amzn / amazon-pay-sdk-samples

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

Seller Details not provided #8

Closed webprogrammierer closed 5 years ago

webprogrammierer commented 7 years ago

I testet the order process about hundred times and I can not find out why sometimes the seller details are not provided in Amazon Seller Central - Payment Details.

What could be the reason why sometimes the seller details are empty (not provided)? I am using the same code without changes.

Is this a browser cache problem? If so how to solve it?

I also found out that after the buyer loggs in and the shipping addresses and the payments methods are shown (for selection) after 3 seconds the payments methods are loaded again (you can see flash it).

I have 4 different test accounts for testing payments. I login with first acount and test the payment, then login with next account and test payment. Is this a probem?

This also happens in the demo example SampleCartDemo - OneTimePayments. Is this reloading the reason why sometimes the seller details are not provided in seller central?

What else could be a reason why seller details are not provided (the sourcecode is always the same): The session variables? The access token? What else? How to solve it? Thank you.

bjguillot commented 7 years ago

I'll need to investigate this further to get to the bottom of it for you.

Please submit a support case using the following link: https://sellercentral.amazon.com/gp/contact-us/contact-amazon-form.html

Be sure to select "Amazon Pay" and then "Amazon Pay Issues" to ensure your question is routed to the correct support queue.

webprogrammierer commented 7 years ago

Maybe the problem is located here:

   <script type="text/javascript">
        new OffAmazonPayments.Widgets.AddressBook({
            sellerId: "YOUR_MERCHANT_ID",
            onOrderReferenceCreate: function (orderReference) {
                /* make a call to the back-end that will set order reference details
                 * and get order reference details. This will set the order total
                 * to 19.95 and return order reference details.
                 *
                 * Get the AddressConsentToken to be sent to the API call
                 */
               var access_token = "";
                $.post("Apicalls/GetDetails.php", {
                    orderReferenceId: orderReference.getAmazonOrderReferenceId(),
                    addressConsentToken: access_token,
                }).done(function (data) {
                   $("#get_details_response").html(data);
                });
            },
            onAddressSelect: function (orderReference) {
            },
            design: {
                designMode: 'responsive'
            },
            onError: function (error) {
                // your error handling code
            }
        }).bind("addressBookWidgetDiv");
        new OffAmazonPayments.Widgets.Wallet({
            sellerId: "YOUR_MERCHANT_ID",
            onPaymentSelect: function (orderReference) {
            },
            design: {
                designMode: 'responsive'
            },
            onError: function (error) {
                // your error handling code
            }
        }).bind("walletWidgetDiv");
    </script>

I think the wallet widget is called BEFORE the results of $.post("Apicalls/GetDetails.php" are here.

This does not occur on every payment, but randomly again and again.

When I remove the calls for the addressbook widgets and move the call for $.post("Apicalls/GetDetails.php" into the wallet widget object call ( to omitt the addressbook widget for digial goods), then the problem (seller details not privided) disappears.

So the problem must be located in the code above! I think we need subsequent calls for "getdetails" and "addressbook widget", but here they seem to be not subsequent (asyonchronous javscript result on..events).

If you understand what I mean you can test it, reproduce it and solve it.

bjguillot commented 5 years ago

This issue was corrected in the update made to the SetPaymentDetails.php file back in August 2017. The original version of the file did not wrap the AddressBook widget inside a window.onAmazonPaymentsReady callback. That was likely leading to the issues you were observing relating to the load order. The current version should work properly.