Black Friday
Super Deal
bit form 74% Off
Offer ends in:
00

days day

00

hours hour

00

Mins Min

00

Secs Sec

Estimated reading: 2 minutes 261 views

Setup Custom Payment Webhook in Bit Form

Learn how to configure a custom payment webhook in Bit Form to optimize payment processing. Enhance your form functionality with custom webhook integration for payment solutions.

To setup a custom payment webhook, follow these instructions:

In your payment gateway account, configure the webhook URL to the following:

https://www.yourdomain.com/index.php?rest_route=/bitform/v1/payments/custom_payment

Once a payment is successfully processed, the payment gateway will send the payment details to the specified webhook URL in JSON format. The webhook will then process these details and update the payment status in your database.

Important Notes:

  1. Metadata Requirement:
    When creating a payment, ensure that the following metadata fields are included:
    • formID
    • entryID
    • fieldKey

This metadata is necessary for identifying and processing the payment properly.

  1. Payment Details:
    After processing, the webhook will return all payment details along with the provided metadata. You can use this information to update the payment status in your database.
  1. Action Hook:
    Use the following action hook to handle successful payment transactions and update the database accordingly:
do_action('bitform_custom_payment_transaction_success', $data);

Registering a Hook

You can register your custom function to handle the transaction success by using:

add_action('bitform_custom_payment_transaction_success', 'payment_transaction_success_func', 10, 1);

Saving Payment Details

To save payment details in the database, include the following method inside this webhook:

(new CustomPayment())->savePaymentInfo();

Example Implementation

Here is an example implementation for handling payment success and saving details:

use BitCode\BitFormPro\API\CustomPayment;
add_action('bitform_custom_payment_transaction_success', 'payment_transaction_success_func', 10, 1);
function payment_transaction_success_func($data) {
// This $data might be an object or array and it’s comes from payment hook response, formId, entryId, fieldKey maybe exists in metadata property.
$formId = $data->metadata->formId;
$entryId = $data->metadata->entryId;
$fieldKey = $data->metadata->fieldKey;
$paymentType = $data->paymentType;
$transactionId = $data->transactionId;
$paymentStringData = json_encode($data);

if(class_exists('BitCode\BitFormPro\API\CustomPayment')) {
(new \BitCode\BitFormPro\API\CustomPayment())->savePaymentInfo($formId, $entryId, $fieldKey, $paymentType, $transactionId, $paymentStringData);
 }
}

Share this Doc

Setup Custom Payment Webhook

Or copy link

CONTENTS