Annuler un ordre de paiement
Cas d'utilisation
Le marchand souhaite annuler un ordre de paiement.
Le Web Service Charge/PaymentOrder/Cancel permet d'annuler uniquement les ordres de paiement créés avec le Web Service Charge/CreatePaymentOrder.
Seuls les ordres de paiement en cours (statut RUNNING) peuvent faire l'objet d'une annulation.
Tester
Testez le web service Charge/PaymentOrder/Cancel depuis notre playground.
Requête
Exemple de requête
Le paramètre `paymentOrderId` est généré lors de l'appel au Web Service Charge/CreatePaymentOrder dans la réponse PaymentOrder.
Paramètre | Requis | Description |
---|---|---|
paymentOrderId | Oui | Référence unique de l'ordre de paiement générée par la plateforme. |
{ "paymentOrderId": "d63e7f507a6f4dfa86cb40a833ecfd85" }
/** * I initialize the PHP SDK */ require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/keys.php'; require_once __DIR__ . '/helpers.php'; /** * Initialize the SDK * see keys.php */ $client = new Lyra\Client(); /** * I create a formToken */ $store = array("amount" => 250, "currency" => "EUR", "orderId" => uniqid("MyOrderId"), "customer" => array( "email" => "sample@example.com" )); $response = $client->post("V4/Charge/CreatePayment", $store); /* I check if there are some errors */ if ($response['status'] != 'SUCCESS') { /* an error occurs, I throw an exception */ display_error($response); $error = $response['answer']; throw new Exception("error " . $error['errorCode'] . ": " . $error['errorMessage'] ); } /* everything is fine, I extract the formToken */ $formToken = $response["answer"]["formToken"]; ?>
/** * I initialize the PHP SDK */ require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/keys.php'; require_once __DIR__ . '/helpers.php'; /** * Initialize the SDK * see keys.php */ $client = new Lyra\Client(); /** * I create a formToken */ $store = array("amount" => 250, "currency" => "EUR", "orderId" => uniqid("MyOrderId"), "customer" => array( "email" => "sample@example.com" )); $response = $client->post("V4/Charge/CreatePayment", $store); /* I check if there are some errors */ if ($response['status'] != 'SUCCESS') { /* an error occurs, I throw an exception */ display_error($response); $error = $response['answer']; throw new Exception("error " . $error['errorCode'] . ": " . $error['errorMessage'] ); } /* everything is fine, I extract the formToken */ $formToken = $response["answer"]["formToken"]; ?>
Réponse
Exemple de Réponse
{ "webService": "Charge/PaymentOrder/Cancel", "version": "V4", "applicationVersion": "5.5.0", "status": "SUCCESS", "answer": { "paymentOrderId": "fd8f6060f824427ba687d0161e46af8f", "paymentURL": "https://sogecommerce.societegenerale.eu/t/328zq5so", "paymentOrderStatus": "CANCELED", "creationDate": "2020-03-31T15:06:49+00:00", "updateDate": null, "amount": 10000, "currency": "EUR", "locale": "fr_FR", "strongAuthentication": "AUTO", "orderId": "myOrderId-1234", (...) "serverDate": "2020-04-01T08:20:46+00:00", "applicationProvider": "SOGECOM", "metadata": null, "_type": "V4/WebService/Response" } }
Gestion des erreurs
Tableau des erreurs
| Code | Description | | ------------ | ---------------------------------------------------------------------------------- | | **INT_902** | Le format du champ **paymentOrderId** est invalide ou le champ n'est pas transmis. | | **PSP_1000** | L'ordre de paiement n'existe pas. | {: .lita-excluded-col1 }