PayTabs Node.js Package makes integration with the PayTabs payment gateway very easy by providing a ready-made payment class that handles the card entry and, billing & shipping information and completes the missing details.

To void a transaction means that the previously authorized/held amount from a previous auth transaction will be released back to the cardholder's bank account from his own bank side, as it was kept on hold there. In this article, we walk you through how to use and manage the below function:




let transactionCreated = function ($results){
    console.log($results);
}

paytabs.queryTransaction(
    transactionDetails,
    cartDetails,
    transactionCreated
);


Void requests are available for ONLY authenticated "Auth" transactions that are NOT fully captured yet.


Through out the article we will use the transaction types clarified in our What is "tran_type"? solution article.


Transaction Reference 


The Parameter Tag/NametransactionDetails 
Example
let transactionDetails = [
    transaction.ref,
    transaction.typ,
    transaction.cls
];
JavaScript
Data TypeArray
Required

transaction.ref Indicates the reference to the "Auth" transaction you want to capture
transaction.typ release 
transaction.cls
ecom



Cart Details


The Parameter Tag/NamecartDetails 
Example
let cartDetails = [
    cart.id,
    cart.currency,
    cart.amount,
    cart.description
];
HTML
Data TypeArray
Required

cart.idIndicates the cart id to the transaction you want to create
cart.currency
Indicates the currency
cart.amount
Indicates the amount you want to capture, either the full amount for a full capture or partial one for partial capture.
cart.description
Indicates the cart/order description at your end to easily relate this transaction to. It might contain the reason for the capture.




transactionCreated (callable)



The Parameter Tag/NametransactionCreated 
Example
let transactionCreated = function ($results){
    console.log($results);
}
JavaScript
Data Typecallable function
Required

PurposeIndicates the function to be run after the payment.
Validation Rules-



Sample Response Payload


To process a capture request, you have to pass a tran_type that MUST be void” and the transaction reference of the original authenticated "Auth" transaction that you want to void, as shown in the below sample:


let transaction = {
    ref: 'TST2229801363947',       // the previous auth transaction ref
    typ: 'release',                // release: partial | void: full
    cls: 'ecom'
};

let cart = {
    id: 'VOID100001',
    currency: 'EGP',
    amount: 100,                   // the amount to release
    description: 'partial void test'
};

let transactionDetails = [
    transaction.ref,
    transaction.typ,
    transaction.cls
];

let cartDetails = [
    cart.id,
    cart.currency,
    cart.amount,
    cart.description
];

let transactionCreated = function ($results){
    console.log($results);
}

paytabs.queryTransaction(
    transactionDetails,
    cartDetails,
    transactionCreated
);


Void requests are available for ONLY authenticated "Auth" transactions that are NOT fully captured yet.



Sample Response Payload

Generic


The response PayTabs will send to you will be a JSON object that contains the full details regarding this void transaction, as shown below:

 
{
  tran_ref: 'TST2229901364658',
  previous_tran_ref: 'TST2229801363947',
  tran_type: 'Release',
  cart_id: 'VOID100001',
  cart_description: 'partial void test',
  cart_currency: 'EGP',
  cart_amount: '100.00',
  customer_details: {
    name: 'Mohammed ELRayes',
    email: '[email protected]',
    phone: '+201234567890',
    street1: 'dummy street',
    city: 'Port Fouad',
    state: 'PTS',
    country: 'EG',
    zip: '42121'
  },
  payment_result: {
    response_status: 'A',
    response_code: 'G84502',
    response_message: 'Authorised',
    transaction_time: '1970-01-01T00:00:00Z'
  },
  payment_info: {
    payment_method: 'Visa',
    card_type: 'Credit',
    card_scheme: 'Visa',
    payment_description: '4111 11## #### 1111',
    expiryMonth: 12,
    expiryYear: 2022
  },
  serviceId: 1,
  profileId: 8***4,
  merchantId: 3***7,
  trace: 'PMN****3.63****F6.00****ED'
}
Generic


This means that the previously authorized/held amount from a previous auth transaction will be released back to the cardholder's bank account from his own bank side (as it kept hold there).








⌂ To get familiar with the whole process and the other steps, kindly navigate to our "The Node.js Packge Integration Manual" solution article. 

 And to get familiar with the rest of the steps regarding the current step "Step 7 - Manage Transactions" kindly click here.

 And to navigate to the previous step in the integration process "Step 6 - Handle the post payment responses" kindly click here.