我已在我的项目中整合了PayPal付款。
我想加入自动退款选项。
require_once('includes/paypal.class.php');
require_once('includes/paypal.adaptive.class.php');
include('includes/config.php');
// Create PayPal object.
$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);
// Prepare request arrays
$RefundFields = array(
'CurrencyCode' => USD',
// Required. Must specify code used for original payment. You do not need to specify if you use a payKey to refund a completed transaction.
'PayKey' => '',
// Required. The key used to create the payment that you want to refund.
'TransactionID' => '7C0359353Y165821P',
// Required. The PayPal transaction ID associated with the payment that you want to refund.
'TrackingID' => ''
// Required. The tracking ID associated with the payment that you want to refund.
);
$Receivers = array();
$Receiver = array(
'Email' => 'jilu@newagesmb.com',
// A receiver's email address.
'Amount' => '100.00',
// Amount to be debited to the receiver's account.
'Primary' => '',
// Set to true to indicate a chained payment. Only one receiver can be a primary receiver. Omit this field, or set to false for simple and parallel payments.
'InvoiceID' => '',
'PaymentType' => 'GOODS'
// The transaction subtype for the payment. Allowable values are: GOODS, SERVICE
);
array_push($Receivers, $Receiver);
$PayPalRequestData = array(
'RefundFields' => $RefundFields,
'Receivers' => $Receivers
);
//print_r($PayPalRequestData);exit;
$PayPalResult = $PayPal->Refund($PayPalRequestData);
echo '<pre />';
print_r($PayPalResult);
我的输出是:
2014-04-28T02:54:20.805-07:00Failure55b35d9b576e810680030560022PLATFORMApplicationErrorApplicationX-PAYPAL-APPLICATION-ID标头包含无效的值X-PAYPAL-APPLICATION-ID
答案 0 :(得分:0)
您的申请是否通过PayPal完全获得批准?
您可以从以下链接查看:
https://www.paypal-apps.com/user/my-account/applications
如果已通过PayPal完全批准,您可以使用应用程序ID。您可以在上述网址确认后尝试此操作。