amzn / amazon-pay-sdk-samples

Amazon Pay SDK Sample Code
Apache License 2.0
43 stars 32 forks source link

Error handling code #9

Open webprogrammierer opened 7 years ago

webprogrammierer commented 7 years ago

I need simple error handling code for the follwing files (SampleCartDemo/OneTimePayments):

index.php
SetPaymentDetails.php
ConfirmPaymentAndAuthorize.php

e.g. here:

            onError: function (error) {
                // something bad happened
            }

The error code and the error text should be shown to the user and should be written to a file.

The user should be able to restart the pay process.

The AuthorizeResult should be examined and if there an AuthorizationStatus that tells us, that the payment was not successfull collectet, the user should not get his ordered goods.

So where I can find example code for all this error handling? Thank you.

bjguillot commented 7 years ago

The possible error codes that can invoke the onError callback function in the widgets are described at the following link: https://pay.amazon.com/us/developer/documentation/lpwa/201954960

I don't have any example code readily available that details how you would go about handling them. A lot of that would depend upon your specific implementation.

Handling declines is discussed in more detail at the following link: https://pay.amazon.com/us/developer/documentation/lpwa/201953810

An easy way to test decline scenarios is to use the special credit cards that have been pre-populated in your Sandbox test account. Test Sandbox accounts come with nine test credit cards. Four of the credit cards have a red asterisk next to them. These four cards will simulate different kinds of declines that you will need to handle in your implementation.

Sandbox Special Credit Cards (red asterisks): Visa...5656 - Simulate decline Authorize with TransactionTimedOut reason code Visa...4545 - Simulate PaymentMethodNotAllowed constraint Visa...2323 - Simulate decline Authorize with AmazonRejected reason code Visa...3434 - Simulate decline Authorize with InvalidPaymentMethod reason code

webprogrammierer commented 7 years ago

But everybody needs error handling and so this error handling example code IS NEEDED.

And I would prefer all this code not to be written in JQuery but in PHP instead, as you can read here: https://github.com/amzn/login-and-pay-with-amazon-sdk-samples/issues/10