Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvdsteege/43af84ecd99cc3202be76281c23f0793 to your computer and use it in GitHub Desktop.
Save rvdsteege/43af84ecd99cc3202be76281c23f0793 to your computer and use it in GitHub Desktop.
Update MemberPress transaction number with Pronamic Pay transaction ID
<?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