|
public function process_payment_form() { |
|
if(isset($_POST['mepr_process_payment_form']) && isset($_POST['mepr_transaction_id']) && is_numeric($_POST['mepr_transaction_id'])) { |
|
$txn = new MeprTransaction($_POST['mepr_transaction_id']); |
|
|
|
if($txn->rec != false) { |
|
$mepr_options = MeprOptions::fetch(); |
|
if(($pm = $mepr_options->payment_method($txn->gateway)) && $pm instanceof MeprBaseRealGateway) { |
|
$errors = $pm->validate_payment_form(array()); |
|
|
|
if(empty($errors)) { |
|
// process_payment_form either returns true |
|
// for success or an array of $errors on failure |
|
try { |
|
$pm->process_payment_form($txn); |
|
} |
|
catch(Exception $e) { |
|
MeprHooks::do_action('mepr_payment_failure', $txn); |
|
$errors = array($e->getMessage()); |
|
} |
|
} |
|
|
|
if(empty($errors)) { |
|
//Reload the txn now that it should have a proper trans_num set |
|
$txn = new MeprTransaction($txn->id); |
|
$product = new MeprProduct($txn->product_id); |
|
$sanitized_title = sanitize_title($product->post_title); |
|
$query_params = array('membership' => $sanitized_title, 'trans_num' => $txn->trans_num, 'membership_id' => $product->ID); |
|
if($txn->subscription_id > 0) { |
|
$sub = $txn->subscription(); |
|
$query_params = array_merge($query_params, array('subscr_id' => $sub->subscr_id)); |
|
} |
|
MeprUtils::wp_redirect($mepr_options->thankyou_page_url(build_query($query_params))); |
|
} |
|
else { |
|
// Artificially set the payment method params so we can use them downstream |
|
// when display_payment_form is called in the 'the_content' action. |
|
$_REQUEST['payment_method_params'] = array( |
|
'method' => $pm->id, |
|
'amount' => $txn->amount, |
|
'user' => new MeprUser($txn->user_id), |
|
'product_id' => $txn->product_id, |
|
'transaction_id' => $txn->id |
|
); |
|
$_REQUEST['mepr_payment_method'] = $pm->id; |
|
$_POST['errors'] = $errors; |
|
return; |
|
} |
|
} |
|
} |
|
} |
|
|
|
$_POST['errors'] = array(__('Sorry, an unknown error occurred.', 'memberpress')); |
|
} |
The exceptions/errors from gateways are stored in
$_POST['errors']:memberpress/app/controllers/MeprCheckoutCtrl.php
Lines 652 to 704 in e07be7e
Only errors in
$_REQUEST['errors']are displayed:memberpress/app/controllers/MeprCheckoutCtrl.php
Lines 568 to 585 in e07be7e
I did notice some 'Deprecated?' comments:
memberpress/app/controllers/MeprCheckoutCtrl.php
Lines 278 to 279 in e07be7e
memberpress/app/controllers/MeprCheckoutCtrl.php
Lines 321 to 325 in e07be7e
Sigh, MemberPress... 😞