Tutorial: Testing Webhook Integration on Staging
This demo acts as a reference to test Webhook responses in the Staging Environment.
Step 1: Creating a Sample Playground: First, we need to set up a specific URL for your application to send its Webhook Events. We will use webhook.site,https://webhook.site/ a platform that allows us to create unique URLs and email addresses for free, and instantly view all the data sent to these addresses.
In the screenshot above, you can see the test URL: https://webhook.site/eeadafbf-e654-40c8-af9e-35b5773fc463. This is the link where we'll set up your Webhook Events.
Step 2: Configuring the Webhook URL: To update your Webhook URL, you'll need to provide the Webhook URL in the body parameters and access-token in the headers. You can obtain your access token by visiting the Refresh Access Token - Transak API Documentation.
After obtaining both your Webhook URL from webhook.site and your access token, navigate to the https://docs.transak.com/reference/update-webhook page. Make a request to update your Webhook URL.
Upon successful submission, the response will resemble the following:
{
"meta": {
"success": true
},
"data": {
"message": "Your request to update webhook url is successfully processed."
}
}
To verify the currently configured Webhook URL in your environment, please visit the https://docs.transak.com/reference/test-webhook page in the API Documentation.
If your Webhook has been configured correctly, you should see the following response:
{
"meta": {
"success": true,
"webhookURL": "https://webhook.site/eeadafbf-e654-40c8-af9e-35b5773fc463"
}
}
Step 3: Testing the configuration: After configuring, the default event is triggered and the responses look like:
The JSON data displayed in the Raw Content block is encrypted. We will use the jsonwebtoken package to decrypt this data.
- Performing a Sample Transaction: When performing a test transaction on the staging environment at https://global-stg.transak.com?apiKey=<YOUR_STAGING_API_KEY>, it is important to note that multiple events may be triggered. These events will be instantly displayed in the left side navigation of the screen.
In this scenario, upon the successful completion of a staging transaction, the following four events were triggered and successfully captured by the Webhook.
- Decrypting the Webhook Data: To decrypt the Webhook data, you can use the following code snippet in your Node.js environment. To execute this, run the command "node ./.js". This example uses only one package, which is jsonwebtoken.
import jwt from "jsonwebtoken";
const webhookData = "eyJhbGciOiJIUzI1NiJ9.eyJ3ZWJob29rRGF0YSI6eyJpZCI6ImUxOTNkNGQ0LTYzOWUtNDYwYS04YmFmLWQyN2Y0YjY4Yjg4MSIsIndhbGxldEFkZHJlc3MiOiIweEQ5MDJkN2V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lQW1vdW50Ijo1Ljc3LCJnYXNDdXJyZW5jeSI6IkVUSCIsImdhc0luTmF0aXZlVG9rZW4iOjAuMDAxNSwiZ2FzQ3VycmVuY3lSYXRlSW5Vc2QiOjAuMDAwMzIyODMxNjIwNzExNTg1NDcsInRvdGFsQW1vdW50Q2hhcmdlZEJ5VHJhbnNhayI6NS43NjU2ODI1MzkyODUwMDF9fSwicGFydG5lckZlZUluTG9jYWxDdXJyZW5jeSI6MS4wNiwic3RhdHVzSGlzdG9yaWVzIjpbXX0sImV2ZW50SUQiOiJPUkRFUl9DUkVBVEVEIiwiY3JlYXRlZEF0IjoiMjAyNC0wNS0wN1QxMTowOToyMi4wOTFaIn0.W07qJG6jlyzid-JrnY7G4CsUOqk8wtcvfrdygGzt5N4";
const accessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBUElfS0VZIjoiZDc5NjcxYTQtYjAyMS00YTRmLWE0NDQtNjg2MmE2ODBhOTRiIiwiaWF0IjoxNzE1MDgxMzI1LCJleHAiOjE3MTU2ODYxMjV9.NJw7DRIpYZnT2N5pLDkGzd1jybIim_1VWtu930xba7s";
const decodedData = jwt.verify(webhookData, accessToken);
console.log(decodedData);
The sample log after execution looks like:
{
webhookData: {
id: 'ecc5eeed-897e-4d72-9142-a8e75bb3d5ab',
walletAddress: '0xD902d7eBF7bc5eCa9EEA22a6Ee9F1A30EBeBEFeE',
createdAt: '2024-05-07T11:36:19.241Z',
status: 'COMPLETED',
fiatCurrency: 'GBP',
userId: '726d9144-dc97-451e-9b91-98ea4c140e5c',
cryptoCurrency: 'ETH',
isBuyOrSell: 'BUY',
fiatAmount: 55,
ipAddress: '35.177.158.9',
amountPaid: 55,
paymentOptionId: 'gbp_bank_transfer',
walletLink: 'https://sepolia.etherscan.io/address/0xD902d7eBF7bc5eCa9EEA22a6Ee9F1A30EBeBEFeE',
quoteId: '5cb7c46f-bede-49d1-a61c-01fe28cf3f60',
orderProcessingType: 'NORMAL',
addressAdditionalData: false,
network: 'ethereum',
conversionPrice: 0.0004031626016260162,
cryptoAmount: 0.0198356,
totalFeeInFiat: 5.8,
fiatAmountInUsd: 68.99,
countryCode: 'FR',
stateCode: 'France',
userKycType: 'STANDARD',
cardPaymentData: {
orderId: 'ecc5eeed-897e-4d72-9142-a8e75bb3d5ab',
paymentId: '663a1233920118f25d62d574',
pgData: [Object],
liquidityProvider: 'MODULR',
updatedAt: '2024-05-07T11:36:24.563Z',
status: 'CAPTURED',
processedOn: '2024-05-07T11:36:23.000Z'
},
statusHistories: [ [Object] ],
isFirstOrder: false,
updatedAt: '2024-05-07T11:36:34.605Z',
completedAt: '2024-05-07T11:36:40.917Z',
transactionHash: 'DUMMY_TX_ID',
transactionLink: 'https://sepolia.etherscan.io/tx/DUMMY_TX_ID',
conversionPriceData: {
_id: '39022614-a74e-4b20-90fe-1e40c0c9ba88',
id: '39022614-a74e-4b20-90fe-1e40c0c9ba88',
createdAt: '2024-05-07T11:36:34.581Z',
fiatCurrency: 'GBP',
cryptoCurrency: 'ETH',
paymentMethod: 'gbp_bank_transfer',
fiatAmount: 55,
network: 'ethereum',
cryptoAmount: 0.0198356,
isBuyOrSell: 'BUY',
conversionPrice: 0.00040316250225966543,
marketConversionPrice: 0.0004052291710319282,
slippage: 0.51,
cryptoLiquidityProvider: 'transak',
fiatLiquidityProvider: 'coinbase',
partnerApiKey: 'd79671a4-b021-4a4f-a444-6862a680a94b',
sourceTokenAmount: 0.019835595111175542,
sourceToken: 'ETH',
notes: [],
fiatFeeAmount: 5.8,
feeDecimal: 0.10545454545454545,
swaps: [Array],
fees: [Array],
fiatAmountInUsd: 68.99,
internalFees: [Array],
cost: [Object]
},
partnerFeeInLocalCurrency: 1.1
},
eventID: 'ORDER_COMPLETED',
createdAt: '2024-05-07T11:36:41.534Z'
}
Updated about 2 months ago