Shakti Sisodiya
Shakti Sisodiya

Reputation: 228

What is process to integrate paypal payout rest API in php

I am working on PayPal Payout API.i am not getting what exactly process should be for a complete payout payment method.everything is working fine but still there are so many bugs. what I and mobile application developer is doing.

Mobile API calls to the server with an amount so that server side a PayPal SDK has been integrated where I make a call on PayPal and make a transaction.

The problem is that whether a payer email register or not in Paypal it returns status PENDING without any transaction id.

And I have set up an IPN listener on PayPal which makes a call whenever payout status update. but it returns transaction_id and I am not getting transaction id while payout made.

I don't know what I need to do with it. Please if you did not understand you can drop a comment.

I am using the simple code for Payouts.

$headers = array(
        'Content-Type:application/json',
        'Authorization:Bearer '.$accsessToken,
    );


    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payouts?sync_mode=false");
    // curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     curl_setopt($ch, CURLOPT_TIMEOUT, 1);
    curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));



$result = curl_exec($ch);
$response = json_decode($result, 1);

$payoutBatchId = $response['batch_header']['payout_batch_id'];




$headers = array(
        'Content-Type:application/json',
        'Authorization:Bearer '.$accsessToken,
    );

unset($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payouts/".$payoutBatchId);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$response = json_decode($result, 1);

dd($response);

Upvotes: 0

Views: 933

Answers (1)

Alexandre Painchaud
Alexandre Painchaud

Reputation: 462

I think you should use PHP Paypal SDK. There is some easy examples.

Hope this help.

Upvotes: 1

Related Questions