Last active
April 30, 2020 04:52
-
-
Save spivurno/9ca370335583b94a804454d6cdb88fdb to your computer and use it in GitHub Desktop.
Gravity Perks // GP Unique ID // Add Wait-for-payment Support for 3rd-party Payment Gateways
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Do I create this PHP file within the GP Unique ID folder on my server? Basically I'm needing to know where does this code go? I put it into my functions.php so I'll see how it goes. However, if it's in the wrong place, again, let me know.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this code actually work, or is this rather a draft? How should I redirect to a third party payment gateway and - in return - from a configured callback script back to the form in Wordpress?