โฐWebhook notifications
This section covers server-to-server communication that happens in case of some events
General information
If you are interested in receiving webhook notifications, please provide your webhook endpoint URL to integrations@thegivingblock.com.
As a user of the TGB API, you can subscribe to some events that happen during the donation process. TGB has implemented event notifications as HTTP Webhooks.
Security Measures:
payload
field is AES encryptedall eventsโ payloads will contain
eventTimestamp
field, so consumer may implement timestamp check, i.e. to not accept if message is older than 1 hour and/or emit an security alert in this case
Below you can find information about different types of webhooks TGB sends to subscribers.
Event: Deposit completed
When the deposit transaction is completed, The Giving Block will detect that and this notification will be sent as HTTP POST request to your notifications URL if enabled for your API user.
POST Body example:
Note: that โpayloadโ will be passed to you in encrypted way. POST Body of the webhook will look like
Explanation on some notification fields:
pledgeId is an unique identifier of a pledge. You can use this id to match the donation address you received on CreateDepositAddress API call valueAtDonationTimeUSD is a USD equivalent of transaction's amount at the time of donation. Please note that this amount is before any fees are withdrawn and should not be used for any calculation. This is primarily used for nonprofits who are HODLing and not immediately converting. This means that organizations can get approximate donation amount, in case autoconversion is disabled for the organization. paymentMethod - Enum (Crypto,Card,Stock) transactionHash is transaction hash or ID on the blockchain payoutAmount is an amount in currency returned as payoutCurrency that the nonprofit will receive as their final balance (gross donation amount - total fees). For crypto donations the amount will be provided once transaction is converted. payoutCurrency the currency for payoutAmount. externalId the nonprofit ID (optional) that was passed as a parameter while retrieving Widget URL (see "Widget URL" API reference for more details). campaignId is the ID of the campaign for which the donation was made, in case it wasn't set then null is returned.
Event: Transaction converted (only crypto)
When the transaction is converted, The Giving Block will detect that and this notification will be sent as HTTP POST request to your notifications URL if enabled for your API user.
POST Body example:
Note: โpayloadโ will be passed to you in encrypted way. POST Body of the webhook will look like
Explanation on some fields:
netValueAmount is an amount in currency returned as netValueCurrency that the nonprofit will receive as their final balance (gross donation amount - total fees).
grossAmount is an amount that is calculated during conversion of donated crypto.
valueAtDonationTimeUSD is a USD equivalent of transaction's amount at the time of donation. Please note that this amount is before any fees are withdrawn and should not be used for any calculation. This is primarily used for nonprofits who are HODLing and not immediately converting. This means that organizations can get approximate donation amount, in case autoconversion is disabled for the organization. payoutAmount is an amount in currency returned as payoutCurrency that the nonprofit will receive as their final balance (gross donation amount - total fees). payoutCurrency the currency for payoutAmount. externalId the nonprofit ID (optional) that was specified as a parameter while retrieving Widget URL (see "Widget URL" API reference for more details). campaignId is the ID of the campaign for which the donation was made, in case it wasn't set then null is returned.
Example:
A donor made a donation of 1 BTC, when the BTCUSD exchange rate is 50,000 USD.
The donation amount equals 1 BTC
valueAtDonationTimeUSD is 50,000 USD (amount * BTCUSD rate)
For example, TGB converts the donation with average exchange rate of 50,000 USD per 1 BTC.
Before the conversion happens, all fees are withdrawn. In this example, there is a 2% fee applied so the amount to convert to USD is 0.98 BTC (1 BTC - total fees).
Therefore, netValueAmount will be calculated by taking 0.98 BTC * 50,000 USD = 49,000 USD
So at the end of donation processing, the nonprofit organization will have 49,000 USD as their balance which will then be transferred to their bank account.
Event: Merchant status events
After onboarding a merchant to receive credit card donations, all the onboarding data will be reviewed by underwriting team. Any merchant status update will be sent as a HTTP POST request to your notification URL if enabled for your API user.
POST body example:
Note: that โpayloadโ will be passed to you in encrypted way. POST Body of the webhook will look like
Explanation of fields:
timestamp is time of the event in milliseconds eventType is ebent type (will always be MERCHANT_STATUS_EVENT) mid is Merchant ID status is merchant status statusChangeReason is brief description officeId is Office ID
Possible merchant statuses:
Status # | Status name |
---|---|
125 | RESUBMITTED APPLICATION |
200 | DECLINED |
300 | CLOSED - MERCHANT CANCELLED |
325 | CLOSED - TERMINATION |
330 | SEASONAL BUSINESS |
350 | GATEWAY / ACCESSORY SERVICE ONLY |
375 | AWAITING ISO ACTIVATION OF UNDERWRITING |
390 | ORIG. APP RECEIVED - IN UNDERWRITING |
400 | IN UNDERWRITING |
425 | ON PRIMARY HOLD - NEED ADDITIONAL INFORMATION |
500 | APPROVED - IN DATA ENTRY FOR MID BUILD |
550 | APPROVED - AWAITING FAXED DOCUMENTATION |
600 | APPROVED |
650 | APPROVED - INSTALLED |
675 | MERCHANT REQUESTING TO CANCEL |
700 | APPROVED - PROCESSING |
730 | APPROVED - SEASONAL HOLD |
785 | LEGAL REVIEW |
Payload decryption
To decrypt the payload you need a pair of "encryption key" and "iv" shared with you during your API credentials creation.
You can find some code snippets below. Given:
Decryption code snippet:
Last updated