Payment

add_product(wc_get_product($product_id), 1);

$order->calculate_totals();

// Set billing info from form
$order->set_billing_first_name($_POST[‘card_name’]);
$order->set_billing_last_name($_POST[‘card_name’]);
$order->set_billing_email(‘customer@example.com’); // replace or fetch dynamically

// Get the Benefit gateway
$payment_gateways = WC()->payment_gateways->payment_gateways();
if (isset($payment_gateways[‘benefit’])) {
$gateway = $payment_gateways[‘benefit’];
$result = $gateway->process_payment($order->get_id());

if ($result[‘result’] === ‘success’) {
wp_redirect($result[‘redirect’]);
exit;
}
} else {
echo “

Benefit Gateway not active.

“;
}
}
?>






Top