Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: TS def XX_bank_account -> XX_bank_transfer #346

Merged

Conversation

hideokamoto-stripe
Copy link
Contributor

The API and document tell us using xx_bank_transfer string to the confirmCustomerBalancePayment method.
But this SDK shows the error when we using these values.

I think we need to these definition

Summary & motivation

When we want to use confirmCustomerBalancePayment method with TypeScript.
We got these errors:

TypeScript Error:

When we copy and paste this example code from the documents:
https://stripe.com/docs/payments/bank-transfers/accept-a-payment?platform=api#collect-payment-method-options

stripe.confirmCustomerBalancePayment(
  '{PAYMENT_INTENT_CLIENT_SECRET}',
  {
    payment_method: {
      customer_balance: {
      },
    },
    payment_method_options: {
      customer_balance: {
        funding_type: 'bank_transfer',
        bank_transfer: {
          type: 'eu_bank_transfer',
          eu_bank_transfer: {
            country: 'FR',
          }
        },
      },
    },
  },
  {
    handleActions: false,
  }
)

We got the TypeScript error:

./pages/payment_intents/index.tsx:55:23
Type error: Type '"eu_bank_transfer"' is not assignable to type '"us_bank_account" | "eu_bank_account" | "id_bank_account" | "gb_bank_account" | "jp_bank_account" | "mx_bank_account"'.

  53 |                     funding_type: 'bank_transfer',
  54 |                     bank_transfer: {
> 55 |                       type: 'eu_bank_transfer',
     |                       ^
  56 |                       eu_bank_transfer: {
  57 |                         country: 'FR',
  58 |                       }

> Build error occurred

API error:

I tried to update the code to allow the TypeScript error:

stripe.confirmCustomerBalancePayment(
  '{PAYMENT_INTENT_CLIENT_SECRET}',
  {
    payment_method: {
      customer_balance: {
      },
    },
    payment_method_options: {
      customer_balance: {
        funding_type: 'bank_transfer',
        bank_transfer: {
-          type: 'eu_bank_transfer',
+          type: 'eu_bank_account',
-          eu_bank_transfer: {
+          eu_bank_account: {
            country: 'FR',
          }
        },
      },
    },
  },
  {
    handleActions: false,
  }
)

Then, the Stripe API returned this error:


code: "parameter_unknown"
doc_url: "https://stripe.com/docs/error-codes/parameter-unknown"
message: "Received unknown parameter: payment_method_options[customer_balance][bank_transfer][eu_bank_account]. Did you mean eu_bank_transfer?"
param: "payment_method_options[customer_balance][bank_transfer][eu_bank_account]"

So, we may need to update the TypeScript definition to resolve the conflicts.

Thanks!

The API and document tell us using `xx_bank_transfer` string to the `confirmCustomerBalancePayment` method.
But this SDK shows the error when we using these values.

I think we need to  these definition
@martinalong-stripe
Copy link
Contributor

Whoops looks like there was a bit of confusion about who would merge this in! Amazing job catching this @hideokamoto-stripe.

I notice that the API ref for this also says "account" so I went ahead and messaged the owners of these docs to double check that these should indeed say "transfer" rather than "account". Once confirmed, I'll merge this in and they will correct the API ref.

@martinalong-stripe martinalong-stripe self-assigned this Oct 3, 2022
@alessandro-stripe
Copy link
Member

@martinalong-stripe hey there, xx_bank_account has been indeed deprecated in favour of xx_bank_transfer

@alessandro-stripe alessandro-stripe dismissed stale reviews from ghost and jackieosborn-stripe via 0e49edb October 20, 2022 08:15
Copy link
Member

@alessandro-stripe alessandro-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: This includes some values that haven't been GA'd are only accessible via gating and/or beta headers

@alessandro-stripe alessandro-stripe merged commit 9db86f7 into master Oct 21, 2022
@alessandro-stripe alessandro-stripe deleted the hideokamoto-stripe/fix-ts/bank-transfer-attributes branch October 21, 2022 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants