Repository navigation
fix: update pay button amount when paymentConfig changes - #49
Merged
AbdulazizAlrabiah merged 1 commit intoNov 26, 2026
Merged
Conversation
The CreditCard and STC Pay pay buttons cached the formatted amount in a module-level variable, so changing paymentConfig.amount or currency while the view was mounted kept showing the first amount, while the payment used the new one. Format the amount from the current props on each render. Fixes moyasar#48 Co-Authored-By: Claude Opus 5.5 <[email protected]>
AbdulazizAlrabiah
self-requested a review
November 12, 2026 19:35
AbdulazizAlrabiah
approved these changes
Nov 22, 2026
Collaborator
|
Thank you Husnain! LGTM |
sultan-algarbi
approved these changes
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #48
Problem
The
CreditCardandStcPaypay buttons cached the formatted amount in a module-level variable the first time they rendered. WhenpaymentConfig.amountorpaymentConfig.currencychanged while the view stayed mounted, the button kept showing the first amount, while the payment request used the new one (e.g. "Pay $10.00" shown, $15.00 charged). SAR was not affected.Changes
src/views/credit_card.tsx: remove theformattedAmountcache and its unmount reset; format the amount from the currentpaymentConfigon each render.src/views/stc_pay/stc_pay_phone_number.tsx: same change (this cache was never reset).src/__tests__/views/).@testing-library/react-nativeand[email protected](matchingreact) as dev dependencies, since there were no view tests before.Testing
main(3/3) and pass with this change (3/3):yarn test: 219/219 passingyarn typecheck: passingyarn lint: 0 errors (no new warnings)yarn prepare: passing