1

I am new to doing anything with paypal, and it's frustrating to me. I am just trying to create the chained payment with this here using sandbox business account:

$api = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay";

$input = array(
    "actionType" => "CREATE",
    "currencyCode" => "USD",
    "feesPayer" => "EACHRECEIVER",
    "memo" => "TestNote",
    "receiverList" => array(
        "receiver" => array( //first goes to merchant(95% of payment)
            "amount" => "95.00",
            "email" => "rbxseller@gmail.com",
            "primary" => true
        ),
        "receiver" => array( //then sends 5% commission to owner of site
            "amount" => "5.00",
            "email" => "rbxowner@gmail.com",
            "primary" => false
        )
    ),
    "requestEnvelope" => array(
        "errorLanguage" => "en_US"
    )
);

$headers = array(
    "X-PAYPAL-SECURITY-USERID: ".USER_ID,
    "X-PAYPAL-SECURITY-PASSWORD: ".USER_PASS,
    "X-PAYPAL-SECURITY-SIGNATURE: ".USER_SIG,
    "X-PAYPAL-REQUEST-DATA-FORMAT: NV",
    "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
    "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T"
);

$ch = curl_init($api);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($input));
$response = curl_exec($ch);
var_dump($response);

I got the error response:

[{"errorId":"580001","domain":"PLATFORM","subdomain":"Application","severity":"Error","category":"Application","message":"Invalid request: {0}"}]

Thank you for taking time to reply!

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
cola
  • 13
  • 2
  • Might be worth trying some answers [here](http://stackoverflow.com/questions/15854931/paypal-implicit-payment-error-580001). – Joe C Feb 05 '17 at 10:33

1 Answers1

0

You're not going to be able to simply submit an array of data to the PayPal end point. You'll need to build out an XML request for Adaptive Payments.

I would recommend you take a look at my PayPal PHP Class Library, which works in very much the same way you're trying to work here, except that it would take your array data, generate the XML request, send it to PayPal, parse the XML result and return an array back to you.

It supports all PayPal APIs including Adaptive Payments, and it comes with fully functional samples as well as ready-made template files to start fresh calls with.

Drew Angell
  • 25,968
  • 5
  • 32
  • 51