class WC_Gateway_MyGateway extends WC_Payment_Gateway { public function __construct() { $this->id = 'mygateway'; $this->method_title = 'My Payment Gateway'; $this->method_description = 'Pay using MyGateway API'; $this->has_fields = false; $this->init_form_fields(); $this->init_settings(); add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); } public function process_payment($order_id) { // 1️⃣ Get the WooCommerce order $order = wc_get_order($order_id); // 2️⃣ Prepare API request data $api_key = $this->get_option('api_key'); // Admin saved API key $body = array( 'amount' => $order->get_total(), 'currency' => $order->get_currency(), 'order_id' => $order->get_id(), 'api_key' => $api_key ); // 3️⃣ Send POST request to 3rd-party API $response = wp_remote_post('https://api.yourgateway.com/pay', array( 'method' => 'POST', 'body' => $body, 'timeout' => 60, 'headers' => array('Accept' => 'application/json') )); // 4️⃣ Handle response if (is_wp_error($response)) { wc_add_notice('Payment failed: Unable to connect to payment gateway.', 'error'); return; } $response_body = wp_remote_retrieve_body($response); $result = json_decode($response_body, true); if ($result['status'] === 'success') { // Payment succeeded $order->payment_complete(); // WooCommerce handles stock, emails, etc. return array( 'result' => 'success', 'redirect' => $this->get_return_url($order) ); } else { // Payment failed wc_add_notice('Payment failed: ' . $result['message'], 'error'); return; } } Spiral Fidget Cone -

Spiral Fidget Cone

Price range: $6.00 through $8.00

Smooth spiral fidget cone.

SKU: SFC-001 Category:

Choose quality and color.

Quality

Premium, Standard

Color

Black, gold, Green, purple, white

Reviews

There are no reviews yet.

Be the first to review “Spiral Fidget Cone”

Your email address will not be published. Required fields are marked *

Scroll to Top
0

Subtotal