Can not initiate checkout page successfully using pay with amazon v2

87 views Asked by At

checkout page popup error image I am integrating pay with amazon button in angular application. Got error code but not error message. Cant understand whats going wrong.

Payload

this.payload = {
      "webCheckoutDetails": {
        "checkoutReviewReturnUrl": "environment.checkoutReviewReturnUrl"
      },
      "storeId": environment.awsClientId,
      "scopes": ["profile", "pin_codes", "phoneNumber"],
      "chargePermissionType": "Recurring",
      "recurringMetadata": {
        "frequency": {
          "unit": this.plan.NewPlan.Frequency,
          "value": this.plan.NewPlan.Frequency_Interval,
        },
        "amount": {
          "amount": this.plan.NewPlan.Price,
          "currencyCode": "USD"
        }
      }
    };

Button

amazon.Pay.renderButton('#AmazonPayButton', {
      // set checkout environment
      merchantId: environment.awsSellerId,
      publicKeyId: environment.publicKeyId,
      ledgerCurrency: 'USD',
      // customize the buyer experience
      checkoutLanguage: 'en_US',
      productType: 'PayOnly',
      placement: 'Cart',
      // configure Create Checkout Session request
      createCheckoutSessionConfig: {
        payloadJSON: JSON.stringify(this.payload),
        signature: this.signature,
        algorithm: this.algorithm
      }
    });

  }

FYI:Script and button is loaded successfully.

Update: I resolved the problem. My code has a server-side function that creates a signature. This function takes some time to finish, and the button was rendered before the signature. I fixed it by making sure the button is rendered after the signature is created.

0

There are 0 answers