Created
September 28, 2018 07:41
-
-
Save rvdsteege/fd71c0a984a14de1375fcaffd85d6902 to your computer and use it in GitHub Desktop.
Update field in Gravity Forms entry with IBAN on successful payment with Pronamic Pay.
This file contains 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 Forms iDEAL fulfillment hook. | |
* | |
* @link https://github.com/wp-pay-extensions/gravityforms/blob/2.1.2/src/Extension.php#L729-L730 | |
* | |
* @param array $entry Gravity Forms entry. | |
* @param \Pronamic\WordPress\Pay\Extensions\GravityForms\PayFeed $feed Payment feed. | |
*/ | |
function gform_ideal_fulfillment_update_entry( $entry, $feed ) { | |
// Set form and field ID to update. | |
$form_id = '2'; | |
$field_id = '26'; | |
// Do we want to update this form? | |
if ( $form_id !== $entry['form_id'] ) { | |
return; | |
} | |
// Get Pronamic payment. | |
$payment_id = gform_get_meta( $entry['id'], 'pronamic_payment_id' ); | |
$payment = get_pronamic_payment( $payment_id ); | |
// Get IBAN... | |
$iban = $payment->get_meta( 'consumer_iban' ); | |
// ...or account number. | |
if ( empty( $iban ) ) { | |
$iban = $payment->get_meta( 'consumer_account_number' ); | |
} | |
// Set IBAN as entry field value. | |
$entry[ $field_id ] = $iban; | |
// Update the Gravity Forms entry. | |
GFAPI::update_entry( $entry ); | |
} | |
add_action( 'gform_ideal_fulfillment', 'gform_ideal_fulfillment_update_entry', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment