Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
The transactionTimeout format has to be number.
Browse files Browse the repository at this point in the history
I tried passing .withTransactionTimeout('0') as a string, and the ChargeAPI returns the error below. 
so, I guess that transactionTimeout has to be passed as a number to resolve the error. (At least, that was my solution to solve the error.)

```
"request": {
            "type": "Connections.Response",
            "requestId": "amzn1.echo-api.request.d313d5f4-3e73-4e17-9d3b-3bb7bb4c63a4",
            "timestamp": "2021-11-23T06:04:58Z",
            "locale": "ja-JP",
            "status": {
                "code": "400",
                "message": "Connections validation failed. Violating fields in payload: [payload.authorizeAttributes.transactionTimeout]."
            },
            "name": "Charge",
            "token": "token"
        }
```

ORIGINAL CODE:
```
  const payloadBuilder = AmazonPay.chargePayload(/* version */ "2")
    .withBillingAgreementId(session.billingAgreementDetails?.billingAgreementId)
    .withCurrency("JPY")
    .withSellerId(process.env["AMAZONPAY_SELLER_ID"])
    .withTransactionTimeout(0)
    .withPaymentAction(PaymentAction.AUTHORIZE)
    .withAmount(`${totalAmount}`)
    .withAuthorizationReferenceId("" + Date.now())
    .withSellerOrderId(generateSellerOrderId())
    .withCustomInformation(getCustomerInformationToCsv(session));
```

PayLoadResult:
```
{
    "name": "Charge",
    "payload": {
        "@type": "ChargeAmazonPayRequest",
        "@Version": "2",
        "billingAgreementId": "C03-2822209-5606699",
        "paymentAction": "AUTHORIZE",
        "sellerId": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
        "authorizeAttributes": {
            "@type": "AuthorizeAttributes",
            "@Version": "2",
            "authorizationAmount": {
                "@type": "Price",
                "@Version": "2",
                "amount": "350",
                "currencyCode": "JPY"
            },
            "authorizationReferenceId": "1637647498489",
            "transactionTimeout": "0"   // <- has to be a number and not a string.
        },
        "sellerOrderAttributes": {
            "@type": "SellerOrderAttributes",
            "@Version": "2",
            "customInformation": "XXXX,XXXXX,XXXXX,XXXX,XXXXXX",
            "sellerOrderId": "alexa-1637647498489"
        }
    },
    "token": "token",
    "type": "Connections.SendRequest"
}
```
  • Loading branch information
johna1203 committed Nov 23, 2021
1 parent 4668ffd commit b42f5a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/checkout/charge/AuthorizeAttributesBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ export class AuthorizeAttributesBuilder {
return this.withSoftDescriptor(softDescriptor);
}

public withTransactionTimeout(transactionTimeout: string): AuthorizeAttributesBuilder {
public withTransactionTimeout(transactionTimeout: number): AuthorizeAttributesBuilder {
this.needsoptionalAuthAttributes = true;
this.transactionTimeout = transactionTimeout;
return this;
}

public setTransactionTimeout(transactionTimeout: string): AuthorizeAttributesBuilder {
public setTransactionTimeout(transactionTimeout: number): AuthorizeAttributesBuilder {
return this.withTransactionTimeout(transactionTimeout);
}

Expand Down

0 comments on commit b42f5a4

Please sign in to comment.