dauds
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorHello,
Please this issue it seems WooCommerce issue. So can you help me please
Thanks
Forum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorHello ,
The actual error is happening on the below :
wp-content/plugins/woocommerce/assets/js/frontend/checkout.min.js?ver=6.6.1
May this error ben the cause of undefined
Please see the Image for more clarity
Forum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorForum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorHi @rynald0s,
Please see below the code of bank.
<?php /** * Custome Pay Mobile Payments Gateway. * * Provides a Custome Pay Mobile Payments Payment Gateway. * * @class WC_Gateway * @extends WC_Payment_Gateway * @version 2.1.0 * @package WooCommerce/Classes/Payment */ class WC_Gateway_Custome Pay extends WC_Payment_Gateway { /** * Constructor for the gateway. */ public function __construct() { // Setup general properties. $this->setup_properties(); // Load the settings. $this->init_form_fields(); $this->init_settings(); // Get settings. $this->title ='Custome Pay'; $this->description = $this->get_option( 'description' ); $this->api_key = $this->get_option( 'api_key' ); $this->widget_id = $this->get_option( 'widget_id' ); $this->instructions = $this->get_option( 'instructions' ); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); // add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) ); add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'change_payment_complete_order_status' ), 10, 3 ); // Customer Emails. add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); } /** * Setup general properties for the gateway. */ protected function setup_properties() { $this->id = 'Custome Pay'; $this->icon = ''; // $this->method_title = 'Custome Pay'; $this->api_key = __( 'Add API Key', 'Custome Pay-pay' ); $this->widget_id = __( 'Add Widget ID', 'Custome Pay-pay' ); $this->method_description = 'Custome Pay Payments Gateway'; $this->has_fields = false; } /** * Initialise Gateway Settings Form Fields. */ public function init_form_fields() { $this->form_fields = array( 'enabled' => array( 'title' => __( 'Enable/Disable', 'Custome Pay-pay' ), 'label' => __( 'Enable Custome Pay Mobile Payments', 'Custome Pay-pay' ), 'type' => 'checkbox', 'description' => '', 'default' => 'no', ), 'title' => array( 'title' => 'Title', 'type' => 'text', 'description' => 'Custome Pay Mobile Payment method description that the customer will see on your checkout.', 'default' => 'Mobile Payment', 'desc_tip' => true, ), 'description' => array( 'title' =>'Description', 'type' => 'textarea', 'description' => 'Custome Pay Mobile Payment method description that the customer will see on your website.', 'default' => 'Custome Pay Mobile Payments before delivery.', 'desc_tip' => true, ), 'instructions' => array( 'title' => __( 'Instructions', 'Custome Pay' ), 'type' => 'textarea', 'description' => __( 'Instructions that will be added to the thank you page.', 'payleo-payments-woo' ), 'default' => __( 'Custome Pay Mobile Payments before delivery.', 'Custome Pay-payments-woo' ), 'desc_tip' => true, ), 'testmode' => array( 'title' => 'Test mode', 'label' => 'Enable Test Mode', 'type' => 'checkbox', 'description' => 'Place the payment gateway in test mode using test API Credencial.', 'default' => 'yes', 'desc_tip' => true, ), 'test_user_name' => array( 'title' => 'Test User Name', 'type' => 'text' ), 'test_password' => array( 'title' => 'Test Password', 'type' => 'text' ), 'test_merchant_id' => array( 'title' => 'Test Merchant ID', 'type' => 'text', ), 'prod_user_name' => array( 'title' => 'Live User name', 'type' => 'text' ), 'prod_password' => array( 'title' => 'Live Password', 'type' => 'text' ), 'prod_merchant_id' => array( 'title' => 'Live Merchant ID', 'type' => 'text', ) ); } /** * Checks to see whether or not the admin settings are being accessed by the current request. * * @return bool */ private function is_accessing_settings() { if ( is_admin() ) { // phpcs:disable WordPress.Security.NonceVerification if ( ! isset( $_REQUEST['page'] ) || 'wc-settings' !== $_REQUEST['page'] ) { return false; } if ( ! isset( $_REQUEST['tab'] ) || 'checkout' !== $_REQUEST['tab'] ) { return false; } if ( ! isset( $_REQUEST['section'] ) || 'Custome Pay' !== $_REQUEST['section'] ) { return false; } // phpcs:enable WordPress.Security.NonceVerification return true; } return false; } /** * Process the payment and return the result. * * @param int $order_id Order ID. * @return array */ public function process_payment( $order_id ) { $order = wc_get_order( $order_id ); if ( $order->get_total() > 0 ) { $this->Custome Pay_payment_processing( $order ); } } private function Custome Pay_payment_processing( $order ) { $total = intval( $order->get_total() ); var_dump($total); $username ="xxxxx"; $password ="xxxxx"; $data = array(); $curl = curl_init(); $authorization = base64_encode($username.':'.$password); curl_setopt_array($curl, array( CURLOPT_URL => "https://xxxxxxxxxx", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_HTTPHEADER => array( "Content-Type: application/json", "Content-Length: 0", "MachineID: xxxxxxx", "ChannelID: 104", "DeviceType: 205", "Authorization: Basic $authorization" ), )); $response = curl_exec($curl); //json decode $character = json_decode($response); global $token; $token= $character->Data->Token; $api_status1 = json_decode($response); $code1=$api_status1->Response->Code; $message1 =$api_status1->Response->Messages; if($code1=="001"){ $status= $this->pushPayment($token); $decode =json_decode($status); $code=$decode->Response->Code; if($code=="001"){ // var_dump ($code); $order->payment_complete(); // Remove cart. WC()->cart->empty_cart(); // Return thankyou redirect. return array( 'result' => 'success', 'redirect' => $this->get_return_url( $order ), ); } else{ $order->update_status( apply_filters( 'woocommerce_Custome Pay_process_payment_order_status', $order->has_downloadable_item() ? 'wc-invoiced' : 'processing', $order ), __( 'Payments pending.', 'Custome Pay-pay' ) ); } }else{ $data = array('status' => false, 'Message' => 'Invalid User or Password.'); echo json_encode($data); } curl_close($curl); // $this->MerchantLogin(); // $phone = esc_attr( $_POST['payment_number'] ); // $network_id = '1'; // mtn // $reason = 'Test'; function pushPayment($token){ $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://xxxxxxx', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "Phone Number":"xxxxxxx", "Amount":"1", "Remarks":"xxx", "Category":"1", "LoginUserName":"xxxxx" } ', CURLOPT_HTTPHEADER => array( "MachineID: xxxxxxx", "ChannelID: 104", "DeviceType: 205", "Content-Type: application/json", "Authorization: Bearer $token" ), )); $json_response = curl_exec($curl); curl_close($curl); return $json_response; } /** * Output for the order received page. */ public function thankyou_page() { if ( $this->instructions ) { echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); } } /** * Change payment complete order status to completed for Custome Pay orders. * * @since 3.1.0 * @param string $status Current order status. * @param int $order_id Order ID. * @param WC_Order|false $order Order object. * @return string */ public function change_payment_complete_order_status( $status, $order_id = 0, $order = false ) { if ( $order && 'Custome Pay' === $order->get_payment_method() ) { $status = 'completed'; } return $status; } /** * Add content to the WC emails. * * @param WC_Order $order Order object. * @param bool $sent_to_admin Sent to admin. * @param bool $plain_text Email format: plain text or HTML. */ public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { if ( $this->instructions && ! $sent_to_admin && $this->id === $order->get_payment_method() ) { echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); } } }Thank you
Forum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorHI @conschneider,
I HAVE TESTED THIS OPTION BUT COULKD NOT SEE ANY CHANGES,
for your information , i am using custom payment.
Thank you
Forum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorHi @rynald0s,
I have made the changes but the error seams to be the same without any changes.
Thank you
Forum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorHi @rynald0s,
Please see the screenshot of WooCommerce > Setting > Advance
The permalinks : https://ibb.co/Qj4qmx0
Thank you for your support
Forum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorHi @solstudioim,
I hope you are doing well,
Thank you for your support , I have follow the steps you have suggested but still facing the same error
screenshot of the error : https://ibb.co/BZ5j8rr
Forum: Plugins
In reply to: [WooCommerce] Thank You page redirect errorHi @rynald0s,
Thank you for quick response, We are receiving successful response when calling the API, the amount is deducted. the order is completed but failing to redirect the page to thank you page.
Please find the screenshot below.
redirect code is the following.
`$status= $this->processPayment($token);
$decode =json_decode($status);
$code=$decode->Response->Code;
if($code==”001″){
// var_dump ($code);
$order->payment_complete();
// Remove cart.
WC()->cart->empty_cart();
// Return thankyou redirect.
return array(
‘result’ => ‘success’,
‘redirect’ => $this->get_return_url( $order ),
);
}- This reply was modified 3 years, 10 months ago by dauds.