Jump to content

Paypal Commerce Gateway ..


ChrisColeman

Recommended Posts

I have several sites running the replacement PayPal Gateway ..

However a few day ago I attempted to activated on a couple of additional sites and this morning received complaints that customers can no longer complete the checkout  process on those sites.

       In the browser log I see (see below), which repeats  (ad infinitum) -

Any ideas ..

Just noticed this error  -

Quote

Uncaught ReferenceError: $ is not defined
    <anonymous> https://www.countrycontrast.co.uk/index.php?_a=gateway:21

 

Many Thanks.

Chris.

 

 

Quote

Request Sent - https://api.paypal.com/v2/checkout/orders/
{"intent":"CAPTURE","purchase_units":[{"reference_id":"623315d3e27dc","items":[{"name":"Bottomleys Mint Rock advert","unit_amount":{"value":"2","currency_code":"GBP"},"quantity":1,"sku":"SAS9","category":"PHYSICAL_GOODS"}],"amount":{"currency_code":"GBP","value":"6.00","breakdown":{"item_total":{"value":"2","currency_code":"GBP"},"shipping":{"value":"4","currency_code":"GBP"},"tax_total":{"value":"0","currency_code":"GBP"},"discount":{"value":"0","currency_code":"GBP"}}},"shipping":{"name":{"full_name":"Chris Coleman"},"email_address":"[email protected]","phone":"01432-354286","address":{"address_line_1":"12 Ran Street","admin_area_1":"","admin_area_2":"HEREFORD","postal_code":"HR40DT","country_code":"GB"}},"invoice_id":"220317-110348-8852","description":"Payment for order 220317-110348-8852"}],"application_context":{"shipping_preference":"SET_PROVIDED_ADDRESS","brand_name":"Small Wonders Miniatures","locale":"en-GB","user_action":"PAY_NOW"},"payer":{"name":{"given_name":"Chris","surname":"Coleman"},"address":{"address_line_1":"12 Ran Street","address_line_2":"","admin_area_1":"","admin_area_2":"HEREFORD","postal_code":"HR40DT","country_code":"GB"}}}
Response received
{"id":"7M9*********8961C","intent":"CAPTURE","status":"CREATED","purchase_units":[{"reference_id":"623315d3e27dc","amount":{"currency_code":"GBP","value":"6.00","breakdown":{"item_total":{"currency_code":"GBP","value":"2.00"},"shipping":{"currency_code":"GBP","value":"4.00"},"tax_total":{"currency_code":"GBP","value":"0.00"},"discount":{"currency_code":"GBP","value":"0.00"}}},"payee":{"email_address":"[email protected]","merchant_id":"YEJVG9VG87BGE"},"description":"Payment for order 220317-110348-8852","invoice_id":"220317-110348-8852","items":[{"name":"Bottomleys Mint Rock advert","unit_amount":{"currency_code":"GBP","value":"2.00"},"quantity":"1","sku":"SAS9","category":"PHYSICAL_GOODS"}],"shipping":{"name":{"full_name":"Chris Coleman"},"address":{"address_line_1":"12 Ran Street","admin_area_2":"HEREFORD","postal_code":"HR40DT","country_code":"GB"}}}],"payer":{"name":{"given_name":"Chris","surname":"Coleman"},"address":{"address_line_1":"12 Ran Street","admin_area_2":"HEREFORD","postal_code":"HR40DT","country_code":"GB"}},"create_time":"2022-03-17T11:35:24Z","links":[{"href":"https://api.paypal.com/v2/checkout/orders/7M9*********8961C","rel":"self","method":"GET"},{"href":"https://www.paypal.com/checkoutnow?token=7M9*********8961C","rel":"approve","method":"GET"},{"href":"https://api.paypal.com/v2/checkout/orders/7M9*********8961C","rel":"update","method":"PATCH"},{"href":"https://api.paypal.com/v2/checkout/orders/7M9*********8961C/capture","rel":"capture","method":"POST"}]}
Today, 11:35    
Request Sent - https://api.paypal.com/v1/identity/generate-token
Response received
{"client_token":"eyJicmFpbnRyZWUiOnsiYXV0aG9yaXphdGlvbkZpbmdlcnByaW50IjoiYzRiNjJiMGFiYTg4ODZmYzJlZjIzNmQwZTBlMGU2YTljNTkwNGJlNDhmMmQzNDMyNDk4MDg5MDFlZDE1ODM3ZnxtZXJjaGFudF9pZD1yd3dua3FnMnhnNTZobTJuJnB1YmxpY19rZXk9ajJmYzJqcHhkZzZ2cDg0ZiZjcmVhdGVkX2F0PTIwMjItMDMtMTdUMTE6MzU6MjQuNTE2WiIsInZlcnNpb24iOiIzLXBheXBhbCJ9LCJwYXlwYWwiOnsiaWRUb2tlbiI6bnVsbCwiYWNjZXNzVG9rZW4iOiJBMjFBQU9FV1YzVnVQQlRUcU95OGJvYmh5blQ5ZjhGOXNDa2tjVVl6M3JmWjFrcjRMSDVPNEpGWGRwRzM5LUtaTXZ5eVV1THJFZzl6TmtkSXZfWEVUQmx1Yl9DaXlnNWVBIn19","expires_in":3600}
Today, 11:32    
Request Sent - https://api.paypal.com/v2/checkout/orders/
{"intent":"CAPTURE","purchase_units":[{"reference_id":"623315d3e27dc","items":[{"name":"Bottomleys Mint Rock advert","unit_amount":{"value":"2","currency_code":"GBP"},"quantity":1,"sku":"SAS9","category":"PHYSICAL_GOODS"}],"amount":{"currency_code":"GBP","value":"6.00","breakdown":{"item_total":{"value":"2","currency_code":"GBP"},"shipping":{"value":"4","currency_code":"GBP"},"tax_total":{"value":"0","currency_code":"GBP"},"discount":{"value":"0","currency_code":"GBP"}}},"shipping":{"name":{"full_name":"Chris Coleman"},"email_address":"[email protected]","phone":"01432-354286","address":{"address_line_1":"12 Ran Street","admin_area_1":"","admin_area_2":"HEREFORD","postal_code":"HR40DT","country_code":"GB"}},"invoice_id":"220317-110348-8852","description":"Payment for order 220317-110348-8852"}],"application_context":{"shipping_preference":"SET_PROVIDED_ADDRESS","brand_name":"Small Wonders Miniatures","locale":"en-GB","user_action":"PAY_NOW"},"payer":{"name":{"given_name":"Chris","surname":"Coleman"},"address":{"address_line_1":"12 Ran Street","address_line_2":"","admin_area_1":"","admin_area_2":"HEREFORD","postal_code":"HR40DT","country_code":"GB"}}}
Response received
{"id":"4PP664404V1521223","intent":"CAPTURE","status":"CREATED","purchase_units":[{"reference_id":"623315d3e27dc","amount":{"currency_code":"GBP","value":"6.00","breakdown":{"item_total":{"currency_code":"GBP","value":"2.00"},"shipping":{"currency_code":"GBP","value":"4.00"},"tax_total":{"currency_code":"GBP","value":"0.00"},"discount":{"currency_code":"GBP","value":"0.00"}}},"payee":{"email_address":"[email protected]","merchant_id":"YEJVG9VG87BGE"},"description":"Payment for order 220317-110348-8852","invoice_id":"220317-110348-8852","items":[{"name":"Bottomleys Mint Rock advert","unit_amount":{"currency_code":"GBP","value":"2.00"},"quantity":"1","sku":"SAS9","category":"PHYSICAL_GOODS"}],"shipping":{"name":{"full_name":"Chris Coleman"},"address":{"address_line_1":"12 Ran Street","admin_area_2":"HEREFORD","postal_code":"HR40DT","country_code":"GB"}}}],"payer":{"name":{"given_name":"Chris","surname":"Coleman"},"address":{"address_line_1":"12 Ran Street","admin_area_2":"HEREFORD","postal_code":"HR40DT","country_code":"GB"}},"create_time":"2022-03-17T11:32:18Z","links":[{"href":"https://api.paypal.com/v2/checkout/orders/4PP664404V1521223","rel":"self","method":"GET"},{"href":"https://www.paypal.com/checkoutnow?token=4PP664404V1521223","rel":"approve","method":"GET"},{"href":"https://api.paypal.com/v2/checkout/orders/4PP664404V1521223","rel":"update","method":"PATCH"},{"href":"https://api.paypal.com/v2/checkout/orders/4PP664404V1521223/capture","rel":"capture","method":"POST"}]}
Today, 11:32    
Request Sent - https://api.paypal.com/v1/identity/generate-token
Response received
{"client_token":"eyJicmFpbnRyZWUiOnsiYXV0aG9yaXphdGlvbkZpbmdlcnByaW50IjoiZWUxYmE1ZmZjMGE5NGU2ZGMzYzllNDE2YjI2YzJmN2NkY2NjOTkwY2NlMmE3ODMzYzZlZGFiMTgxYzIwYzgwZHxtZXJjaGFudF9pZD1yd3dua3FnMnhnNTZobTJuJnB1YmxpY19rZXk9ajJmYzJqcHhkZzZ2cDg0ZiZjcmVhdGVkX2F0PTIwMjItMDMtMTdUMTE6MzI6MTguNTUxWiIsInZlcnNpb24iOiIzLXBheXBhbCJ9LCJwYXlwYWwiOnsiaWRUb2tlbiI6bnVsbCwiYWNjZXNzVG9rZW4iOiJBMjFBQU9UdUdyRHVHaG9IcUZ5VU5idlhxSjVORzNGekdfb0RqVzFRbGI5eXppZDktWTVSZkZlQU41NFRRY2M2QlFBUWRncmstUUdGaFl5RjNRdXE3dUswUXhUTjVxQm9RIn19","expires_in":3600}
om/v1/notifications/webhooks

 

Edited by ChrisColeman
Update ..
Link to comment
Share on other sites

The Uncaught Reference error indicates that, for whatever reason, the skin is not loading jQuery correctly, if at all.

The skin, in its final form, as displayed in the browser, has a resource link that points to a web address where jQuery can be found -- either from your store or from another location on the internet. Usually, when this error happens, it could be because there is a browser add-on or utility that prevents loading javascript files from other than your own site.

The Request/Response does not suggest there are any errors to be reported.

 

Link to comment
Share on other sites

Hi, I have regressed the sites in question to PayPal standard which works as it did and will do a bit of digging. 
 

So must be using a different jquery - or non at all which would be better🍺
 

On the subject, I don’t not if the send/receive loop is good - should it not anticipate an error or at least wait a while before resending the request. 
     I have some history with Stripe which is not entirely different and it is usual to await an acknowledgement before resending the request?

Link to comment
Share on other sites

  • 2 months later...

Hi, 

    I just tried this again with with PayPal Commerce 1.6.2 and still no joy, therefore I downloaded the 1.6.2 code to get a better look ..

And this  is what I found -

/**
 * CubeCart v6
 * ========================================
 * CubeCart is a registered trade mark of CubeCart Limited
 * Copyright CubeCart Limited 2019. All rights reserved.
 * UK Private Limited Company No. 5323904
 * ========================================
 * Web:   http://www.cubecart.com
 * Email:  [email protected]
 * License:  GPL-3.0 http://opensource.org/licenses/GPL-3.0
 */
function ppcp_body_js($tpl_output, Smarty_Internal_Template $template)
{
    $skins = $GLOBALS['gui']->getSkinData()['info'];
   //  $skin = $GLOBALS['gui']->getSkinData();
  
    if (($pp_config = $GLOBALS['cache']->read('pp_config.'.$skins['name'])) === false) {
        if(file_exists('modules/plugins/paypal_commerce/config.custom.json')) {
            $pp_config = file_get_contents('modules/plugins/paypal_commerce/config.custom.json');
        } else if(file_exists('modules/plugins/paypal_commerce/config.'.$skins['name'].'.json')) {
            $pp_config = file_get_contents('modules/plugins/paypal_commerce/config.'.$skins['name'].'.json');
        } else {
            $pp_config = file_get_contents('modules/plugins/paypal_commerce/config.foundation.json');
        }
        $GLOBALS['cache']->write($pp_config, 'pp_config.'.$skins['name']);
    }
    if(isset($GLOBALS['cart']->basket['total']) && $GLOBALS['cart']->basket['total'] > 0) {
        $pp_amount = $GLOBALS['cart']->basket['total'];
    } else {
        $pp_amount = "null";
    }

    return preg_replace('/\<\/body\>/i','<script id="pp_config" type="application/json">'.$pp_config.'</script><script>
        var pp_config = JSON.parse(document.getElementById(\'pp_config\').textContent)
        var pp_amount = '.$pp_amount.';</script></body>', $tpl_output);

    return $tpl_output;
}
$GLOBALS['smarty']->registerFilter("output","ppcp_body_js");

On about the third line of code you can see I have replaced a line. Now the thing is that this was never going to work the variable '$skin' is never referenced in the code so its clearly in error.

The question is why did nobody else experience the same ?

Its probably because, and this is just a guess, many other skins are strongly based upon the foundation skin, but as I say that's only a guess ..

Anyway it seems to be working now but no production test yet..

Chris.

 

 

  • Like 1
Link to comment
Share on other sites

Hi,

      A confession ..

Even though there is an error as reported - That was not the cause of my problem.

The skin I'm using does not use JQUERY, I'm not a fan.

It has worked without issue for 5+ years.

Anyway it turns out that paypal_commerce has a dependency on a jquery file being present in the currently active skin (??).

So thats it I replaced a JQUERY file into my skin and it now works.

Chris.

ps. I have posted on GITHUB.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...