#nck-flutter

1 messages ยท Page 1 of 1 (latest)

visual haven
#

Hey! Share as much context as possible

#

FYI, Flutter is a third-party library but will do my best to assist!

autumn osprey
#

Thank you ๐Ÿ™‚

#

So, Apple Pay works perfectly fine. But not Google Pay. This is what my payment configuration file looks like for Google Pay:

{
  "provider": "google_pay",
  "data": {
    "environment": "TEST",
    "apiVersion": 2,
    "apiVersionMinor": 0,
    "allowedPaymentMethods": [
      {
        "type": "CARD",
        "tokenizationSpecification": {
          "type": "PAYMENT_GATEWAY",
          "parameters": {
            "gateway": "stripe",
            "stripe:version": "2020-08-27",
            "stripe:publishableKey": "pk_test_xxx"
          }
        },
        "parameters": {
          "allowedAuthMethods": ["PAN_ONLY", "CRYPTOGRAM_3DS"],
          "allowedCardNetworks": ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "MIR", "VISA"],
          "billingAddressRequired": true,
          "billingAddressParameters": {
            "format": "FULL",
            "phoneNumberRequired": false
          }
        }
      }
    ],
    "merchantInfo": {
      "merchantId": "xxx",
      "merchantName": "xxx"
    },
    "transactionInfo": {
      "countryCode": "DE",
      "currencyCode": "EUR"
    }
  }
}

And the GooglePayButton of the pay package has a callback function, which returns the results for a successful token creation. So I am treating its result, I am naming it paymentSheetResult, like the following:

    final token =
        paymentSheetResult['paymentMethodData']['tokenizationData']['token'];
    final tokenJson = Map.castFrom(json.decode(token));

    PaymentMethodParams params = PaymentMethodParams.cardFromToken(
      token: tokenJson['id'],
      setupFutureUsage: PaymentIntentsFutureUsage.OffSession,
    );

    PaymentMethod paymentMethod = await Stripe.instance.createPaymentMethod(
      params,
    );

PaymentMethod and PaymentMethodParams are from the flutter_stripe package.

visual haven
#

I'd generally recommend against using createPaymentMethod directly

autumn osprey
autumn osprey
visual haven
#

Well, what are you actually trying to do here?

#

Is this part of a payment flow?

autumn osprey
#

Correct. We are saving payment methods for future and off-session usage. The result of the payment method creation is being sent to our API to attach a saved payment method to a customers profile that he later can choose from.

visual haven
#

payment method creation is being sent to our API to attach a saved payment method to a customers profile
You shouldn't really do that directly either

#

However not sure how that fits with the Flutter lib

autumn osprey
#

And this works perfectly well for Apple Pay. But for Google Pay I get this weird Card details not complete as soon as I try to create the payment method directly for Stripe.

visual haven
#

So if the customer later tries to pay with this saved payment method he may be prompted to confirm his choice and payment with 3DS.
That won't work with off-session payments though (they'll just error)

autumn osprey
visual haven
#

Well generally with wallets the auth is done when the user adds the card to their wallet