Rebill Transaction

Business and website owners often want to store credit card numbers for later to allow re-billing of customers for recurring orders, and allows easier checkout for repeat customers on a website. Normally rebilling requires businesses and websites to store credit card informations, which are subjected to strict PCI-DSS standards. The rebill transaction mechanism enables businesses and websites to perform re-billing of customers for recurring orders without being enforced to store credit card information as this is handles by Payzone.


A Rebill can only happen on a CCSale, CCAuthorize or Capture transaction. In the case of a Capture transaction, the transactionID of the Capture (not the initial CCAuthorize) must be passed as a parameter.


Endpoints

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

Accepted parameters

Field Type Max Length Required Description
transactionID Integer 20 yes Initial transaction reference to rebill
amount Integer 10 yes Number in minor unit, e.g. cents; 100 dollar cent equals to 1 dollar
orderID String 100 no Merchant reference for the current transaction request. If not present the reference of the initial transaction will be used.

Code samples

Note: Gateway API transactions are done with a different library than payment-page API. See the code sample comments for more info:

   
    /*
    *   Transaction name is 'Rebill', once you create a new transaction passing this as parameter, 
    *   you need to set the mandatory data using the following method:
    *    setReferralInformation()
    */

    $client = new GatewayClient();

    $transaction = $client->newTransaction('Rebill', 'testMerchant', 'testPassword');
    $transaction->setReferralInformation($saleOrCaptureTransactionID, 200);
    // Optional, to customize the order ID for this payment
    $transaction->setOrderID("Custom OrderID");

    $response = $transaction->send();

    if ('000' === $response->errorCode) {
        $rebillTransactionID  = $response->transactionID;
    } else {
        echo "Error {$response->errorCode} with message {$response->errorMessage}";
    }
                      
   
    PaymentGatewayConnector connector = new PaymentGatewayConnector(API_URL, ORIGINATOR, PASSWORD);

    RebillResponse response = null;
    RebillRequest request = new RebillRequest();
    request.setTransactionId(1234567L);
    request.setAmount(2500);
    // Optional, to customize the order ID for this payment
    request.setOrderId("Custom OrderID");

    try {
        response = connector.doRebillTransaction(request);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (response != null) {
        if (TransactionResultCode.TRANSACTION_SUCCESSFULLY.equals(response.getErrorCode()) {
        System.out.println("Success: " + response.getErrorMessage());
        } else {
        System.out.println("Failure: " + response.getErrorMessage());
        }
    }
                      
   
    const gateway = require("payxpert")("123456", "GreatP4ssw0rd").gateway;

    let transactionID = "111...";

    let rebillBody = {
        transactionID: transactionID,
        amount: 100500
    };

    let responseRebill = await gateway.rebillTransaction(transactionID, rebillBody);

    if (responseRebill.code == "000") {
        // Success
    }
        
        
   
    var client = new GatewayClient(OriginatorConfig.ORIGINATOR_ID, OriginatorConfig.ORIGINATOR_PASSWORD);
    var rebillTransaction = client.NewRebillTransaction(transactionID);
    rebillTransaction.SetAmount(1500);

    var rebillResponse = rebillTransaction.Send().Result;

    if (rebillResponse.IsSuccessfull())
    {
        Console.WriteLine("Rebill is ok. New transaction ID: " + rebillResponse.transactionID);
    }
    else
    {
        Console.WriteLine("Error performing refund: " + rebillResponse.errorMessage);
    }

                        

Response

The body of the response is in JSON format.

The following fields are present in the response :


Name Type Description
transactionID String Transaction reference returned by the system
errorCode String See API Response Codes
errorMessage String See API Response Codes

© Payzone | 2022