HTTP Method | API URL | API Version |
---|---|---|
POST | https://paiement.payzone.ma/transaction/{transactionID}/refund | >= 002.50 |
This call permits to a merchant to refund the given transaction. Note that the transactionID that uniquely identifies the transaction is part of the URL (the string {transactionID} in the URL must be replaced by the transactionID returned in the initial payment status).
The information for the payment are serialized in JSON format and are transmitted in the body of the request.
Name | Type | Description | Required | API Version |
---|---|---|---|---|
apiVersion | String(8) | API version to be used (default 002.50) | yes | >= 002.50 |
amount | Integer(32bits) | The amount for the capture in cents (for 1€ => 100) | yes | >= 002.50 |
The body of the response to a payment cancel request is in JSON format.
The following fields are present in the response :
Name | Type | Description | API Version |
---|---|---|---|
code | String(3) | API response code (see API Response Codes for possible values) | >= 002.50 |
message | String(255) | Human readable message associated with the code | >= 002.50 |
transactionID | String(20) | The unique identifier of the transaction | >= 002.50 |
operation | String(32) | The effective operation done for the operation | >= 002.51 |
use PayXpert\Connect2Pay\Connect2PayClient;
$url = "https://paiement.payzone.ma";
// This will be provided once your account is approved
$originator = "000000";
$password = "Gr3atPassw0rd!";
$transactionId = "example";
$amount = "100";
$c2pClient = new Connect2PayClient($url, $originator, $password);
$status = $c2pClient->cancelTransaction($transactionId, $amount);
if ($status != null && $status->getCode() != null) {
$code = (int) $status->getCode();
echo "Error code: " . $status->getCode() . "\n";
echo "Error message: " . $status->getMessage() . "\n";
echo "Transaction ID: " . $status->getTransactionID() . "\n";
} else {
echo "Error: " . $c2pClient->getClientErrorMessage() . "\n";
}
// Instantiate the client and send the cancel request
// Second argument is the originator ID, third one is the associated API key
Connect2payClient c2p = new Connect2payClient("https://paiement.payzone.ma", "123456",
"GreatP4ssw0rd");
TransactionCancelRequest request = new TransactionCancelRequest();
TransactionCancelResponse response = null;
request.setAmount(100);
request.setTransactionId("example");
try {
response = c2p.cancelTransaction(request);
} catch (Exception e) {
logger.error("Ooops, an error occurred canceling the transaction: " + e.getMessage());
// Handle the error...
}
const paymentPage = require("payxpert")("123456", "GreatP4ssw0rd").connect2pay;
// To make this request we need to know TransactionID of original transaction to be cancelled
const responseCancel = await paymentPage.cancelTransaction(transactionId, amount);
if (responseCancel) {
console.log("Error code: " + responseCancel.code);
console.log("Error message: " + responseCancel.message);
console.log("Transaction ID: " + responseCancel.transactionID);
} else {
console.log("Error occurred");
}
var client = new Connect2PayClient(OriginatorConfig.ORIGINATOR_ID,
OriginatorConfig.ORIGINATOR_PASSWORD);
var requestCancel = client.NewRequestTransactionCancel(transactionID);
requestCancel.SetAmount(1500);
var responseCancel = await requestCancel.Send();
if (responseCancel.IsSuccessfull())
{
Console.WriteLine("Cancellation transaction ID: " + responseCancel.transactionID);
} else {
Console.WriteLine("Cancellation request failure: " + responseCancel.code + ": " + responseCancel.message);
}