๐ก What are the webhooks?
Webhooks are a powerful way to receive real-time notifications from our API about specific events. When certain events occur, such as a payment transaction, our system will send an HTTP POST request to a URL you've provided, allowing you to react to the event in your application. Let's dive into the webhook payload structure:
Request Headers
When setting up your webhook endpoint, make sure to handle incoming HTTP POST
requests and consider including the following headers to handle the payload correctly:
Content-Type: application/json
- Indicates that the request payload is in JSON format.
Request Body Example
{
"PaymentId": "E066159D6D3C416D9F3490258EBC73F4",
"Type": "JustPay",
"Sandbox": false,
"PaymentStatus": "Draft",
"Amount": 0.03,
"FinalAmount": null,
"Currency": "GEL",
"Commission": 2.50,
"Preauthorized": false,
"CanBeCaptured": false,
"CreateDate": 638155893040924688,
"CaptureDate": null,
"BlockDate": null,
"CardMask": null,
"CardBrand": null,
"CardCountry": null,
"CardHolder": null,
"ExpirationDate": null,
"RejectionReason": null,
"Refund": {
"Refundable": false,
"Amount": null,
"RequestedAmount": null,
"RefundDate": null,
"Revisions": []
},
"Splits": [
{
"Amount": 0.01,
"Iban": "GE33TB0000000000000000",
"PayIn": 0.0,
"Status": null,
"Description": null,
"CashOutOrder": []
}
]
}
Parsing Payment Statuses
You can parse the PaymentStatus field to determine the status of the payment transaction. Here are the possible payment statuses:
Transaction Status | Description |
---|---|
Draft | When the transaction is created and waiting for card details for the next action. |
Blocked | The funds have been successfully blocked on the card. Usually, this means you have used preauthorize: True Transactions with Blocked statuses need to be committed within 30 days, otherwise, they will be refunded automatically. |
Captured | The funds have been captured successfully from the cardholder. |
Refunded | The transaction has been refunded fully. |
PartiallyRefunded | The transaction amount has been refunded partially. |
Rejected | The transaction was rejected, because of different reasons. |
Example: Parsing Payment Statuses in Python
import json
# Sample JSON response
response_json = '{"data": {"PaymentStatus": "Draft", ...}, "status": {"message": null, "errors": null, "type": null}}'
response_dict = json.loads(response_json)
payment_status = response_dict['data']['PaymentStatus']
if payment_status == 'Draft':
print("Transaction is in draft status, awaiting card details.")
elif payment_status == 'Blocked':
print("Funds have been blocked on the card, ready for capture.")
# ... similar checks for other payment statuses