We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Problem, Shop

PayPal Express always cancels

Every time I click my PayPal express button and I go to the page calling perch_shop_checkout() for PayPal express, it never sends me to the PayPal site, but instead straight to my cancel page.

I have my shop.php file with all the appropriate keys (replaced here with x's). I pulled them straight form PayPal developer site.

<?php
    return [
        'gateways' => [

            'paypal-express' => [
                'enabled'   => true,
                'test_mode' => true,
                'live' => [
                    'username'  => 'xxx',
                    'password'  => 'xxxxxx',
                    'signature' => 'xxxxxx',
                ],
                'test' => [
                    'username'  => 'xxx',
                    'password'  => 'xxxxxx',
                    'signature' => 'xxxxxx',
                ],
            ],

            'braintree' => [
                'enabled'   => true,
                'test_mode' => true,
                'live' => [
                    'merchantId'  => 'xxx',
                    'publicKey'   => 'xxxxxx',
                    'privateKey'  => 'xxxxxx',
                ],
                'test' => [
                    'merchantId'  => 'xxx',
                    'publicKey'   => 'xxxxxx',
                    'privateKey'  => 'xxxxxx',
                ],
            ],
        ]
    ];

here's the basic code for the page ... all that I have before it are a few snippets of code defining DOMAIN as well as the runtime.php file.

<?php
if (perch_member_logged_in()) {
  // your 'success' return URL
  $return_url = 'https://'.DOMAIN.'/checkout/success-paypal.php';
  $cancel_url = 'https://'.DOMAIN.'/checkout/cancel.php';

  perch_shop_checkout('paypal-express', [
    'return_url' => $return_url,
    'cancel_url' => $cancel_url,
  ]);
} else {
    PerchUtil::redirect('https://'.DOMAIN.'/checkout/checkout.php');
}
?>

I guess I can't say it ALWAYS cancels, since TWICE it has properly redirected me to PayPal express checkout form.

So why did it send me twice to the PayPal express checkout form and the rest of the time to the cancel page?

Blake Myers

Blake Myers 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I've got no idea. What more can you tell me?

I'm not sure what else there is to say ... I've tried it on the live server and my development server ... I've tried different browsers too.

I tried calling the debugger, but that just stops everything from happening.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you turned on debug? Is there anything in your server error log? Are your SSL certs up to date?

Yes, I have debug on, but nothing pops up.

SSL certs are good as well. Although ... I'm using Let's Encrypt ... do you think that has anything to do with it?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, I mean the outbound SSL configuration for contacting PayPal, not your site's HTTPS connection.

I was finally able to catch a debug on the issue ... here's the part I think you need ...

Payment failed
Omnipay\PayPal\Message\ExpressAuthorizeResponse Object
(
    [liveCheckoutEndpoint:protected] => https://www.paypal.com/cgi-bin/webscr
    [testCheckoutEndpoint:protected] => https://www.sandbox.paypal.com/cgi-bin/webscr
    [request:protected] => Omnipay\PayPal\Message\ExpressAuthorizeRequest Object
        (
            [liveEndpoint:protected] => https://api-3t.paypal.com/nvp
            [testEndpoint:protected] => https://api-3t.sandbox.paypal.com/nvp
            [parameters:protected] => Symfony\Component\HttpFoundation\ParameterBag Object
                (
                    [parameters:protected] => Array
                        (
                            [username] => XXXXXXXXXXXXXXX
                            [password] => XXXXXXXXXXXXXXX
                            [signature] => XXXXXXXXXXXXXXX
                            [testMode] => 1
                            [solutionType] => Sole
                            [landingPage] => Billing
                            [brandName] => 
                            [headerImageUrl] => 
                            [logoImageUrl] => 
                            [borderColor] => 
                            [returnUrl] => https://becalistyle.local/checkout/success.php
                            [cancelUrl] => https://becalistyle.local/checkout/cancel.php
                            [amount] => 3000.00
                            [currency] => HUF
                            [transactionId] => 76
                            [clientIp] => 127.0.0.1
                            [description] => Order #76
                            [card] => Omnipay\Common\CreditCard Object
                                (
                                    [supported_cards:protected] => Array
                                        (
                                            [visa] => /^4\d{12}(\d{3})?$/
                                            [mastercard] => /^(5[1-5]\d{4}|677189)\d{10}$|^(222[1-9]|2[3-6]\d{2}|27[0-1]\d|2720)\d{12}$/
                                            [discover] => /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/
                                            [amex] => /^3[47]\d{13}$/
                                            [diners_club] => /^3(0[0-5]|[68]\d)\d{11}$/
                                            [jcb] => /^35(28|29|[3-8]\d)\d{12}$/
                                            [switch] => /^6759\d{12}(\d{2,3})?$/
                                            [solo] => /^6767\d{12}(\d{2,3})?$/
                                            [dankort] => /^5019\d{12}$/
                                            [maestro] => /^(5[06-8]|6\d)\d{10,17}$/
                                            [forbrugsforeningen] => /^600722\d{10}$/
                                            [laser] => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/
                                        )

                                    [parameters:protected] => Symfony\Component\HttpFoundation\ParameterBag Object
                                        (
                                            [parameters:protected] => Array
                                                (
                                                    [billingFirstName] => Blake
                                                    [shippingFirstName] => Blake
                                                    [billingLastName] => Myers
                                                    [shippingLastName] => Myers
                                                    [billingAddress1] => XXXXXXXXXXXXXXX
                                                    [billingAddress2] => 
                                                    [billingCity] => Praha 4
                                                    [billingPostcode] => 147000
                                                    [billingState] => 
                                                    [billingCountry] => CZ
                                                    [shippingAddress1] => XXXXXXXXXXXXXXX
                                                    [shippingAddress2] => 
                                                    [shippingCity] => Praha 4
                                                    [shippingPostcode] => 147000
                                                    [shippingState] => 
                                                    [shippingCountry] => CZ
                                                    [billingCompany] => 
                                                    [shippingCompany] => 
                                                    [email] => XXXXXXXXXXXXXXX
                                                )

                                        )

                                )

                            [transactionReference] => 76
                        )

                )

            [httpClient:protected] => Guzzle\Http\Client Object
                (
                    [defaultHeaders:protected] => Guzzle\Common\Collection Object
                        (
                            [data:protected] => Array
                                (
                                )

                        )

                    [userAgent:protected] => Guzzle/3.9.3 curl/7.55.1 PHP/7.1.8
                    [config:Guzzle\Http\Client:private] => Guzzle\Common\Collection Object
                        (
                            [data:protected] => Array
                                (
                                    [curl.options] => Array
                                        (
                                            [78] => 60
                                            [10065] => /Users/bmyers/Sites/becalistyle/perch/addons/apps/perch_shop/lib/vendor/guzzle/guzzle/src/Guzzle/Http/Resources/cacert.pem
                                            [64] => 1
                                            [81] => 2
                                        )

                                )

                        )

                    [baseUrl:Guzzle\Http\Client:private] => 
                    [curlMulti:Guzzle\Http\Client:private] => Guzzle\Http\Curl\CurlMultiProxy Object
                        (
                            [handles:protected] => Array
                                (
                                    [0] => Guzzle\Http\Curl\CurlMulti Object
                                        (
                                            [multiHandle:protected] => Resource id #207
                                            [requests:protected] => Array
                                                (
                                                )

                                            [handles:protected] => SplObjectStorage Object
                                                (
                                                    [storage:SplObjectStorage:private] => Array
                                                        (
                                                        )

                                                )

                                            [resourceHash:protected] => Array
                                                (
                                                )

                                            [exceptions:protected] => Array
                                                (
                                                )

                                            [successful:protected] => Array
                                                (
                                                )

                                            [multiErrors:protected] => Array
                                                (
                                                    [1] => Array
                                                        (
                                                            [0] => CURLM_BAD_HANDLE
                                                            [1] => The passed-in handle is not a valid CURLM handle.
                                                        )

                                                    [2] => Array
                                                        (
                                                            [0] => CURLM_BAD_EASY_HANDLE
                                                            [1] => An easy handle was not good/valid. It could mean that it isn't an easy handle at all, or possibly that the handle already is in used by this or another multi handle.
                                                        )

                                                    [3] => Array
                                                        (
                                                            [0] => CURLM_OUT_OF_MEMORY
                                                            [1] => You are doomed.
                                                        )

                                                    [4] => Array
                                                        (
                                                            [0] => CURLM_INTERNAL_ERROR
                                                            [1] => This can only be returned if libcurl bugs. Please report it to us!
                                                        )

                                                )

                                            [selectTimeout:protected] => 1
                                            [eventDispatcher:protected] => Symfony\Component\EventDispatcher\EventDispatcher Object
                                                (
                                                    [listeners:Symfony\Component\EventDispatcher\EventDispatcher:private] => Array
                                                        (
                                                        )

                                                    [sorted:Symfony\Component\EventDispatcher\EventDispatcher:private] => Array
                                                        (
                                                        )

                                                )

                                        )

                                )

                            [groups:protected] => Array
                                (
                                )

                            [queued:protected] => Array
                                (
                                )

                            [maxHandles:protected] => 3
                            [selectTimeout:protected] => 1
                            [eventDispatcher:protected] => Symfony\Component\EventDispatcher\EventDispatcher Object
                                (
                                    [listeners:Symfony\Component\EventDispatcher\EventDispatcher:private] => Array
                                        (
                                        )

                                    [sorted:Symfony\Component\EventDispatcher\EventDispatcher:private] => Array
                                        (
                                        )

                                )

                        )

                    [uriTemplate:Guzzle\Http\Client:private] => Guzzle\Parser\UriTemplate\UriTemplate Object
                        (
                            [template:Guzzle\Parser\UriTemplate\UriTemplate:private] => 
                            [variables:Guzzle\Parser\UriTemplate\UriTemplate:private] => 
                            [regex:Guzzle\Parser\UriTemplate\UriTemplate:private] => /\{([^\}]+)\}/
                        )

                    [requestFactory:protected] => Guzzle\Http\Message\RequestFactory Object
                        (
                            [methods:protected] => Array
                                (
                                    [getInstance] => 0
                                    [__construct] => 1
                                    [fromMessage] => 2
                                    [fromParts] => 3
                                    [create] => 4
                                    [cloneRequestWithMethod] => 5
                                    [applyOptions] => 6
                                    [visit_headers] => 7
                                    [visit_body] => 8
                                    [visit_allow_redirects] => 9
                                    [visit_auth] => 10
                                    [visit_query] => 11
                                    [visit_cookies] => 12
                                    [visit_events] => 13
                                    [visit_plugins] => 14
                                    [visit_exceptions] => 15
                                    [visit_save_to] => 16
                                    [visit_params] => 17
                                    [visit_timeout] => 18
                                    [visit_connect_timeout] => 19
                                    [visit_debug] => 20
                                    [visit_verify] => 21
                                    [visit_proxy] => 22
                                    [visit_cert] => 23
                                    [visit_ssl_key] => 24
                                )

                            [requestClass:protected] => Guzzle\Http\Message\Request
                            [entityEnclosingRequestClass:protected] => Guzzle\Http\Message\EntityEnclosingRequest
                        )

                    [eventDispatcher:protected] => Symfony\Component\EventDispatcher\EventDispatcher Object
                        (
                            [listeners:Symfony\Component\EventDispatcher\EventDispatcher:private] => Array
                                (
                                    [request.sent] => Array
                                        (
                                            [100] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [0] => Guzzle\Http\RedirectPlugin Object
                                                                (
                                                                    [defaultMaxRedirects:protected] => 5
                                                                )

                                                            [1] => onRequestSent
                                                        )

                                                )

                                        )

                                    [request.clone] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [0] => Guzzle\Http\RedirectPlugin Object
                                                                (
                                                                    [defaultMaxRedirects:protected] => 5
                                                                )

                                                            [1] => cleanupRequest
                                                        )

                                                )

                                        )

                                    [request.before_send] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [0] => Guzzle\Http\RedirectPlugin Object
                                                                (
                                                                    [defaultMaxRedirects:protected] => 5
                                                                )

                                                            [1] => cleanupRequest
                                                        )

                                                )

                                        )

                                )

                            [sorted:Symfony\Component\EventDispatcher\EventDispatcher:private] => Array
                                (
                                )

                        )

                )

            [httpRequest:protected] => Symfony\Component\HttpFoundation\Request Object
                (
                    [attributes] => Symfony\Component\HttpFoundation\ParameterBag Object
                        (
                            [parameters:protected] => Array
                                (
                                )

                        )

                    [request] => Symfony\Component\HttpFoundation\ParameterBag Object
                        (
                            [parameters:protected] => Array
                                (
                                )

                        )

                    [query] => Symfony\Component\HttpFoundation\ParameterBag Object
                        (
                            [parameters:protected] => Array
                                (
                                )

                        )

                    [server] => Symfony\Component\HttpFoundation\ServerBag Object
                        (
                            [parameters:protected] => Array
                                (
                                    [REDIRECT_STATUS] => 200
                                    [HTTP_HOST] => becalistyle.local
                                    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
                                    [HTTP_COOKIE] => PHPSESSID=h43nlq33co85d36v3j6ih48ff7; p_m=5ad2594c8178ac39a0ee97bc5a54af308630abc1; cmsa=1
                                    [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38
                                    [HTTP_ACCEPT_LANGUAGE] => en-us
                                    [HTTP_DNT] => 1
                                    [HTTP_ACCEPT_ENCODING] => gzip, deflate
                                    [HTTP_X_FORWARDED_PROTO] => https
                                    [HTTP_X_FORWARDED_PORT] => 443
                                    [HTTP_X_FORWARDED_FOR] => 127.0.0.1
                                    [HTTP_X_FORWARDED_HOST] => becalistyle.local
                                    [HTTP_X_FORWARDED_SERVER] => becalistyle.local
                                    [HTTP_CONNECTION] => Keep-Alive
                                    [PATH] => /usr/bin:/bin:/usr/sbin:/sbin
                                    [SERVER_SIGNATURE] => 
Apache Server at becalistyle.local Port 443


                                    [SERVER_SOFTWARE] => Apache
                                    [SERVER_NAME] => becalistyle.local
                                    [SERVER_ADDR] => 127.0.0.1
                                    [SERVER_PORT] => 443
                                    [REMOTE_ADDR] => 127.0.0.1
                                    [DOCUMENT_ROOT] => /Users/bmyers/Sites/becalistyle
                                    [REQUEST_SCHEME] => https
                                    [CONTEXT_PREFIX] => 
                                    [CONTEXT_DOCUMENT_ROOT] => /Users/bmyers/Sites/becalistyle
                                    [SERVER_ADMIN] => admin@example.com
                                    [SCRIPT_FILENAME] => /Users/bmyers/Sites/becalistyle/hta.php
                                    [REMOTE_PORT] => 52142
                                    [REDIRECT_URL] => /checkout/paypal.php
                                    [GATEWAY_INTERFACE] => CGI/1.1
                                    [SERVER_PROTOCOL] => HTTP/1.1
                                    [REQUEST_METHOD] => GET
                                    [QUERY_STRING] => 
                                    [REQUEST_URI] => /checkout/paypal.php
                                    [SCRIPT_NAME] => /hta.php
                                    [PHP_SELF] => /checkout/paypal.php
                                    [REQUEST_TIME_FLOAT] => 1506880974.753
                                    [REQUEST_TIME] => 1506880974
                                )

                        )

                    [files] => Symfony\Component\HttpFoundation\FileBag Object
                        (
                            [parameters:protected] => Array
                                (
                                )

                        )

                    [cookies] => Symfony\Component\HttpFoundation\ParameterBag Object
                        (
                            [parameters:protected] => Array
                                (
                                    [PHPSESSID] => h43nlq33co85d36v3j6ih48ff7
                                    [p_m] => 5ad2594c8178ac39a0ee97bc5a54af308630abc1
                                    [cmsa] => 1
                                )

                        )

                    [headers] => Symfony\Component\HttpFoundation\HeaderBag Object
                        (
                            [headers:protected] => Array
                                (
                                    [host] => Array
                                        (
                                            [0] => becalistyle.local
                                        )

                                    [accept] => Array
                                        (
                                            [0] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
                                        )

                                    [cookie] => Array
                                        (
                                            [0] => PHPSESSID=h43nlq33co85d36v3j6ih48ff7; p_m=5ad2594c8178ac39a0ee97bc5a54af308630abc1; cmsa=1
                                        )

                                    [user-agent] => Array
                                        (
                                            [0] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38
                                        )

                                    [accept-language] => Array
                                        (
                                            [0] => en-us
                                        )

                                    [dnt] => Array
                                        (
                                            [0] => 1
                                        )

                                    [accept-encoding] => Array
                                        (
                                            [0] => gzip, deflate
                                        )

                                    [x-forwarded-proto] => Array
                                        (
                                            [0] => https
                                        )

                                    [x-forwarded-port] => Array
                                        (
                                            [0] => 443
                                        )

                                    [x-forwarded-for] => Array
                                        (
                                            [0] => 127.0.0.1
                                        )

                                    [x-forwarded-host] => Array
                                        (
                                            [0] => becalistyle.local
                                        )

                                    [x-forwarded-server] => Array
                                        (
                                            [0] => becalistyle.local
                                        )

                                    [connection] => Array
                                        (
                                            [0] => Keep-Alive
                                        )

                                )

                            [cacheControl:protected] => Array
                                (
                                )

                        )

                    [content:protected] => 
                    [languages:protected] => 
                    [charsets:protected] => 
                    [encodings:protected] => 
                    [acceptableContentTypes:protected] => 
                    [pathInfo:protected] => 
                    [requestUri:protected] => 
                    [baseUrl:protected] => 
                    [basePath:protected] => 
                    [method:protected] => 
                    [format:protected] => 
                    [session:protected] => 
                    [locale:protected] => 
                    [defaultLocale:protected] => en
                )

            [response:protected] => Omnipay\PayPal\Message\ExpressAuthorizeResponse Object
 *RECURSION*
            [zeroAmountAllowed:protected] => 1
            [negativeAmountAllowed:protected] => 
        )

    [data:protected] => Array
        (
            [TIMESTAMP] => 2017-10-01T18:03:02Z
            [CORRELATIONID] => 40fd3b39250e0
            [ACK] => Failure
            [VERSION] => 119.0
            [BUILD] => 39073839
            [L_ERRORCODE0] => 10002
            [L_SHORTMESSAGE0] => Security error
            [L_LONGMESSAGE0] => Security header is not valid
            [L_SEVERITYCODE0] => Error
        )

)
Drew McLellan

Drew McLellan 2638 points
Perch Support

That does seem to confirm what I'm saying, yes.

its just so strange ... if I manually add PayPal Express Checkout (not using Perch's setup), I can get it to work just fine ... it doesn't return a token that validates, but I can at least see the checkout pop up, log into PayPal, etc ... so I'm not sure how to incorporate manually adding PayPal Checkout and have it complete the order.

Do you have any advice?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is the same occurring on your server?

Yes, both my testing server (my Mac at home) and the live/testing server on Dreamhost.