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.


Capture request is available for successfully Authenticated Authorized transactions, to process a capture request tran_type should be “capture” and the transaction id of the original Authorize transaction that you want to capture should be passed in the tran_ref parameter.


  


You can either capture a partial or full authorized amount or based on the amount, we walk you through how to use and manage the below function:


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

paytabs.queryTransaction(
    transactionDetails,
    cartDetails,
    transactionCreated
);


Capture request is ONLY available for successfully Authorized (Auth) transactions. 


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
];
Data TypeArray
Required

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



Cart Details


The Parameter Tag/NamecartDetails 
Example
let cartDetails = [
cart.id,
cart.currency,
cart.amount,
cart.description
];
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);
}
Data Typecallable function
Required

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




Sample Request Payload


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


let transaction = {
    ref: 'TST2229801363947',
    typ: 'capture',
    cls: 'ecom'
};

let cart = {
    id: 'CAP100001',
    currency: 'EGP',
    amount: 200,
    description: 'partial capture 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
);


Capture request is ONLY available for successfully Authorized (Auth) transactions. 



Sample Response Payload

Generic


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


{
  tran_ref: 'TST2229901364842',
  previous_tran_ref: 'TST2229801363947',
  tran_type: 'Capture',
  cart_id: 'CAP100001',
  cart_description: 'partial capture test',
  cart_currency: 'EGP',
  cart_amount: '200.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: 'G94611',
    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****4.63****73.00****43'
}


This means that the previously authorized/hold amount from a previous auth transaction will be captured/transferred from the cardholder's bank account to your bank account.






⌂ 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.