Git Product home page Git Product logo

Comments (4)

bjguillot avatar bjguillot commented on July 17, 2024

In the SetPaymentDetails.php file in the OneTimePayments example, you can remove the block of code including and between the lines:

new OffAmazonPayments.Widgets.AddressBook({
....
}).bind("addressBookWidgetDiv");

You can also remove this line:

<div id="addressBookWidgetDiv" style="width:400px; height:240px; display:inline-block;"></div>

That will remove the widget from your screen. You may need to do some additional code on the backend to remove references to shipping address, including no longer needing to pass the AddressConsentToken (or AccessToken) to the backend.

Try these things and let us know if you have any questions.

from amazon-pay-sdk-samples.

webprogrammierer avatar webprogrammierer commented on July 17, 2024

You want to remove all these lines of code:

        new OffAmazonPayments.Widgets.AddressBook({
            sellerId: "xxx",
            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");

So the $.post("Apicalls/GetDetails.php", { is also removed and then nothing works anymore.

There are so many problems here. Why is nobody here who can support people who want to implement amazon pay?

from amazon-pay-sdk-samples.

bjguillot avatar bjguillot commented on July 17, 2024

OK, I looked into and see my omission.

The onOrderReferenceCreate callback needs to be moved to the Wallet Widget, i.e., so this part:

        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);
            });
        },

Needs to be inserted after the lines

 new OffAmazonPayments.Widgets.Wallet({
        sellerId: "SELLER_ID",

You only want to have one widget that uses the onOrderReferenceCreate callback, and since we removed the AddressBook widget, we need to move it to the Wallet widget.

Sorry for not mentioning that originally.

There are some other optimizations you can do for digital only goods, such as removing the payments:shipping_address portion of the scope from the index.html file.

from amazon-pay-sdk-samples.

webprogrammierer avatar webprogrammierer commented on July 17, 2024

Thank you. I have already find that out by myself.

from amazon-pay-sdk-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.