Search code examples
phppaypalpaypal-rest-sdkpaypal-adaptive-payments

Transfer funds from one personal account to another directly with PayPal API in PHP


I want to know what is the best choice to transfer the funds from one personal to another in PHP. There was some solutions before, but now those are deprecated such as Adaptive API etc. I found one solution in here, but when I transfer the funds, it sent to my default business account. Here is the code:

$params = [
    'intent' => 'CAPTURE',
    'purchase_units' => [
        [
            'amount' => [
                'currency_code' => $currency,
                'value' => (string) $amount
            ],
            'payee' => [
                'email_address' => $address //receiver user PayPal email address
            ]
        ]
    ]
];
$data = $this->encodeData($params);
$headers = $this->getAuthHeaders($data);
$res = $this->execute('POST, '/v2/checkout/orders', $data, $headers);

It's really strange why I can't send it directly to this recipient.


Solution

  • DATA====>{"intent":"CAPTURE","purchase_units":[{"amount":{"currency_code":"USD","value":"50"},"payee":{"email":"[email protected]"}}],"application_context":{"user_action":"PAY_NOW","shipping_preference":"NO_SHIPPING","return_url":"https://xxx.com","cancel_url":"https://xxx.com"}} : Here is $data

    Your request data is specifying email rather than email_address, so this is unrecognized and ignored.

    Check your encodeData function to see why this is happening.