Bonjour,
J'ai un problème lorsque je veux utiliser la fonction DoExpressCheckout de Paypal. Celle-ci fonctionne avec la monnaie USD mais lorsque je veux le faire en EUR, l'API me retourne une erreur 10444 me disant "The transaction currency specified must be the same as previously specified."
mon code est le suivant :
$response = $paypal->request('DoExpressCheckoutPayment', array(
'TOKEN' => $_GET['token'],
'PAYERID' => $_GET['PayerID'],
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
'PAYMENTREQUEST_0_AMT' => $_SESSION['TotalPanier'],
'PAYMENTREQUEST_O_CURRENCYCODE' => 'EUR',
));
if($response){
var_dump($response);
}else{var_dump($paypal->errors); die('Erreur ! ');}
L'objet paypal et la fonction request est la suivante :
<?php
class Paypal{
private $user = 'sell_api1.dev.fr';
private $pwd = '*******';
private $signature = '*******';
private $endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
public $errors = array();
public function __construct($user = false, $pwd = false, $signature = false, $prod = false){
if($user){$this->user = $user;}
if($pwd){$this->pwd = $pwd;}
if($signature){$this->signature = $signature;}
if($prod){$this->endpoint = 'https://api-3t.paypal.com/nvp';}
}
public function request($method, $params){
$params = array_merge($params, array(
'METHOD' => $method,
'VERSION' => '124.0',
'USER' => $this->user,
'SIGNATURE' => $this->signature,
'PWD' => $this->pwd,
));
$params = http_build_query($params);
$endpoint = 'https://api-3T.sandbox.paypal.com/nvp';
$curl = curl_init();
curl_setopt_array($curl,array(
CURLOPT_URL => $this->endpoint,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $params,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_VERBOSE => 1,
));
$responsePaypal = curl_exec($curl);
$response = array();
parse_str($responsePaypal, $response);
if(curl_errno($curl)){
$this->errors = curl_error($curl);
curl_close($curl);
return false;
}else{
if($response['ACK'] == 'Success'){
curl_close($curl);
return $response;
}else{
$this->errors = $response;
curl_close($curl);
return false;
}
}
}
}
?>
Merci d'avance pour votre aide