Gravity Perks // GP Unique ID // Add Wait-for-payment Support for 3rd-party Payment Gateways
<?php
/**
* Gravity Perks // GP Unique ID // Add Wait-for-payment Support for 3rd-party Payment Gateways
* http://gravitywiz.com/documentation/gp-unique-id/
*/
// 1 - Indicate that waiting for payments is enabled.
add_filter( 'gpui_wait_for_payment', '__return_true' );
// 2 - Fetch the applicable payment feed for your gateway.
add_filter( 'gpui_wait_for_payment_feed', function( $feed, $form, $entry ) {
// Replace the get_my_payment_feed_func() with your own functionality for fetching your payment feed.
$feed = get_my_payment_feed_func();
return $feed;
}, 10, 3 );
// 3 - Call populate_field_value() with the $fulfilled flag set to true when the payment is completed.
// This example is how it works with the Gravity Forms PayPal add-on. When the payment is fulfilled,
// PayPal triggers the gform_paypal_fulfillment action. We bind to that action and call the
// populate_field_value() method to populate the unique ID when the payment is fulfilled.
add_action( 'gform_paypal_fulfillment', function( $entry ) {
$form = GFAPI::get_form( $entry['form_id'] );
gp_unique_id_field()->populate_field_value( $entry, $form, true );
}, 9 );