Credit Card Capture Transaction

The process of checking that the credit card being used in a transaction contains sufficient funds to cover the amount of the transaction. Note that if sufficient funds are found, the amount is held for a given period of time, waiting to be withdrawn when settlement occurs (the period of time varies based on the issuing bank of the credit card).

Endpoints

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

Accepted parameters

Field Type Max Length Required Description
transactionID Integer 20 yes Initial transaction reference to capture
amount Integer 10 yes Number in minor unit, e.g. cents; 100 dollar cent equals to 1 dollar

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


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 'Capture', 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('Capture', 'testMerchant', 'testPassword');
    $transaction->setReferralInformation($authorizeTransactionID, 200);

    $response = $transaction->send();

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

    CaptureResponse response = null;
    CaptureRequest request = new CaptureRequest();
    request.setTransactionId(1234567L);
    request.setAmount(2500);

    try {
        response = connector.doCaptureTransaction(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 = "111222";

    const captureBody = {
        transactionID: transactionId,
        amount: 1000
    };

    const responseCapture = await gateway.creditCardCapture(transactionId, captureBody);

    if (responseCapture.code == "000") {
        // Success
    }
        
        
   
    var client = new GatewayClient(OriginatorConfig.ORIGINATOR_ID, OriginatorConfig.ORIGINATOR_PASSWORD);
    var transaction = client.NewCaptureTransaction(TransactionID);

    transaction.SetAmount(1000);

    var response = await transaction.Send();

    if (response.IsSuccessfull())
    {
        Console.WriteLine("Capture operation ok. Capture transaction ID: " + response.transactionID);
    }
                        
                        

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