Version: 1.1.0-beta

Step 4: Inspect a transaction

After the transaction has been created your application can pick up the transaction ID posted by either the form on your page or by your own code.

Get transaction details#

This transaction ID can be used with the SDK to fetch additional details about the transaction.

const response = await client.getTransaction(transaction_id);
console.log(response.data);

The transaction includes details about the payment method used, and the status of the transaction.

{
"type": "transaction",
"id": "fe26475d-ec3e-4884-9553-f7356683f7f9",
"status": "authorized",
"amount": 1299,
"currency": "USD",
"payment_method": {
"type": "payment-method",
"id": "77a76f7e-d2de-4bbc-ada9-d6a0015e6bd5",
"method": "card",
"status": "stored",
"token": "0123456789123458",
"details": {
"number": "XXXX XXXX XXXX 1111",
"expiration_date": "11 / 21",
"scheme": "visa"
},
...
},
...
}
API Reference

Visit the API reference documentation for full details about the transaction resource, and any other API.

Capture transaction#

Although Gr4vy Embed allows for setting the intent to capture, in some cases it might be desirable to capture the transaction after it has been authorized.

const { Client, TransactionCaptureRequest } = require("@gr4vy/node");
const request = new TransactionCaptureRequest();
request.amount = "1000";
const transaction = await client.captureTransaction(id, request);
Partial capture

Some payment processors allow for partial processing. To capture a part of the authorized amount only, set the amount on the capture request to an amount lower than the originally authorized amount.