Open aednzxy opened 2 years ago
I would love to get this integrated (so I do not have to copy paste all your lovely code). My problem is that I am not competent enough to write the tests you ask for above without some hints of what you would need to be satisfied. Please advise so this can be integrated :)
@whiteancient take a look at the tests in this block: https://github.com/bennypowers/stripe-elements/blob/1a4033cdfe5669a6e50cadd030847912bd0e8c5b/test/stripe-elements.test.ts#L277 An example would be this test that asserts that a stripe element with a valid PK, and a completed form, and generate="payment-method"
eventually gets a payment method object
https://github.com/bennypowers/stripe-elements/blob/1a4033cdfe5669a6e50cadd030847912bd0e8c5b/test/stripe-elements.test.ts#L805-L812
You'll need to add the relevant methods to this mocked stripe.js object: https://github.com/bennypowers/stripe-elements/blob/1a4033cdfe5669a6e50cadd030847912bd0e8c5b/test/mock-stripe/index.ts and maybe some test helpers a la https://github.com/bennypowers/stripe-elements/blob/1a4033cdfe5669a6e50cadd030847912bd0e8c5b/test/test-helpers.ts#L504-L508
Is this still relevant?
The motivation behind this PR is to allow support for direct charges against connected accounts. To do this, we must pass in the stripeAccount attribute to the StripeConstructorOptions parameter when initialising stripe-js.
This PR adds an additional, optional attribute
stripe-account
, allowing the user to provide the ID of the connected account they wish to make charges against.This is supported both when initialising either via window.Stripe or loadStripe, both methods accept a StripeConstructorOptions parameter after publishableKey. This is where we set the stripe-account attribute that is passed to the web component.
See example of loading stripe elements with stripeAccount attribute: https://stripe.com/docs/connect/creating-a-payments-page?platform=web&ui=elements#set-up-stripe-elements
When this value is set, the stripe library sets the
stripe-account
header on corresponding requests. It only needs to be set when we initialise stripe js, the rest is handled by stripe's library.