transfer money from one paypal account to another php

Solutions on MaxInterview for transfer money from one paypal account to another php by the best coders in the world

showing results for - "transfer money from one paypal account to another php"
Lennart
22 Aug 2017
1
2            // Get access token from PayPal client Id and secrate key
3            $ch = curl_init();
4
5            curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
6            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
7            curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
8            curl_setopt($ch, CURLOPT_POST, 1);
9            curl_setopt($ch, CURLOPT_USERPWD, PAYPAL_CLIENT_ID . ":" . PAYPAL_SECRATE_KEY);
10
11            $headers = array();
12            $headers[] = "Accept: application/json";
13            $headers[] = "Accept-Language: en_US";
14            $headers[] = "Content-Type: application/x-www-form-urlencoded";
15            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
16
17            $results = curl_exec($ch);
18            $getresult = json_decode($results);
19
20
21            // PayPal Payout API for Send Payment from PayPal to PayPal account
22            curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payouts");
23            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
24
25            $array = array('sender_batch_header' => array(
26                    "sender_batch_id" => time(),
27                    "email_subject" => "You have a payout!",
28                    "email_message" => "You have received a payout."
29                ),
30                'items' => array(array(
31                        "recipient_type" => "EMAIL",
32                        "amount" => array(
33                            "value" => '100',
34                            "currency" => "USD"
35                        ),
36                        "note" => "Thanks for the payout!",
37                        "sender_item_id" => time(),
38                        "receiver" => 'paypalemail@xxx.com'
39                    ))
40            );
41            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array));
42            curl_setopt($ch, CURLOPT_POST, 1);
43
44            $headers = array();
45            $headers[] = "Content-Type: application/json";
46            $headers[] = "Authorization: Bearer $getresult->access_token";
47            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
48
49            $payoutResult = curl_exec($ch);
50            //print_r($result);
51            $getPayoutResult = json_decode($payoutResult);
52            if (curl_errno($ch)) {
53                echo 'Error:' . curl_error($ch);
54            }
55            curl_close($ch);
56            print_r($getPayoutResult);
57
58