[Google Pay] createPaymentRequest results in PaymentError

未關閉
#28 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
30/100
Issue 類型
缺陷
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
typescript
領域
mobile, payments

研究方向

Start at GooglePayButton.createPaymentRequest and compare the supplied options with the Google Pay example, focusing on the PaymentError statusCode 10. Reproduce the call with the listed NativeScript, Google Pay, Stripe, and Android settings, then verify that the payment sheet appears instead of immediately invoking PaymentError.

由索引模型根據 Issue 內容生成。

描述

I'm basically following the Google Pay example in a Vue app. Calling createPaymentRequest on the GooglePayButton object immediately results in the PaymentError handler being called, with statusCode 10 and statusMessage "10: ". I don't see any other error information being returned. The Google Pay sheet does not appear.
Using "@nativescript/core": "^8.5.6", "@nativescript/google-pay": "^0.1.2"

async onGooglePayTap(args) {
      try {
        if (global.isAndroid) {
          const googlePayBtn = args.object;

          // setup the event listeners
          googlePayBtn.once(GooglePayEvents.PaymentCancelled, (args) => {
            console.log("payment cancelled, not much to do here");
          });

          googlePayBtn.once(GooglePayEvents.PaymentSuccess, async (args) => {
            console.log("PaymentSuccess");
            // this is where you handle the response with the token from google pay to send to payment provider
            const payloadToBackend = {
              amount: 25.2,
              method: "3DS",
              "3DS": {
                signature:
                  args.data.paymentMethodData.tokenizationData.token.signature,
                type: "G", // for Google
                version:
                  args.data.paymentMethodData.tokenizationData.token
                    .protocolVersion,
                data: args.data.paymentMethodData.tokenizationData.token
                  .signedMessage,
              },
            };

            // send your payload to your payment provider here
            // const result = await this.someHttpMethodToYourProviderBackend(payloadToBackend);

            if (result) {
              // now show the user the confirmation screen
            } else {
              // show the user that something went wrong here
            }
          });

          googlePayBtn.once(GooglePayEvents.PaymentError, (args) => {
            console.log("PaymentError");
            console.dir(args, { depth: null });
            // TODO: let user know some error happened
          });

          const options = {
            environment: "development",
            theme: "light",
            merchantInfo: {
              merchantName: "Test Merchant",
            },
            allowedPaymentMethods: {
              type: AllowedPaymentMethodsType.CARD,
              parameters: {
                allowPrepaidCards: true,
                allowCreditCards: true,
                billingAddressRequired: true,
                billingAddressParameters: {
                  format: BillingAddressParametersFormat.MIN,
                  phoneNumberRequired: true,
                },
              },
              tokenizationSpecification: {
                type: TokenizationSpecificationType.PAYMENT_GATEWAY,
                parameters: {
                  gateway: "stripe",
                  "stripe:version": "2018-10-31",
                  "stripe:publishableKey":
                    "redacted",
                },
              },
            },
            transactionInfo: {
              currencyCode: "USD",
              countryCode: "US",
              transactionId: "283999292929929", // A unique ID that identifies a transaction attempt. Merchants can use an existing ID or generate a specific one for Google Pay transaction attempts. This field is required when you send callbacks to the Google Transaction Events API.
              totalPriceStatus: TotalPriceStatusValue.FINAL,
              totalPrice: 25.2,
              totalPriceLabel: "Total",
              checkoutOption: CheckoutOptionValue.DEFAULT,
            },
            emailRequired: true,
            shippingAddressRequired: true,
            shippingAddressParameters: {
              allowedCountryCodes: ["US"],
              phoneNumberRequired: true,
            },
          };

          // this creates the payment request to the Google Pay SDK and will present the user with the payment sheet to complete the transaction

          googlePayBtn.createPaymentRequest(options).catch((err) => {
            console.log("error with create payment request", err);
          });
          console.log("created payment request");
        }
      } catch (error) {
        console.log("Error with google pay", error);
      }
    },
主要語言
TypeScript
星號
35
分支
13
PR 合併指標
30 天內沒有已合併 PR

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

NativeScript/payments 的其他 Issue

查看 NativeScript/payments 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。