paypal大规模支付api在php中使用

时间:2015-07-03 06:59:57

标签: php paypal

我正在尝试使用此代码使用Paypal Mass Payment API,但我收到了此错误。

我将此代码保存到文件'MassPay.php'并将其上传到我的localhost。我正在尝试测试代码,如果我可以使它工作,我将在核心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);
?>

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

您可以使用以下课程进行大额支付交易

用实际的paypal凭证模式(live / sandbox)定义你的常量。

    -(void)dropDownCloseAnimation : (UIButton *)sender withTF : (UITextField *)textField
{
    if (sender.tag == 203 || textField.tag == 106)
    {
        [UIView animateWithDuration:0.9 animations:^{
            self.DropDownView.frame = CGRectMake(self.TFVehicalType.frame.origin.x, self.TFVehicalType.frame.origin.y + self.TFVehicalType.frame.size.height + 2, self.TFVehicalType.frame.size.width, 0);
        } completion:nil];
    }
    else if (sender.tag == 204 || textField.tag == 107)
    {
        [UIView animateWithDuration:0.5 animations:^{
            self.DropDownView.frame = CGRectMake(self.TFVehicalColor.frame.origin.x, self.TFVehicalColor.frame.origin.y + self.TFVehicalColor.frame.size.height + 2, self.TFVehicalColor.frame.size.width, 0);
        } completion:nil];
    }
    else if (sender.tag == 205 || textField.tag == 112)
    {
        [UIView animateWithDuration:0.5 animations:^{
            self.DropDownView.frame = CGRectMake(self.TFCity.frame.origin.x, self.TFCity.frame.origin.y + self.TFCity.frame.size.height + 2, self.TFCity.frame.size.width, 0);
        } completion:nil];
    }
    else if (sender.tag == 206 || textField.tag == 113)
    {
        [UIView animateWithDuration:0.5 animations:^{
            self.DropDownView.frame = CGRectMake(self.TFLocation.frame.origin.x, self.TFLocation.frame.origin.y + self.TFLocation.frame.size.height + 2, self.TFLocation.frame.size.width, 0);
        } completion:nil];
    }
    else if (sender.tag == 207 || textField.tag == 114)
    {
        [UIView animateWithDuration:0.5 animations:^{
            self.DropDownView.frame = CGRectMake(self.TFStatus.frame.origin.x, self.TFStatus.frame.origin.y + self.TFStatus.frame.size.height + 2, self.TFStatus.frame.size.width, 0);
        } completion:nil];
    }
}