gpt4 book ai didi

php - paypal 批量支付 api 在 php 中的使用

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:49:53 25 4
gpt4 key购买 nike

我正在尝试通过此代码使用 Paypal Mass Payment API,但出现此错误。

我将此代码保存到文件“MassPay.php”中并将其上传到我的本地主机。我正在尝试测试代码,如果我可以让它工作,我将在核心 php 中使用它,每月支付给教师。

Array
(
[TIMESTAMP] => 2015-07-03T06:55:19Z
[CORRELATIONID] => 437cfd2eedc02
[ACK] => Failure
[VERSION] => 74.0
[BUILD] => 17235934
[L_ERRORCODE0] => 10004
[L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
[L_LONGMESSAGE0] => The number of input records is less than or equal to zero
[L_SEVERITYCODE0] => Error
[ERRORS] => Array
(
[0] => Array
(
[L_ERRORCODE] => 10004
[L_SHORTMESSAGE] => Transaction refused because of an invalid argument. See additional error messages for details.
[L_LONGMESSAGE] => The number of input records is less than or equal to zero
[L_SEVERITYCODE] => Error
)

)

[REQUESTDATA] => Array
(
[USER] => dudhat-facilitator_api1.artoongames.com
[PWD] => AXAT8HSZRR4XANFZ
[VERSION] => 74.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => AFcWxV21C7fd0v3bYYYRCpSSRl31Ab1QV5bWA6uEZ.6emUAkZaZEhjiA
[METHOD] => MassPay
[EMAILSUBJECT] => dudhat@artoongames.com
[CURRENCYCODE] => USD
[RECEIVERTYPE] => EmailAddress
)

[RAWREQUEST] => USER=dudhat-facilitator_api1.artoongames.com&PWD=AXAT8HSZRR4XANFZ&VERSION=74.0&BUTTONSOURCE=AngellEYE_PHPClass&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31Ab1QV5bWA6uEZ.6emUAkZaZEhjiA&METHOD=MassPay&EMAILSUBJECT=dudhat%40artoongames.com&CURRENCYCODE=USD&RECEIVERTYPE=EmailAddress
[RAWRESPONSE] => TIMESTAMP=2015%2d07%2d03T06%3a55%3a19Z&CORRELATIONID=437cfd2eedc02&ACK=Failure&VERSION=74%2e0&BUILD=17235934&L_ERRORCODE0=10004&L_SHORTMESSAGE0=Transaction%20refused%20because%20of%20an%20invalid%20argument%2e%20See%20additional%20error%20messages%20for%20details%2e&L_LONGMESSAGE0=The%20number%20of%20input%20records%20is%20less%20than%20or%20equal%20to%20zero&L_SEVERITYCODE0=Error
)

使用此代码“MassPay.php”

<?php

// Include required library files.
require_once('includes/config.php');
require_once('includes/paypal.class.php');

// Create PayPal object.
$PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature);
$PayPal = new PayPal($PayPalConfig);

// Prepare request arrays
$MPFields = array(
'emailsubject' => 'dudhat@artoongames.com', // The subject line of the email that PayPal sends when the transaction is completed. Same for all recipients. 255 char max.
'currencycode' => 'USD', // Three-letter currency code.
'receivertype' => 'EmailAddress' // Indicates how you identify the recipients of payments in this call to MassPay. Must be EmailAddress or UserID
);

// Typically, you'll loop through some sort of records to build your MPItems array.
// Here I simply include 3 items individually.

$Item1 = array(
'l_email' => 'dudhat@gmail.com', // Required. Email address of recipient. You must specify either L_EMAIL or L_RECEIVERID but you must not mix the two.
'l_receiverid' => 'dudhat@gmail.com', // Required. ReceiverID of recipient. Must specify this or email address, but not both.
'l_amt' => '10.00', // Required. Payment amount.
'l_uniqueid' => '522', // Transaction-specific ID number for tracking in an accounting system.
'l_note' => 'test payment' // Custom note for each recipient.
);

$Item2 = array(
'l_email' => 'dilip@gmail.com', // Required. Email address of recipient. You must specify either L_EMAIL or L_RECEIVERID but you must not mix the two.
'l_receiverid' => 'dilip@gmail.com', // Required. ReceiverID of recipient. Must specify this or email address, but not both.
'l_amt' => '1.00', // Required. Payment amount.
'l_uniqueid' => '523', // Transaction-specific ID number for tracking in an accounting system.
'l_note' => 'test payment' // Custom note for each recipient.
);



$MPItems = array($Item1,$Item2); // etc

$PayPalRequestData = array('MPFields' => $MPFields, 'MPItems' => $MPFields);

// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->MassPay($PayPalRequestData);

// Write the contents of the response array to the screen for demo purposes.
echo '<pre />';
print_r($PayPalResult);
?>

最佳答案

您在 $MPItems 中组装了一些支付项目,但没有将 $MPItems 添加到 PayPal 请求数据中。因此,PayPal 以不包含任何付款项目为由拒绝了批量付款。

关于php - paypal 批量支付 api 在 php 中的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31200519/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com