我想付款給兩個接收者,即買家購買100件商品,接收者1得到90,接收者2得到10。我正在使用鏈接付款方式。我在收款人1的賬戶中收到了100美元,但是我無法收到收款人2的付款。收件人的帳戶ID已設置,但未在此處給出。我做錯了什麼?謝謝Paypal自適應付款
<?php
require_once('../includes/config.php');
require_once('../includes/paypal.class.php');
$PayPalConfig = array(
'Sandbox' => $sandbox,
'DeveloperAccountEmail' => $developer_account_email,
'ApplicationID' => $application_id,
'DeviceID' => $device_id,
'IPAddress' => $_SERVER['REMOTE_ADDR'],
'APIUsername' => $api_username,
'APIPassword' => $api_password,
'APISignature' => $api_signature,
'APISubject' => $api_subject
);
$PayPal = new PayPal_Adaptive($PayPalConfig);
$PayRequestFields = array(
'ActionType' => 'PAY_PRIMARY',
'CancelURL' => $domain.'cancel.php',
'CurrencyCode' => 'USD',
'FeesPayer' => 'EACHRECEIVER',
'IPNNotificationURL' => '',
'Memo' => '',
'Pin' => '',
'PreapprovalKey' => '',
'ReturnURL' => $domain.'return.php',
'ReverseAllParallelPaymentsOnError' => '',
'SenderEmail' => '',
'TrackingID' => ''
);
$ClientDetailsFields = array(
'CustomerID' => '',
'CustomerType' => '',
'GeoLocation' => '',
'Model' => '',
'PartnerName' => ''
);
$FundingTypes = array('ECHECK', 'BALANCE', 'CREDITCARD');
$Receivers = array();
$Receiver = array(
'Amount' => '100.00',
'Email' => 'receiver1accountid',
'InvoiceID' => '',
'PaymentType' => 'GOODS',
'PaymentSubType' => '',
'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''),
'Primary' => 'true'
);
array_push($Receivers,$Receiver);
$Receiver = array(
'Amount' => '10.00',
'Email' => 'receiver2accountid',
'InvoiceID' => '',
'PaymentType' => 'GOODS',
'PaymentSubType' => '',
'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''),
'Primary' => 'false'
);
array_push($Receivers,$Receiver);
$SenderIdentifierFields = array(
'UseCredentials' => ''
);
$AccountIdentifierFields = array(
'Email' => '',
'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => '')
);
$PayPalRequestData = array(
'PayRequestFields' => $PayRequestFields,
'ClientDetailsFields' => $ClientDetailsFields,
'FundingTypes' => $FundingTypes,
'Receivers' => $Receivers,
'SenderIdentifierFields' => $SenderIdentifierFields,
'AccountIdentifierFields' => $AccountIdentifierFields
);
$PayPalResult = $PayPal->Pay($PayPalRequestData);
if(!$PayPalResult)
{
$errors = array('Errors'=>$PayPalResult['Errors']);
echo '<pre />';
print_r($errors);
exit();
}
else
{
header('Location: '.$PayPalResult['RedirectURL']);
$ExecutePaymentFields = array(
'PayKey' => $PayPalResult['PayKey'],
'FundingPlanID' => ''
);
$PayPalRequestData = array('ExecutePaymentFields' => $ExecutePaymentFields);
$PayPalResult = $PayPal->ExecutePayment($PayPalRequestData);
if(!$PayPalResult)
{
$errors = array('Errors'=>$PayPalResult['Errors']);
echo '<pre />';
print_r($errors);
exit();
}
else
{
echo '<pre />';
print_r($PayPalResult);
}
}
?>
謝謝安德魯!我只是完成了它。不過,我只想讓這兩筆款項同時完成。感謝您寶貴的意見,以及您建立的圖書館。它真的很有趣。再次感謝........ –
抱歉不能投票,因爲我的repu不允許截至目前....... :-) –
@Andrew Angell您好,我想延遲二次付款,因爲二級接收器只有在完成任務後纔會被記入。所以,你能告訴我你的想法如何解決這個問題嗎?建議一些鏈接... – SDK