SagePay PayNow Module



  • Hi all,

    I’m using ThirtyBees 1.04 with the SagePay PayNow module (3rd party payment gateway) for PrestaShop. Tested with PrestaShop 1.6.11, it works perfectly until it comes back from the payment provider, at which point it simply reverts back to the first order page. The result is a payment without an order. I’m looking at the code to figure out what has changed and why it doesn’t get to the order confirmation page. Any help would be appreciated, from where to look for changes to a sample payment module that works - anything that will help me sort this out. I’m a C# developer by trade, but PHP isn’t too different, and I’ve done plenty of web dev over the years. I’ve taken a look at the code as I said, just looking for some pointers here.

    TIA


  • administrators

    Check the error log for any errors on the payment return, that would be the first place I looked.



  • I am seeing the exact same issue, no problem on Prestashop, but thirty bees does not process the order.

    I see the post back but the Cart Does not get turned into a valid order

    105.186.16.177 - - [27/Feb/2018:13:02:47 +0200] “GET /modules/paynow/logo.png HTTP/1.1” 200 3326 “-” "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6"
    41.21.175.145 - - [27/Feb/2018:13:06:12 +0200] “POST /modules/paynow/paynow_callback.php?key=xxxxxxxxxxx0f716d7fa8cd8b3064&id_cart=23188&id_module=185 HTTP/1.1” 302 4708 “-” "-"
    105.186.16.177 - - [27/Feb/2018:13:06:13 +0200] “POST /modules/paynow/paynow_callback.php?key=xxxxxxxxxxx0f716d7fa8cd8b3064&id_cart=23188&id_module=185 HTTP/1.1” 302 630 “https://paynow.sagepay.co.za/Site/PayNowAccept.aspx” "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6"
    105.186.16.177 - - [27/Feb/2018:13:06:14 +0200] “GET /index.php?controller=order-confirmation?key=xxxxxxxxxxx0f716d7fa8cd8b3064&id_cart=23188&id_module=185 HTTP/1.1” 302 389 “https://paynow.sagepay.co.za/Site/PayNowAccept.aspx” "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6"
    105.186.16.177 - - [27/Feb/2018:13:06:14 +0200] “GET /order-history HTTP/1.1” 200 7936 “https://paynow.sagepay.co.za/Site/PayNowAccept.aspx” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6”

    I do also get a warning on the dispatcher…

    [Tue Feb 27 13:06:13.512467 2018] [fcgid:warn] [pid 160555] [client 41.21.175.145:55652] mod_fcgid: stderr: PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client2/web5/web/classes/Dispatcher.php on line 513
    [Tue Feb 27 13:06:13.959738 2018] [fcgid:warn] [pid 160555] [client 41.21.175.145:55652] mod_fcgid: stderr: PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client2/web5/web/classes/Dispatcher.php on line 513

    This is what I get in the module debug log

    2018-02-27 13:06:12 : Verify data received
    2018-02-27 13:06:12 : Host = gateway.sagepay.co.za
    2018-02-27 13:06:12 : Params = RequestTrace=36973.31290079
    2018-02-27 13:06:12 : curl_init
    2018-02-27 13:06:13 : Response:

    2018-02-27 13:06:13 : Amount: Valid!
    2018-02-27 13:06:13 : --> valOne: [string] true
    2018-02-27 13:06:13 : --> valTwo: [string] true
    2018-02-27 13:06:13 : TransactionAccepted: Valid!
    2018-02-27 13:06:13 : Reference: Valid!
    2018-02-27 13:06:13 : RequestTrace: Valid!
    2018-02-27 13:06:13 : pnValidData: true
    2018-02-27 13:06:13 : Check status and update order
    2018-02-27 13:06:13 : - Complete
    2018-02-27 13:06:13 : - Redirecting to order-confirmation
    2018-02-27 13:06:14 : SagePayNow Validation initiated.
    2018-02-27 13:06:14 : Get posted data
    2018-02-27 13:06:14 : SagePayNow Data: Array
    (
    [TransactionAccepted] => true
    [CardHolderIpAddr] => 198.6.6.1
    [RequestTrace] => 36973.31290079
    [Reference] => 23188_2018022746
    [Extra1] => 1337
    [Extra2] => 23188
    [Extra3] => xxxxxxxxxxx0f716d7fa8cd8b3064
    [Amount] => 3765.0000
    [Method] => 1
    )

    2018-02-27 13:06:14 : Purchase:
    Cart Object
    (
    [id_shop_group] => 1
    [id_shop] => 1
    [id_address_delivery] => 1378
    [id_address_invoice] => 1378
    [id_currency] => 3
    [id_customer] => 1337
    [id_guest] => 576807
    [id_lang] => 1
    [recyclable] => 0
    [gift] => 0
    [gift_message] =>
    [mobile_theme] => 0
    [date_add] => 2018-02-27 12:57:25
    [secure_key] => xxxxxxxxxxx0f716d7fa8cd8b3064
    [id_carrier] => 28
    [date_upd] => 2018-02-27 13:02:33
    [checkedTos] =>
    [pictures] =>
    [textFields] =>
    [delivery_option] => a:1:{i:1378;s:3:“28,”;}
    [allow_seperated_package] => 0
    [_products:protected] =>
    [_taxCalculationMethod:protected] => 0
    [webserviceParameters:protected] => Array
    (
    [fields] => Array
    (
    [id_address_delivery] => Array
    (
    [xlink_resource] => addresses
    )

                    [id_address_invoice] => Array
                        (
                            [xlink_resource] => addresses
                        )
    
                    [id_currency] => Array
                        (
                            [xlink_resource] => currencies
                        )
    
                    [id_customer] => Array
                        (
                            [xlink_resource] => customers
                        )
    
                    [id_guest] => Array
                        (
                            [xlink_resource] => guests
                        )
    
                    [id_lang] => Array
                        (
                            [xlink_resource] => languages
                        )
    
                )
    
            [associations] => Array
                (
                    [cart_rows] => Array
                        (
                            [resource] => cart_row
                            [virtual_entity] => 1
                            [fields] => Array
                                (
                                    [id_product] => Array
                                        (
                                            [required] => 1
                                            [xlink_resource] => products
                                        )
    
                                    [id_product_attribute] => Array
                                        (
                                            [required] => 1
                                            [xlink_resource] => combinations
                                        )
    
                                    [id_address_delivery] => Array
                                        (
                                            [required] => 1
                                            [xlink_resource] => addresses
                                        )
    
                                    [quantity] => Array
                                        (
                                            [required] => 1
                                        )
    
                                )
    
                        )
    
                )
    
        )
    
    [id] => 23188
    [id_shop_list] => 
    [get_shop_from_context:protected] => 1
    [table:protected] => cart
    [identifier:protected] => id_cart
    [fieldsRequired:protected] => Array
        (
            [0] => id_currency
            [1] => id_lang
        )
    
    [fieldsSize:protected] => Array
        (
            [secure_key] => 32
        )
    
    [fieldsValidate:protected] => Array
        (
            [id_shop_group] => isUnsignedId
            [id_shop] => isUnsignedId
            [id_address_delivery] => isUnsignedId
            [id_address_invoice] => isUnsignedId
            [id_carrier] => isUnsignedId
            [id_currency] => isUnsignedId
            [id_customer] => isUnsignedId
            [id_guest] => isUnsignedId
            [id_lang] => isUnsignedId
            [recyclable] => isBool
            [gift] => isBool
            [gift_message] => isMessage
            [mobile_theme] => isBool
            [allow_seperated_package] => isBool
            [date_add] => isDate
            [date_upd] => isDate
        )
    
    [fieldsRequiredLang:protected] => Array
        (
        )
    
    [fieldsSizeLang:protected] => Array
        (
        )
    
    [fieldsValidateLang:protected] => Array
        (
        )
    
    [tables:protected] => Array
        (
        )
    
    [image_dir:protected] => 
    [image_format:protected] => jpg
    [def:protected] => Array
        (
            [table] => cart
            [primary] => id_cart
            [fields] => Array
                (
                    [id_shop_group] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                        )
    
                    [id_shop] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                        )
    
                    [id_address_delivery] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                        )
    
                    [id_address_invoice] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                        )
    
                    [id_carrier] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                        )
    
                    [id_currency] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                            [required] => 1
                        )
    
                    [id_customer] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                        )
    
                    [id_guest] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                        )
    
                    [id_lang] => Array
                        (
                            [type] => 1
                            [validate] => isUnsignedId
                            [required] => 1
                        )
    
                    [recyclable] => Array
                        (
                            [type] => 2
                            [validate] => isBool
                        )
    
                    [gift] => Array
                        (
                            [type] => 2
                            [validate] => isBool
                        )
    
                    [gift_message] => Array
                        (
                            [type] => 3
                            [validate] => isMessage
                        )
    
                    [mobile_theme] => Array
                        (
                            [type] => 2
                            [validate] => isBool
                        )
    
                    [delivery_option] => Array
                        (
                            [type] => 3
                        )
    
                    [secure_key] => Array
                        (
                            [type] => 3
                            [size] => 32
                        )
    
                    [allow_seperated_package] => Array
                        (
                            [type] => 2
                            [validate] => isBool
                        )
    
                    [date_add] => Array
                        (
                            [type] => 5
                            [validate] => isDate
                        )
    
                    [date_upd] => Array
                        (
                            [type] => 5
                            [validate] => isDate
                        )
    
                )
    
            [classname] => Cart
        )
    
    [update_fields:protected] => 
    [force_id] => 
    

    )

    2018-02-27 13:06:14 : Verify data received
    2018-02-27 13:06:14 : Host = gateway.sagepay.co.za
    2018-02-27 13:06:14 : Params = RequestTrace=36973.31290079
    2018-02-27 13:06:14 : curl_init
    2018-02-27 13:06:14 : Response:

    2018-02-27 13:06:14 : Amount: Valid!
    2018-02-27 13:06:14 : --> valOne: [string] true
    2018-02-27 13:06:14 : --> valTwo: [string] true
    2018-02-27 13:06:14 : TransactionAccepted: Valid!
    2018-02-27 13:06:14 : Reference: Valid!
    2018-02-27 13:06:14 : RequestTrace: Valid!
    2018-02-27 13:06:14 : pnValidData: true
    2018-02-27 13:06:14 : Check status and update order
    2018-02-27 13:06:14 : - Complete
    2018-02-27 13:06:14 : - Redirecting to order-confirmationxxxxxxxxxxx



  • @lekkatime That’s exactly my experience. I have a feeling something may have changed with regard to carrying the order back to the order page, losing it’s state.



  • I added the redirect URL to the log. Can anyone confirm if we are missing anything on this?

    index.php?controller=order-confirmation&key=xxxx24d7a231aa37d91113f6905xxxx&id_cart=69&id_module=100

    I see the code is setup as follows:
    Tools::redirect(‘index.php?controller=order-confirmation&’.$_SERVER[‘QUERY_STRING’]);

    Is that not perhaps causing the & issues we are seeing on the redirect line above? Would it not be worth recreating the line, as in say the Authorize module?
    Tools::redirect($url.‘id_module=’.(int) $authorizeaim->id.’&id_cart=’.(int) $cart->id.’&key=’.$auth_order->secure_key);



  • Okay, I tried cleaning up the URL for redirect - verified this in the log. No joy. Any help appreciated here.



  • @Raithlin have you contacted the paynow developers ? Have they been helpful ?



  • @lekkatime I’ve been away on business for the last week. No, not yet - but I’m going to do that. I’ll revert if I have any feedback.


Log in to reply
 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.