/**
* Process the payment.
*
* @param int $order_id
*/
public function process_payment($order_id)
{
$order = wc_get_order($order_id);
// Payment/CC form is hosted on Simplify
if ('hosted' === $this->mode) {
return $this->process_hosted_payments($order);
}
// New CC info was entered
if (isset($_POST['simplify_token'])) {
$cart_token = wc_clean($_POST['simplify_token']);
$customer_token = $this->get_users_token();
$customer_token_value = !is_null($customer_token) ? $customer_token->get_token() : '';
$this->process_customer($order, $customer_token, $cart_token);
return $this->process_standard_payments($order, $cart_token, $customer_token_value);
}
// Possibly Create (or update) customer/save payment token, use an existing token, and then process the payment
if (isset($_POST['wc-simplify_commerce-payment-token']) && 'new' !== $_POST['wc-simplify_commerce-payment-token']) {
$token_id = wc_clean($_POST['wc-simplify_commerce-payment-token']);
$token = WC_Payment_Tokens::get($token_id);
if ($token->get_user_id() !== get_current_user_id()) {
wc_add_notice(__('Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce'), 'error');
return;
}
$this->process_customer($order, $token);
return $this->process_standard_payments($order, '', $token->get_token());
}
}