• Resolved alekssos

    (@alekssos)


    Hi, I am trying to get this working and I am stuck at White screen after i get the gateway call back.
    The page that is called back has orderId = 0.

    In logs I get:
    08-22-2018 @ 13:58:37 – Processing payment for order_id=8455
    08-22-2018 @ 13:58:37 – POST-ing to Bankart: responseURL=https://www.mydomain/wp/wc-api/bankart_callback, amt=53.40, action=4, trackid=8455 …
    08-22-2018 @ 14:01:37 – Received POST request from gateway: Array
    (
    [paymentid] => 3566419581382340
    [result] => APPROVED
    [auth] => VB1653
    [ref] => 823414626816
    [tranid] => 8936089011482340
    [postdate] => 0822
    [trackid] => 8455
    [responsecode] => 00
    [cvv2response] => Y
    [eci] => 7
    )

    08-22-2018 @ 14:01:37 – Customer redirect URL: https://www.mydomain/wp/wc-api/bankart_customer_redirect
    08-22-2018 @ 14:01:38 – Invalid GET request: Array
    (
    [orderId] => 0
    [paymentId] => 3566419581382340
    )

    I would appreciate if I can get any help with that.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author geca

    (@geca)

    Hi, for starters please execute the following select on your DB (via phpMyAdmin for example) and let me know what you get.

    select * from wp_postmeta where meta_key = 'bankart-payment-id'

    Thread Starter alekssos

    (@alekssos)

    Hi,

    I get all meta data of my last 5 tries to do process:
    meta_id,post_id,meta_key, meta_value

    Plugin Author geca

    (@geca)

    Ok. What is the “post_id” for the record with “meta_value” = 3566419581382340 ?

    Thread Starter alekssos

    (@alekssos)

    its: 8455

    Plugin Author geca

    (@geca)

    What I’m trying to figure out is why you don’t get a valid WC_Order here:

    
    $args = array(
        'meta_query' => array(
            array(
                'key' => 'bankart-payment-id',
                'value' => $payment_id,
                'compare' => '=',
            )
        ),
        'post_type' => 'shop_order',
    );
    $posts_found = get_posts($args);
    $order = new WC_Order($posts_found[0]);
    

    Can you replace the code above with this one and let me know what gets logged?

    
    $args = array(
        'meta_query' => array(
            array(
                'key' => 'bankart-payment-id',
                'value' => $payment_id,
                'compare' => '=',
            )
        ),
        'post_type' => 'shop_order',
    );
    
    $this->log("args: " . print_r($args, true)); // This line is new.
    $posts_found = get_posts($args);
    $this->log("posts_found: " . print_r($posts_found, true)); // This line is new.
    $order = new WC_Order($posts_found[0]);
    

    Plus, what “post_type” is the post with ID=8455?

    Edit: additional logging.

    Thread Starter alekssos

    (@alekssos)

    call back i get is : https://mydomain/wp/wc-api/bankart_customer_redirect?orderId=0&paymentId=6261424011682340

    I dont really know where to check for post type.
    New order log:

    08-22-2018 @ 16:01:38 - Processing payment for order_id=8456
    08-22-2018 @ 16:01:38 - POST-ing to Bankart: responseURL=https://mydomain/wp/wc-api/bankart_callback, amt=53.40, action=4, trackid=8456 ...
    08-22-2018 @ 16:01:46 - Received POST request from gateway: Array
    (
        [paymentid] => 6261424011682340
        [result] => APPROVED
        [auth] => VB4843
        [ref] => 823416897839
        [tranid] => 3800304011682340
        [postdate] => 0822
        [trackid] => 8456
        [responsecode] => 00
        [cvv2response] => Y
        [eci] => 7
    )
    
    08-22-2018 @ 16:01:46 - args: Array
    (
        [meta_query] => Array
            (
                [0] => Array
                    (
                        [key] => bankart-payment-id
                        [value] => 6261424011682340
                        [compare] => =
                    )
    
            )
    
        [post_type] => shop_order
    )
    
    08-22-2018 @ 16:01:46 - posts_found: Array
    (
    )
    
    08-22-2018 @ 16:01:46 - Customer redirect URL: https://mydomain/wp/wc-api/bankart_customer_redirect
    08-22-2018 @ 16:01:47 - Invalid GET request: Array
    (
        [orderId] => 0
        [paymentId] => 6261424011682340
    )
    • This reply was modified 6 years, 6 months ago by alekssos.
    Plugin Author geca

    (@geca)

    Thanks for the log output. Here’s how to check post type:

    select post_type from wp_posts where id = 8455

    Let me know what you get.

    Edit: Actually, give me all the data you get for this post:

    select * from wp_posts where id = 8455

    Thread Starter alekssos

    (@alekssos)

    Results I get:

    "ID";"post_author";"post_date";"post_date_gmt";"post_content";"post_title";"post_excerpt";"post_status";"comment_status";"ping_status";"post_password";"post_name";"to_ping";"pinged";"post_modified";"post_modified_gmt";"post_content_filtered";"post_parent";"guid";"menu_order";"post_type";"post_mime_type";"comment_count"
    "8455";"1";"2018-08-22 13:58:36";"2018-08-22 11:58:36";;"Order – avgust 22, 2018 @ 01:58 pop";;"wc-cancelled";"closed";"closed";"order_5b7d4fecc1862";"narocilo-aug-22-2018-1158-am";;;"2018-08-22 15:32:07";"2018-08-22 13:32:07";;"0";"https://mydomain/wp/?post_type=shop_order&p=8455";"0";"shop_order";;"1"
    
    Plugin Author geca

    (@geca)

    Sorry for a bit of delay. Try replacing this code

     
    $args = array(
        'meta_query' => array(
            array(
                'key' => 'bankart-payment-id',
                'value' => $payment_id,
                'compare' => '=',
            )
        ),
        'post_type' => 'shop_order',
    );
    $posts_found = get_posts($args);
    $order = new WC_Order($posts_found[0]);
    

    with this

    
    $query_string = "
        SELECT post_id
        FROM $wpdb->postmeta 
        WHERE meta_value = '$payment_id' and meta_key = 'bankart-payment-id'
    ";
    
    $query_result = $wpdb->get_row($query_string, OBJECT);            
    $order = wc_get_order($query_result->post_id);
    

    In addition to that, replace this code

    
    printf('REDIRECT=%s?orderId=%s&paymentId=%s', $customer_redirect_url, $order->id, $payment_id);
    

    with

    
    printf('REDIRECT=%s?orderId=%s&paymentId=%s', $customer_redirect_url, $order->get_id(), $payment_id);
    

    and let me know if you still get the WSOD.

    • This reply was modified 6 years, 6 months ago by geca.
    Thread Starter alekssos

    (@alekssos)

    It still gives WSOD. The log i get is:

    08-27-2018 @ 09:04:13 - Processing payment for order_id=8487
    08-27-2018 @ 09:04:13 - POST-ing to Bankart: responseURL=https://www.mydomain/wp/wc-api/bankart_callback, amt=53.40, action=4, trackid=8487 ...
    08-27-2018 @ 09:04:21 - Received POST request from gateway: Array
    (
        [paymentid] => 1388327040982390
        [result] => APPROVED
        [auth] => VB8036
        [ref] => 823909663513
        [tranid] => 1547067040982390
        [postdate] => 0827
        [trackid] => 8487
        [responsecode] => 00
        [cvv2response] => Y
        [eci] => 7
    )
    
    08-27-2018 @ 09:04:22 - Received POST request from gateway: 
    08-27-2018 @ 09:04:22 - payment_id is missing, exiting.
    08-27-2018 @ 09:08:32 - Received POST request from gateway: 
    08-27-2018 @ 09:08:32 - payment_id is missing, exiting.

    The link i get as call back, is lacking both variables. It is clean callback with no extra data: https://www.mydomain/wp/wc-api/bankart_callback

    Plugin Author geca

    (@geca)

    Well, that’s strange. Let’s do it this way – replace the entire gateway_callback function with the one bellow and let me know what gets logged.

            function gateway_callback() {
                global $woocommerce;
                global $wpdb;
    
                $this->log("Received POST request from gateway: " . print_r(filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING), true));
                $this->log("Received GET request from gateway: " . print_r(filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING), true));
    
                $response = new BankartPurchaseResponse();
                $payment_id = $response->get_request_param('paymentid');
    
                if (!$payment_id) {
                    $this->log("payment_id is missing, exiting.");
                    exit();
                }
    
                $query_string = "
                    SELECT post_id
                    FROM $wpdb->postmeta 
                    WHERE meta_value = '$payment_id' and meta_key = 'bankart-payment-id'
                ";
                
                $this->log("TEST 1: query string: " . print_r($query_string, true));
    
                $query_result = $wpdb->get_row($query_string, OBJECT);            
                
                $this->log("TEST 2: query result: " . print_r($query_result, true));
                
                $order = wc_get_order($query_result->post_id);
                
                $this->log("TEST 3:  result: " . print_r($order, true));
                
                if ($response->is_authorized()) {
                    $order->add_order_note(sprintf('Bankart Payment Completed. PaymentID is %s.'), $payment_id);
                    $order->payment_complete();
                } else {
                    $order->update_status('failed', $response->get_error_message());
                }
    
                $customer_redirect_url = str_replace('https:', 'http:', home_url('/wc-api/' . $this->id . '_customer_redirect'));
    
                $this->log("Customer redirect URL: " . $customer_redirect_url);
    
                printf('REDIRECT=%s?orderId=%s&paymentId=%s', $customer_redirect_url, $order->get_id(), $payment_id);
                exit();
            }
    Thread Starter alekssos

    (@alekssos)

    It gets the orderid and paymentid in call back link, but its WSOD:
    https://www.mydomain.si/wp/wc-api/bankart_customer_redirect?orderId=8506&paymentId=7130243430882400

    This is log:

    08-28-2018 @ 08:43:00 - Processing payment for order_id=8506
    08-28-2018 @ 08:43:00 - POST-ing to Bankart: responseURL=https://www.mydomain.si/wp/wc-api/bankart_callback, amt=103.30, action=4, trackid=8506 ...
    08-28-2018 @ 08:43:08 - Received POST request from gateway: Array
    (
        [name] => MerchantNotification
        [version] => 1
        [paymentid] => 7130243430882400
        [result] => APPROVED
        [auth] => VB7073
        [ref] => 824008663522
        [tranid] => 8357557430882400
        [postdate] => 0828
        [trackid] => 8506
        [eci] => 7
        [responsecode] => 00
        [cvv2response] => Y
    )
    
    08-28-2018 @ 08:43:08 - Received GET request from gateway: 
    08-28-2018 @ 08:43:08 - TEST 1: query string: 
                    SELECT post_id
                    FROM wp_postmeta 
                    WHERE meta_value = '7130243430882400' and meta_key = 'bankart-payment-id'
                
    08-28-2018 @ 08:43:08 - TEST 2: query result: stdClass Object
    (
        [post_id] => 8506
    )
    
    08-28-2018 @ 08:43:08 - TEST 3:  result: WC_Order Object
    (
        [status_transition:protected] => 
        [data:protected] => Array
            (
                [parent_id] => 0
                [status] => pending
                [currency] => EUR
                [version] => 3.4.4
                [prices_include_tax] => 
                [date_created] => WC_DateTime Object
                    (
                        [utc_offset:protected] => 0
                        [date] => 2018-08-28 08:42:59.000000
                        [timezone_type] => 3
                        [timezone] => Europe/Ljubljana
                    )
    
                [date_modified] => WC_DateTime Object
                    (
                        [utc_offset:protected] => 0
                        [date] => 2018-08-28 08:42:59.000000
                        [timezone_type] => 3
                        [timezone] => Europe/Ljubljana
                    )
    
                [discount_total] => 0
                [discount_tax] => 0
                [shipping_total] => 2.87
                [shipping_tax] => 0.63
                [cart_tax] => 18
                [total] => 103.30
                [total_tax] => 18.63
                [customer_id] => 0
                [order_key] => wc_order_5b84eef36c8e1
                [billing] => Array
                    (
                        [first_name] => ALeks
                        [last_name] => ?o?tari?
                        [company] => 
                        [address_1] => Ljubljanska cesta 13a
                        [address_2] => 
                        [city] => Trzin
                        [state] => 
                        [postcode] => 1236
                        [country] => SI
                        [email] => [email protected]
                        [phone] => 
                    )
    
                [shipping] => Array
                    (
                        [first_name] => ALeks
                        [last_name] => ?o?tari?
                        [company] => 
                        [address_1] => Ljubljanska cesta 13a
                        [address_2] => 
                        [city] => Trzin
                        [state] => 
                        [postcode] => 1236
                        [country] => SI
                    )
    
                [payment_method] => bankart
                [payment_method_title] => Pla?ilo s kreditno kartico
                [transaction_id] => 
                [customer_ip_address] => 89.143.13.238
                [customer_user_agent] => mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/68.0.3440.106 safari/537.36
                [created_via] => checkout
                [customer_note] => 
                [date_completed] => 
                [date_paid] => 
                [cart_hash] => ddcd4f8acb447f70d683209c1a81ac21
            )
    
        [items:protected] => Array
            (
            )
    
        [items_to_delete:protected] => Array
            (
            )
    
        [cache_group:protected] => orders
        [data_store_name:protected] => order
        [object_type:protected] => order
        [id:protected] => 8506
        [changes:protected] => Array
            (
            )
    
        [object_read:protected] => 1
        [extra_data:protected] => Array
            (
            )
    
        [default_data:protected] => Array
            (
                [parent_id] => 0
                [status] => 
                [currency] => 
                [version] => 
                [prices_include_tax] => 
                [date_created] => 
                [date_modified] => 
                [discount_total] => 0
                [discount_tax] => 0
                [shipping_total] => 0
                [shipping_tax] => 0
                [cart_tax] => 0
                [total] => 0
                [total_tax] => 0
                [customer_id] => 0
                [order_key] => 
                [billing] => Array
                    (
                        [first_name] => 
                        [last_name] => 
                        [company] => 
                        [address_1] => 
                        [address_2] => 
                        [city] => 
                        [state] => 
                        [postcode] => 
                        [country] => 
                        [email] => 
                        [phone] => 
                    )
    
                [shipping] => Array
                    (
                        [first_name] => 
                        [last_name] => 
                        [company] => 
                        [address_1] => 
                        [address_2] => 
                        [city] => 
                        [state] => 
                        [postcode] => 
                        [country] => 
                    )
    
                [payment_method] => 
                [payment_method_title] => 
                [transaction_id] => 
                [customer_ip_address] => 
                [customer_user_agent] => 
                [created_via] => 
                [customer_note] => 
                [date_completed] => 
                [date_paid] => 
                [cart_hash] => 
            )
    
        [data_store:protected] => WC_Data_Store Object
            (
                [instance:WC_Data_Store:private] => WC_Order_Data_Store_CPT Object
                    (
                        [internal_meta_keys:protected] => Array
                            (
                                [0] => _parent_id
                                [1] => _status
                                [2] => _currency
                                [3] => _version
                                [4] => _prices_include_tax
                                [5] => _date_created
                                [6] => _date_modified
                                [7] => _discount_total
                                [8] => _discount_tax
                                [9] => _shipping_total
                                [10] => _shipping_tax
                                [11] => _cart_tax
                                [12] => _total
                                [13] => _total_tax
                                [14] => _customer_id
                                [15] => _order_key
                                [16] => _billing
                                [17] => _shipping
                                [18] => _payment_method
                                [19] => _payment_method_title
                                [20] => _transaction_id
                                [21] => _customer_ip_address
                                [22] => _customer_user_agent
                                [23] => _created_via
                                [24] => _customer_note
                                [25] => _date_completed
                                [26] => _date_paid
                                [27] => _cart_hash
                                [28] => _customer_user
                                [29] => _order_key
                                [30] => _order_currency
                                [31] => _billing_first_name
                                [32] => _billing_last_name
                                [33] => _billing_company
                                [34] => _billing_address_1
                                [35] => _billing_address_2
                                [36] => _billing_city
                                [37] => _billing_state
                                [38] => _billing_postcode
                                [39] => _billing_country
                                [40] => _billing_email
                                [41] => _billing_phone
                                [42] => _shipping_first_name
                                [43] => _shipping_last_name
                                [44] => _shipping_company
                                [45] => _shipping_address_1
                                [46] => _shipping_address_2
                                [47] => _shipping_city
                                [48] => _shipping_state
                                [49] => _shipping_postcode
                                [50] => _shipping_country
                                [51] => _completed_date
                                [52] => _paid_date
                                [53] => _edit_lock
                                [54] => _edit_last
                                [55] => _cart_discount
                                [56] => _cart_discount_tax
                                [57] => _order_shipping
                                [58] => _order_shipping_tax
                                [59] => _order_tax
                                [60] => _order_total
                                [61] => _payment_method
                                [62] => _payment_method_title
                                [63] => _transaction_id
                                [64] => _customer_ip_address
                                [65] => _customer_user_agent
                                [66] => _created_via
                                [67] => _order_version
                                [68] => _prices_include_tax
                                [69] => _date_completed
                                [70] => _date_paid
                                [71] => _payment_tokens
                                [72] => _billing_address_index
                                [73] => _shipping_address_index
                                [74] => _recorded_sales
                                [75] => _recorded_coupon_usage_counts
                                [76] => _download_permissions_granted
                                [77] => _order_stock_reduced
                            )
    
                        [meta_type:protected] => post
                        [object_id_field_for_meta:protected] => 
                    )
    
                [stores:WC_Data_Store:private] => Array
                    (
                        [coupon] => WC_Coupon_Data_Store_CPT
                        [customer] => WC_Customer_Data_Store
                        [customer-download] => WC_Customer_Download_Data_Store
                        [customer-download-log] => WC_Customer_Download_Log_Data_Store
                        [customer-session] => WC_Customer_Data_Store_Session
                        [order] => WC_Order_Data_Store_CPT
                        [order-refund] => WC_Order_Refund_Data_Store_CPT
                        [order-item] => WC_Order_Item_Data_Store
                        [order-item-coupon] => WC_Order_Item_Coupon_Data_Store
                        [order-item-fee] => WC_Order_Item_Fee_Data_Store
                        [order-item-product] => WC_Order_Item_Product_Data_Store
                        [order-item-shipping] => WC_Order_Item_Shipping_Data_Store
                        [order-item-tax] => WC_Order_Item_Tax_Data_Store
                        [payment-token] => WC_Payment_Token_Data_Store
                        [product] => WC_Product_Data_Store_CPT
                        [product-grouped] => WC_Product_Grouped_Data_Store_CPT
                        [product-variable] => WC_Product_Variable_Data_Store_CPT
                        [product-variation] => WC_Product_Variation_Data_Store_CPT
                        [shipping-zone] => WC_Shipping_Zone_Data_Store
                        [webhook] => WC_Webhook_Data_Store
                    )
    
                [current_class_name:WC_Data_Store:private] => WC_Order_Data_Store_CPT
                [object_type:WC_Data_Store:private] => order
            )
    
        [meta_data:protected] => Array
            (
                [0] => WC_Meta_Data Object
                    (
                        [current_data:protected] => Array
                            (
                                [id] => 6560
                                [key] => mailchimp_woocommerce_is_subscribed
                                [value] => 1
                            )
    
                        [data:protected] => Array
                            (
                                [id] => 6560
                                [key] => mailchimp_woocommerce_is_subscribed
                                [value] => 1
                            )
    
                    )
    
                [1] => WC_Meta_Data Object
                    (
                        [current_data:protected] => Array
                            (
                                [id] => 6561
                                [key] => bankart-hpp-url
                                [value] => https://tebank.bankart.si:443/Testgw31/hppaction?formAction=com.aciworldwide.commerce.gateway.payment.action.HostedPaymentPageAction&&paymentId=7130243430882400
                            )
    
                        [data:protected] => Array
                            (
                                [id] => 6561
                                [key] => bankart-hpp-url
                                [value] => https://tebank.bankart.si:443/Testgw31/hppaction?formAction=com.aciworldwide.commerce.gateway.payment.action.HostedPaymentPageAction&&paymentId=7130243430882400
                            )
    
                    )
    
                [2] => WC_Meta_Data Object
                    (
                        [current_data:protected] => Array
                            (
                                [id] => 6562
                                [key] => bankart-payment-id
                                [value] => 7130243430882400
                            )
    
                        [data:protected] => Array
                            (
                                [id] => 6562
                                [key] => bankart-payment-id
                                [value] => 7130243430882400
                            )
    
                    )
    
            )
    
    )
    
    08-28-2018 @ 08:43:09 - Customer redirect URL: https://www.mydomain.si/wp/wc-api/bankart_customer_redirect
    08-28-2018 @ 08:43:10 - Invalid GET request: Array
    (
        [orderId] => 8506
        [paymentId] => 7130243430882400
    )
    Plugin Author geca

    (@geca)

    Let’s repeat the procedure with gateway_customer_redirect function. Replace it with the code bellow, go to https://www.mydomain.si/wp/wc-api/bankart_customer_redirect?orderId=8506&paymentId=7130243430882400 in your browser and paste the log output.

     function gateway_customer_redirect() {
         $order_id = filter_input(INPUT_GET, 'orderId', FILTER_VALIDATE_INT);
         $payment_id = filter_input(INPUT_GET, 'paymentId', FILTER_SANITIZE_STRING);
    
        $this->log("TEST 1: order_id: " . $order_id);
        $this->log("TEST 2: payment_id: " . $payment_id);
    
         if (!$order_id || !$payment_id) {
             $this->log("Invalid GET request: " . print_r(filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING), true));
             exit();
         }
    
         $order = new WC_Order($order_id);
    
         $this->log("TEST 3: order: " . print_r($order, true));
         $this->log("TEST 4: redirecting to: " . $this->get_return_url($order));
    
         wp_redirect($this->get_return_url($order));
         exit();
     }
    Thread Starter alekssos

    (@alekssos)

    Hi,

    Previous and this last code fixed the problem, I get transaction, it does not give WSOD anymore, shows checkout page, and sends all the appropiate emails.

    Dobi? pivo ?e se kdaj sre?ava ??
    Hvala ti. LP ALeks

    Plugin Author geca

    (@geca)

    Awesome! Will make sure to update the plugin ASAP.

    Ni problema – te dr?im za besedo! ??
    Pozdrav, Gregor

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Stuck on bankart_callback WSOD’ is closed to new replies.