3

I'm trying to integrate Amazon Payments (Payment only, not login with Amazon) into my site.

I can successfully display the authentication form for the payment:

<div id="AmazonPayButton" />
          @{
              var callbackurl = string.Format("{0}://{1}/Account/AmazonConfirm", Request.Url.Scheme, Request.Url.Authority);
           }
           <script type="text/javascript">
               OffAmazonPayments.Button("AmazonPayButton", "M_MYSELLERID_1234567", {
                   type: "PwA",
                   size: "medium",
                   authorization: function() {
                      loginOptions =
                           {scope: "payments:widget", popup: true };
                      authRequest = amazon.Login.authorize(loginOptions, "@(callbackurl)");
                   },
                   onError: function(error) {
                        alert('We could not connect to Amazon to process your payment, try again later');
                   }
              });
      </script>
</div>

Amazon successful redirects to my callback URL after authentication. But when I try to display the wallet widget with the Same Seller ID, I get an "invalid seller ID" error:

<div id="walletWidgetDiv">
    </div>
    <script>
        new OffAmazonPayments.Widgets.Wallet({
            sellerId: 'M_MYSELLERID_1234567',
            onReady: function(billingAgreement) {
                var billingAgreementId = billingAgreement.getAmazonBillingAgreementId();
            },
            agreementType: 'BillingAgreement',
            design: {
                size : {width:'400px', height:'260px'}
            },
            onPaymentSelect: function(billingAgreement) {
                // Replace this code with the action that you want to perform
                // after the payment method is selected.
            },
            onError: function(error) {
                alert(error.getErrorMessage());
            }
      }).bind("walletWidgetDiv");
    </script>

enter image description here

Why would the authentication work, only to have the Wallet display rejected?

Update @Brent Douglas in his answer triggered me to recheck my seller ID and I had specified an incorrect ID in one of my script references. Now I get the following error:

"the seller ID is not in the appropriate state to execute the request"

Not sure what that means. I checked my account and the deposit/banking info is specified, and nothing else is flagged on the Integration Settings page. Is there anything else in the account that needs to be added/verified? (Other than the typical, web page URL and other info)

Mike Marshall
  • 7,788
  • 4
  • 39
  • 63
  • looking at [this](https://payments.amazon.com/developer), on the wallet tab... where do you have the top part defined? – gloomy.penguin Oct 21 '14 at 15:32
  • also... [starting on page 19](https://images-na.ssl-images-amazon.com/images/G/02/mwsportal/doc/en_US/offamazonpayments/AmazonPaymentsAdvancedIntegrationGuide.pdf) this has more details about the process than I found anywhere else online so far. Sometimes errors aren't exactly spot on, it could be some other info missing, too. – gloomy.penguin Oct 21 '14 at 15:39
  • Are you in a sand box? – Abkarino Oct 21 '14 at 16:27
  • @gloomy.penguin I do have that part defined, just left it out, will recheck the docs you linked – Mike Marshall Oct 21 '14 at 16:45
  • @Abkarino yes, in sandbox mode – Mike Marshall Oct 21 '14 at 16:45
  • @gloomy.penguin triple-checked and all the script references are there per the examples. I read the docs and there are no attributes/script code missing that I can tell – Mike Marshall Oct 21 '14 at 17:00

2 Answers2

2

You need to log in to your Seller Central account, make sure "Amazon Payments Advanced" is selected in the drop-down at the top, click "Settings" in the upper right, then "Integration Settings". On this page you will see "Your Merchant ID". This is your Seller ID. Replace M_MYSELLERID_1234567 with this seller ID everywhere.

Assuming you are using the correct seller ID you also need to make sure you are including the following in your handle login page where you display the wallet widget.

<!-- since you are using 'popup' -->
<script type='text/javascript'>
    window.onAmazonLoginReady = function () {
        amazon.Login.setClientId('[YOUR_CLIENT_ID]');
        amazon.Login.setUseCookie(true);
    };
</script>

You then need to include the Widgets.js file.

For sandbox mode you would use this.

<script src='https://static-na.payments-amazon.com/OffAmazonPayments/us/sandbox/js/Widgets.js'></script>

For production you would use this.

<script src='https://static-na.payments-amazon.com/OffAmazonPayments/us/js/Widgets.js'></script>
Brent D.
  • 543
  • 2
  • 7
  • I think he just put those to hide his personal information!! – Abkarino Oct 21 '14 at 17:14
  • well he is actually half right, I was using the wrong seller ID. I followed the instructions for the integration settings and now I am using the "Merchant ID" from that page. I am getting a different error now, so I have updated the question – Mike Marshall Oct 21 '14 at 20:49
  • This usually means something is wrong with your account. In Seller Central click "Settings" > "Account Info". in the "Product Status" section it should tell you what needs to be corrected. – Brent D. Oct 21 '14 at 21:16
  • It says "Inactive. You can transact in the Sandbox environment only. Please refer to your account verification status or contact seller support." But I'm in sandbox mode for testing, shouldn't it work? – Mike Marshall Oct 22 '14 at 03:32
  • 1
    Follow-up: so there were two problems 1) A single script link I had contained the wrong seller ID 2) The "invalid account state" issue was a bad cut-and-paste and I was using the production script URL instead of the sandbox. Thanks for the help – Mike Marshall Oct 22 '14 at 14:55
0

I searched around with the same exact error and I found this link.

Which suggest "You need to use SandBox credentials for Amazon Payments. "

Check this link.

Abkarino
  • 1,426
  • 1
  • 12
  • 19