Dani
Dani

Reputation: 51

Verify Mobile payment Using Curl (SinglePayment)

I have successfully integrate the PayPal into android app and get the payment id using sandbox account. Please tell me how to use the curl GET to verify the mobile payment.This is the curl but i dont know how to use it in php to get the response.

curl https://api.sandbox.paypal.com/v1/payments/payment/PAY-XXXXXXXXXXX \
-H "Content-Type: application/json" \
-H "Authorization: Bearer accessToken"

https://developer.paypal.com/docs/integration/mobile/verify-mobile-payment/

Upvotes: 2

Views: 386

Answers (1)

hassan
hassan

Reputation: 8288

php provide a lot of built-in functions to execute shell commands.

to execute your command , you only need to use one of the following functions: exec, shell_exec, system, or one of these functions.

$command = 'curl https://api.sandbox.paypal.com/v1/payments/payment/PAY-XXXXXXXXXXXXXX -H "Content-Type: application/json" -H "Authorization: Bearer accessToken"'

exec($command, $return);

another option is to using cURL library:

here is a quick example, you may have to customize this example by adding required curl opt_* options

$ch = curl_init('https://api.sandbox.paypal.com/v1/payments/payment/PAY-XXXXXXXXXXXXXX');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Authorization: Bearer accessToken'
));
$result = curl_exec($ch);
curl_close($ch);

Upvotes: 1

Related Questions