Created
March 19, 2021 15:00
-
-
Save rvdsteege/43af84ecd99cc3202be76281c23f0793 to your computer and use it in GitHub Desktop.
Update MemberPress transaction number with Pronamic Pay transaction ID
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 | |
/** | |
* Update MemberPress transaction number. | |
* | |
* @param \Pronamic\WordPress\Pay\Payments\Payment $payment Payment. | |
* @retun void | |
*/ | |
function update_mepr_transaction_number( $payment ) { | |
// Check payment source. | |
if ( 'memberpress' !== $payment->get_source() ) { | |
return; | |
} | |
// Check transaction ID. | |
$transaction_id = $payment->get_transaction_id(); | |
if ( empty( $transaction_id ) ) { | |
return; | |
} | |
$mp_transaction = new \MeprTransaction( $payment->get_source_id() ); | |
// Check if update is required. | |
if ( $mp_transaction->trans_num === $transaction_id ) { | |
return; | |
} | |
$mp_transaction->trans_num = $transaction_id; | |
$mp_transaction->store(); | |
} | |
\add_action( 'pronamic_pay_update_payment', 'update_mepr_transaction_number' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment