begiPass
begiPass

Reputation: 2174

execute curl command inside php script and get response from server and extract it

I want to verify the proof of android paypal payment to do that, I want to execute this code :

    curl https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails \
 -H "X-PAYPAL-SECURITY-USERID: user_id" \
 -H "X-PAYPAL-SECURITY-PASSWORD: password" \
 -H "X-PAYPAL-SECURITY-SIGNATURE: signature" \
 -H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" \
 -H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" \
 -H "X-PAYPAL-APPLICATION-ID: APP-91B933855X481767M" \
 -d "payKey=AP-70M68096ML426802W&requestEnvelope.errorLanguage=en_US"

since I am just a beginner in php, how can I run this command in php script and receive a response

can you link me to some examples also

thank you

Upvotes: 0

Views: 755

Answers (1)

Sabuj Hassan
Sabuj Hassan

Reputation: 39443

$http_header = array(
    "X-PAYPAL-SECURITY-USERID: user_id",
    "X-PAYPAL-SECURITY-PASSWORD: password",
    "X-PAYPAL-SECURITY-SIGNATURE: signature",
    "X-PAYPAL-REQUEST-DATA-FORMAT: NV",
    "X-PAYPAL-RESPONSE-DATA-FORMAT: NV",
    "X-PAYPAL-APPLICATION-ID: APP-91B933855X481767M"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails");
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header );
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "payKey=AP-70M68096ML426802W&requestEnvelope.errorLanguage=en_US");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);

$html = curl_exec ($ch);
echo $html;

Upvotes: 1

Related Questions