-3

I want to make a Adaptive payment from one account to other account.I can get a Access token .But i don't know how to make a Pay API call using Access token. Actually I want to bypass PayPal login screen.

    global $token;
     $url = 'https://api.sandbox.paypal.com/v1/AdaptivePayments/Pay';

     $createPacket = array(
        "actionType" => 'PAY',
        "currencyCode" => "SGD",
        "receiverList" => array(
            "receiver" => array(
                array(
                    "amount" => '34.00',
                    "email" => 'abc@gmail.com',
                )
            )
        ),
        "returnUrl" => $params['redirect_url'],
        "cancelUrl" => $params['cancel_url'],
        'senderEmail' =>'abcd@gmail.com',
        "requestEnvelope" => $this->envelope);

    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Authorization: Bearer ' . $token,
        'Accept: application/json',
        'Content-Type: application/json'
    ));

    curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($createPacket) );
    #curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
    $response = curl_exec($curl);

Your help would be appreciated.

Kosala Yapa
  • 64
  • 2
  • 9

1 Answers1

0

To the best of my knowledge, it is not possible to skip the authentication screen. At some point, the user or owner of the account you are working with must authenticate in order to prove that he has given you permission to perform the work you are doing.

You might wonder why Authentication is needed when you pass an Authorization token in the API call, but the auth token that you pass as 'Authorization: Bearer ' . $token, is actually identification of your application and not the user.

Jared Clemence
  • 1,062
  • 11
  • 26