paypal / here-sideloader-api-samples

Sideloader API samples that enable to integrate PayPal Here into other apps
Other
24 stars 32 forks source link

Transaction Cancelled upon pin entry #65

Closed glennmurley15 closed 6 years ago

glennmurley15 commented 6 years ago

Hi, Written a code sample to sideload a payment into PPH, and anytime I sideload, after pin entry, I get "Transaction cancelled", then the PPH app sends decline response to my app.

(All code in JS - cordova)


var invoice = {
    "paymentTerms": "DueOnReceipt",
    "discountPercent": "0",
    "currencyCode": "GBP",
    "payerEmail": "customer@domain.co.uk",
    "itemList": {
        "item": [
            {
                "taxRate": "0",
                "name": "Item Name",
                "description": "Item Description",
                 "unitPrice": "1.99",
                 "quantity": "1"
             },
             {
                "taxRate": "0",
                "name": "Item Two",
                "description": "Item Two Description",
                "unitPrice": "2.99",
                "quantity": "1"
            }
        ]
    }
};

var invoiceStr = Base64.encode(JSON.stringify(invoice));

var url = 'paypalhere://takePayment?';
url = url.concat('accepted=card,paypal');
url = url.concat('&returnUrl=');
url = url.concat(encodeURIComponent('myapp://takePayment/Result?Status={result}&Type={Type}&InvoiceId={InvoiceId}&Total={GrandTotal}'));
url = url.concat('&as=b64');
url = url.concat('&step=choosePayment');
url = url.concat('&payerPhone=441617971234');
url = url.concat('&invoice='+encodeURIComponent(invoiceStr));

window.open(url, '_self', 'location=no');
glennmurley15 commented 6 years ago

After many hours of debugging, and reading the docs a thousand times, I spotted that I removed the tax name but not the tax rate. Docs say if you use one, you must use both.

However, new issue, On payment decline and success, the return URL comes back the same, with no type value at all (completely empty), but returns Number and GrandTotal everytime. I have tried many different formats for URL (because the docs specify an extra question mark after the result placeholder? and makes no difference if I include it or not)

url = url.concat(encodeURIComponent('myapp://takePayment/?{result}?Type={Type}&tx={Number}&total={GrandTotal}')); url = url.concat(encodeURIComponent('myapp://takePayment/?{result}Type={Type}&tx={Number}&total={GrandTotal}')); url = url.concat(encodeURIComponent('myapp://takePayment/?Type={Type}&tx={Number}&total={GrandTotal}'));

DJ92 commented 6 years ago

Hey @glennmurley15 , as per my knowledge and the here-sideloader-sample repo, the type=UNKNOWN is returned on all declines. For success scenarios, it comes back with the type of sale CARD, CASH, etc. and this was fixed in the latest PPH App Release. Let me know if you're still facing the issue.

Thanks!

glennmurley15 commented 6 years ago

Both success and decline return to this URL (first is decline) Notice how the parameter Type is completely empty.

myapp://takePayment/??Type=&tx=2018-10-17-2014-1108&total=4.2 myapp://takePayment/??Type=&tx=2018-10-17-2016-1108&total=1.05

This behaviour is the same, even if I don't include {result}?

This is using PPH app v3.3.1 (331000)

DJ92 commented 6 years ago

Hey @glennmurley15, our new version v3.4.0 is currently being throttled out. It should have the fix you are looking for. Thanks for your patience.

glennmurley15 commented 6 years ago

Just reloaded app store, and v3.4.0 is available. Same behaviour after update.

Empty Type value.

DJ92 commented 6 years ago

Hey @glennmurley15 , thanks for raising this. Success does come back with Type=CARD. We're working on declines and should be fixed with our upcoming app release. Apologize for any inconvenience caused.

glennmurley15 commented 6 years ago

After a couple of days of installing 3.4.0 it has started returning Type=Card

I am guessing the app has microsoft codepush integrated as it was definitely returning empty type after the initial update, and something has been tweaked and pushed remotely.

Since it started returning Type=Card the behaviour has been consistent during use, so I am happy to close the issue and confirm it as fixed.

DJ92 commented 6 years ago

Thanks! Glad it worked @glennmurley15