skip to Main Content

I appreciate your advice on this matter. I’ve been looking for a way to send payments to multiple receivers from paypal for a few days, I’m developing a platform in Laravel, and I’ve tried the api-sdk-php, and it works perfectly for individual payments
however, I have not got the corresponding method to create an invoice similar to this one.

2 Tennis 25 $

[email protected]

1 Redmi 10 $ 150

[email protected]

I have reviewed many threads, some mention the adaptive payments of paypal, however when I review the documentation it shows me that this payment format is deprecated and the APP_ID parameter currently I could not obtain it.

I also read and tried some guides but in the end I used deprecated code, I found libraries with tiny documentation, except the official PayPal one, every day I end up more disoriented, I appreciate the help and advice that you can give me to achieve the goal, and leave an answer that I can help others in the future.

2

Answers


  1. Chosen as BEST ANSWER

    I found my solution for Laravel or PHP, Adaptive payments still work, I used that old method and managed to create an invoice of several receivers and receive in his sandbox accounts.

    I will share my finding so that others can also benefit, although I can not give myself any credit, the solution is found in the channel from youtube optikalefx and support me from the paypal api.

    Here the solution, I hope it helps other programmers

        $createPacket = array(
            "actionType" => "PAY", // Payment action type
            "currencyCode" => "USD", // Payment currency code
            "receiverList" => array(
                "receiver" => array(
                    array(
                        "amount" => "25", // Payment amount
                        "email" => "[email protected]", // Receiver's email address
                    ),
                    array(
                        "amount" => "150", // Payment amount
                        "email" => "[email protected]", // Receiver's email address
                    ),
    
                ),
            ),
            "returnUrl" => url("/"), // Redirect URL after approval
            "cancelUrl" => url("/"), // Redirect URL after cancellation
            "requestEnvelope" => array(
                "errorLanguage" => "en_US", // Language used to display errors
                "detailLevel" => "ReturnAll", // Error detail level
            ),
        );
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($createPacket));
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            "X-PAYPAL-SECURITY-USERID:" . "YOUR_USER_ID",
            "X-PAYPAL-SECURITY-PASSWORD:" . "YOUR_SECURITY_PASSWORD",
            "X-PAYPAL-SECURITY-SIGNATURE:" . "YOUR_SIGNATURE",
            "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T", //USE THIS Global SANDBOX APP ID 
            "X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
            "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
        ]);
    
        $response = json_decode(curl_exec($ch), true);
        return redirect("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=".$response['payKey']));
    

  2. Yes, Adaptive Payments was deprecated back in December of 2017

    Currently there is no general purpose parallel payments solution. Your best bet is probably to see if you can be approved for Payouts with an account you control, and for that account to be the primary receiver: https://developer.paypal.com/docs/payouts/integrate/prerequisites/

    Then you can send payouts from that account to any secondary receiver(s), with additional API calls.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search