feat(payments-plugin): Add multi currency support for braintree plugin #3239
+328
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: this PR has been remade, as it was originally branched off from master and made against master.
Description
As briefly described in #3218, this PR adds new feature to the core BraintreePlugin, extending the plugin options with an optional object named
merchantAccountIds
.merchantAccountId
, thegateway.clientToken.generate()
andgateway.transaction.sale()
. Both of these methods accept themerchantAccountId
with typestring | undefined
. To look up the correctmerchantAccountId
to use, we are using the activeorder.currencyCode
and the plugin options. I did not implement heavy input error checks as the plugin option validity is evaluated runtime thanks to typescript.clientToken
generation and relying on the braintree-drop-in UI client side. Thebraintree-dev-server
sets up an Order, logs info for the developer and exposes theshopClient
and generatedclientToken
for a test plugin found under/fixtures/braintree-checkout-test.plugin.ts
.<div id="result"/>
.nonce
generated by the client drop-in UI doesn't have fake-currency-mismatch-nonce test value. The drop-in UI in the browser has to be manually completed and the value sent to the vendure server. I think the development server introduced here helps a lot in this, but I'm open for suggestions to make complete e2e here.Possible improvement
I think it's not optimal to add the
merchantAccountId
values during plugin initialisation, this would be better off as args for the payment handler itself. But I would rather wait for the newstruct
type to create the currency-merchantAccountId pairs as handler arguments to make it bullet-proof.Breaking changes
As far as I'm concerned, there are none.
Checklist
📌 Always:
👍 Most of the time: