Rebill a Transaction

Endpoints

HTTP Method API URL API Version
POST https://paiement.payzone.ma/transaction/{transactionID}/rebill >= 002.51

This call permits to a merchant to rebill 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.

Accepted parameters

Name Type Value Required API Version
apiVersion String(8) API version to be used (default 002.51) yes >= 002.51
amount Integer(32bits) The amount for the capture in cents (for 1€ => 100) yes >= 002.51
orderId String(100) Merchant reference for the current transaction request. If not present the reference of the initial transaction will be used. no >= 002.62

Response

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.51
message String(255) Human readable message associated with the code >= 002.51
transactionID String(20) The unique identifier of the transaction >= 002.51
operation String(32) The effective operation done for the operation >= 002.51

Code samples

     
    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->rebillTransaction($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 rebill request
    // Second argument is the originator ID, third one is the associated API key
    Connect2payClient c2p = new Connect2payClient("https://paiement.payzone.ma", "123456", 
    "GreatP4ssw0rd");

    TransactionRebillRequest request = new TransactionRebillRequest();
    TransactionRebillResponse response = null;

    request.setAmount(100);
    request.setTransactionId("example");

    try {
        response = c2p.rebillTransaction(request);
    } catch (Exception e) {
        logger.error("Ooops, an error occurred rebilling 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
    // and amount to rebill
    const response = await paymentPage.rebillTransaction(transactionId, amount);
    
    if (response) {
        console.log("Error code: " + response.code);
        console.log("Error message: " + response.message);
        console.log("Transaction ID: " + response.transactionID);
    } else {
        console.log("Error occured");
    }
    
                        
 
    var client = new Connect2PayClient(OriginatorConfig.ORIGINATOR_ID, 
    OriginatorConfig.ORIGINATOR_PASSWORD);

    // To make this request we need to know TransactionID of original transaction
    // and amount to rebill

    var requestRebill = client.NewRequestRebill(transactionID);
    requestRebill.SetAmount(5500);
    var responseRebill = await requestRebill.Send();

    if (responseRebill.IsSuccessfull())
    {
        Console.WriteLine("Refund transaction ID: " + responseRebill.transactionID);
    } else {
        Console.WriteLine("Cancellation request failure: "
        + responseRebill.code + ": " + responseRebill.message);
    }
                        
                        

© Payzone | 2023