Sur l'une des pages de documentation de l'API Paypal, il y a la commande suivante.Commande Curl fonctionnant via SSH mais pas via PHP
curl -s --insecure -H "X-PAYPAL-SECURITY-USERID: caller_1312486258_biz_api1.gmail.com" -H "X-PAYPAL-SECURITY-PASSWORD: 1312486294" -H "X-PAYPAL-SECURITY-SIGNATURE: AbtI7HV1xB428VygBUcIhARzxch4AL65.T18CTeylixNNxDZUu0iO87e" -H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON" -H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON" -H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" https://svcs.sandbox.paypal.com/AdaptivePayments/Pay -d "{\"actionType\":\"PAY\", \"currencyCode\":\"USD\", \"receiverList\":{\"receiver\":[{\"amount\":\"1.00\",\"email\":\"[email protected]\"}]}, \"returnUrl\":\"http://www.example.com/success.html\", \"cancelUrl\":\"http://www.example.com/failure.html\", \"requestEnvelope\":{\"errorLanguage\":\"en_US\", \"detailLevel\":\"ReturnAll\"}}"
L'exécution de cette commande via SSH génère une réponse de succès.
J'essaie d'exécuter cette commande exacte via PHP CURL, mais continue à recevoir un message d'erreur indiquant que les informations d'identification de l'API sont incorrectes. Puisque ce n'est manifestement pas le cas (sinon la commande ci-dessus aurait donné une réponse similaire) je ne peux pas arriver à une conclusion autre que quelque chose ne va pas avec mon code, mais une erreur qui m'échappe depuis plusieurs jours maintenant:
$baseurl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay';
define('PAYPAL_API_USER', 'caller_1312486258_biz_api1.gmail.com');
define('PAYPAL_API_PWD', '1312486294');
define('PAYPAL_API_SIGNATURE', 'AbtI7HV1xB428VygBUcIhARzxch4AL65.T18CTeylixNNxDZUu0iO87e');
define('PAYPAL_API_APPLICATION_ID', 'APP-80W284485P519543T');
$returnurl = "http://www.returnurl.net";
$cancelurl = "http://www.cancelnurl.net";
$data = array(
"actionType" => "PAY",
"currencyCode" => "USD",
"receiverList" => array(
"receiver" => array(
array(
"amount" => "1.00",
"email" => "[email protected]"
),
)
),
"returnUrl" => $returnurl,
"cancelUrl" => $cancelurl,
"requestEnvelope" => array(
"errorLangauge" => "en_US",
"detailLevel" => "ReturnAll",
)
);
$headers = array(
"X-PAYPAL-SECURITY-USERID: ".PAYPAL_API_USER,
"X-PAYPAL-SECURITY-PASSWORD: ".PAYPAL_API_PWD,
"X-PAYPAL-SECURITY-SIGNATURE: ".PAYPAL_API_SIGNATURE,
"X-PAYPAL-SECURITY-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-SECURITY-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-SECURITY-APPLICATION-ID: ".PAYPAL_API_APPLICATION_ID,
);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $baseurl);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt ($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt ($ch, CURLOPT_HEADER, $headers);
print_r(curl_exec($ch));
Quelqu'un peut-il trouver quelque chose d'incorrect avec ce code?
Encore une fois je dois souligner que c'est strictement un problème PHP CURL, pas un Paypal.
Vous ne devriez pas inclurons vos clés de sécurité/mots de passe .... c'est un forum public .. – Darren
Darren ce sont les publics publiés sur une page de documentation Paypal: https: // développeur .paypal.com/docs/classique/adaptative-payments/gs_AdaptivePayments /. Bien sûr, je ne poste jamais le mien –
Je regarde mon ami :-) – Darren