- Issue created by @valic
- @valic opened merge request.
- 🇭🇷Croatia valic Osijek
We should have an agnostic determination of which merchant id needs to be used outside of payment forms or 3DS pane review and not make BC if not required.
The current state of the change is as follows:
- no breaking changes - no new methods or alteration of existing ones
- no changes for any of the payment method forms
- inside method generateClientToken resolve merchantAccountId by current store currency by default, and if we are on order route (aka checkout) resolve per order currency route than)We need to resolve this per current store currency for offsite card authorization when no order is attached to the payment.
- Status changed to Needs review
over 1 year ago 1:29pm 19 April 2023 - 🇭🇷Croatia valic Osijek
Per internal discussion, we are now passing currency to map it on the corresponding merchant id.
There is one method to fallback to store if the currency is not passed as on the user payment methods tab where there is no order
protected function getMerchantId($currency_code = NULL) { // Fallback to current store. if (empty($currency_code)) { $currency_code = $this->currentStore->getStore()->getDefaultCurrencyCode(); } if (empty($this->configuration['merchant_account_id'][$currency_code])) { throw new InvalidRequestException(sprintf('No merchant account ID configured for currency %s', $currency_code)); } return $this->configuration['merchant_account_id'][$currency_code]; }
We are missing that ability only during payment method creation in "doCreatePaymentMethod" when we have an active order but no ability to fetch currency. So we fallback to store by logic from getMerchantId
- Status changed to Needs work
over 1 year ago 12:31pm 29 May 2023 - 🇮🇱Israel jsacksick
Left several comments in the MR, some changes are required before merging this.
- Status changed to Needs review
over 1 year ago 2:50pm 5 July 2023 - 🇭🇷Croatia valic Osijek
@jsacksick we show same error message for outside of checkout scenario
- 🇭🇷Croatia valic Osijek
To sum up the changes.
The token is generated based on order currency or fallback to the current store default currency (in cases when the customer is not on the order route)
During checkout, the currency is pulled from the current order.We have a change in method \Drupal\commerce_braintree\Plugin\Commerce\PaymentGateway\HostedFieldsInterface::generateClientToken
which not sure we treat as BC, but we probably should. Even payments would work without passing $currency_code for most; custom code should be reviewed.If for currency payment gateway is missing merchant_id during checkout on the user payment page, we return this error gracefully.
-
jsacksick →
committed 4f547601 on 8.x-1.x authored by
valic →
Issue #3345876: Allow specifying merchant id when generating client...
-
jsacksick →
committed 4f547601 on 8.x-1.x authored by
valic →
- Status changed to Fixed
over 1 year ago 1:09pm 11 July 2023 Automatically closed - issue fixed for 2 weeks with no activity.