Skip to content

Commit

Permalink
Merge branch 'main' into fix/wallets-in-tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Sep 20, 2024
2 parents e1dbc15 + a52ad3a commit 6aa1156
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 62 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [0.88.3](https://github.com/juspay/hyperswitch-web/compare/v0.88.2...v0.88.3) (2024-09-20)


### Bug Fixes

* added suspense and error boundary for apple pay and google pay in tabs ([#632](https://github.com/juspay/hyperswitch-web/issues/632)) ([209f8e9](https://github.com/juspay/hyperswitch-web/commit/209f8e96be744c4c49e05c10700d839e3dd957f3))

## [0.88.2](https://github.com/juspay/hyperswitch-web/compare/v0.88.1...v0.88.2) (2024-09-20)


### Reverts

* chunk loading issue - 1 ([#623](https://github.com/juspay/hyperswitch-web/issues/623)) ([#631](https://github.com/juspay/hyperswitch-web/issues/631)) ([f719ff5](https://github.com/juspay/hyperswitch-web/commit/f719ff5472bd844125c97eae412c3afa1ec114ed))

## [0.88.1](https://github.com/juspay/hyperswitch-web/compare/v0.88.0...v0.88.1) (2024-09-20)


### Bug Fixes

* Invalid shipping address and taxjar api failing case handle in apple pay ([#628](https://github.com/juspay/hyperswitch-web/issues/628)) ([d4f3c41](https://github.com/juspay/hyperswitch-web/commit/d4f3c41ff3ccc1253f4c19613ead0be60cd98fc3))

# [0.88.0](https://github.com/juspay/hyperswitch-web/compare/v0.87.2...v0.88.0) (2024-09-17)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.88.0",
"version": "0.88.3",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
28 changes: 16 additions & 12 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -330,24 +330,28 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
| ApplePay =>
switch applePayToken {
| ApplePayTokenOptional(optToken) =>
<ApplePayLazy sessionObj=optToken walletOptions paymentType />
<ReusableReactSuspense loaderComponent={loader()} componentName="ApplePayLazy">
<ApplePayLazy sessionObj=optToken walletOptions paymentType />
</ReusableReactSuspense>
| _ => React.null
}
| GooglePay =>
<SessionPaymentWrapper type_={Wallet}>
{switch gPayToken {
| OtherTokenOptional(optToken) =>
switch googlePayThirdPartyToken {
| GooglePayThirdPartyTokenOptional(googlePayThirdPartyOptToken) =>
<GPayLazy
sessionObj=optToken
thirdPartySessionObj=googlePayThirdPartyOptToken
walletOptions
paymentType
/>
| _ =>
<GPayLazy sessionObj=optToken thirdPartySessionObj=None walletOptions paymentType />
}
<ReusableReactSuspense loaderComponent={loader()} componentName="GPayLazy">
{switch googlePayThirdPartyToken {
| GooglePayThirdPartyTokenOptional(googlePayThirdPartyOptToken) =>
<GPayLazy
sessionObj=optToken
thirdPartySessionObj=googlePayThirdPartyOptToken
walletOptions
paymentType
/>
| _ =>
<GPayLazy sessionObj=optToken thirdPartySessionObj=None walletOptions paymentType />
}}
</ReusableReactSuspense>
| _ => React.null
}}
</SessionPaymentWrapper>
Expand Down
2 changes: 2 additions & 0 deletions src/PaymentElementRenderer.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ let make = (
: <PaymentElement cardProps expiryProps cvcProps paymentType />
}
}

let default = make
2 changes: 1 addition & 1 deletion src/PaymentElementRenderer.resi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@react.component
let make: (
let default: (
~paymentType: CardThemeType.mode,
~cardProps: CardUtils.cardProps,
~expiryProps: CardUtils.expiryProps,
Expand Down
1 change: 1 addition & 0 deletions src/PaymentElementRendererLazy.res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let make = React.lazy_(() => Js.import(PaymentElementRenderer.default))
4 changes: 2 additions & 2 deletions src/RenderPaymentMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ let make = (
? <WalletShimmer />
: <PaymentElementShimmer />}
</RenderIf>}
componentName="PaymentElementRenderer">
<PaymentElementRenderer paymentType cardProps expiryProps cvcProps />
componentName="PaymentElementRendererLazy">
<PaymentElementRendererLazy paymentType cardProps expiryProps cvcProps />
</ReusableReactSuspense>
| CardNumberElement =>
<InputField
Expand Down
70 changes: 37 additions & 33 deletions src/Utilities/ApplePayHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -127,40 +127,44 @@ let startApplePaySession = (
~clientSecret,
~paymentMethodType,
)
->then(response => {
let taxCalculationResponse = response->taxResponseToObjMapper
let (netAmount, ordertaxAmount, shippingCost) = (
taxCalculationResponse.net_amount,
taxCalculationResponse.order_tax_amount,
taxCalculationResponse.shipping_cost,
)
let newTotal: lineItem = {
label: "Net Amount",
amount: netAmount->Float.toString,
\"type": "final",
}
let newLineItems: array<lineItem> = [
{
label: "Bag Subtotal",
amount: (netAmount -. ordertaxAmount -. shippingCost)->Float.toString,
\"type": "final",
},
{
label: "Order Tax Amount",
amount: ordertaxAmount->Float.toString,
\"type": "final",
},
{
label: "Shipping Cost",
amount: shippingCost->Float.toString,
\"type": "final",
},
]
let updatedOrderDetails: updatedOrderDetails = {
newTotal,
newLineItems,
->thenResolve(response => {
switch response->taxResponseToObjMapper {
| Some(taxCalculationResponse) => {
let (netAmount, ordertaxAmount, shippingCost) = (
taxCalculationResponse.net_amount,
taxCalculationResponse.order_tax_amount,
taxCalculationResponse.shipping_cost,
)
let newTotal: lineItem = {
label: "Net Amount",
amount: netAmount->minorUnitToString,
\"type": "final",
}
let newLineItems: array<lineItem> = [
{
label: "Bag Subtotal",
amount: (netAmount - ordertaxAmount - shippingCost)->minorUnitToString,
\"type": "final",
},
{
label: "Order Tax Amount",
amount: ordertaxAmount->minorUnitToString,
\"type": "final",
},
{
label: "Shipping Cost",
amount: shippingCost->minorUnitToString,
\"type": "final",
},
]
let updatedOrderDetails: updatedOrderDetails = {
newTotal,
newLineItems,
}
ssn.completeShippingContactSelection(updatedOrderDetails)
}
| None => ssn.abort()
}
ssn.completeShippingContactSelection(updatedOrderDetails)->resolve
})
->ignore
}
Expand Down
22 changes: 11 additions & 11 deletions src/Utilities/TaxCalculation.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ open Utils

type calculateTaxResponse = {
payment_id: string,
net_amount: float,
order_tax_amount: float,
shipping_cost: float,
net_amount: int,
order_tax_amount: int,
shipping_cost: int,
}

let taxResponseToObjMapper = resp => {
let responseDict = resp->getDictFromJson
let displayAmountDict = responseDict->getDictFromDict("display_amount")
{
payment_id: responseDict->getString("payment_id", ""),
net_amount: displayAmountDict->getFloat("net_amount", 0.0),
order_tax_amount: displayAmountDict->getFloat("order_tax_amount", 0.0),
shipping_cost: displayAmountDict->getFloat("shipping_cost", 0.0),
}
resp
->JSON.Decode.object
->Option.map(dict => {
payment_id: dict->getString("payment_id", ""),
net_amount: dict->getInt("net_amount", 0),
order_tax_amount: dict->getInt("order_tax_amount", 0),
shipping_cost: dict->getInt("shipping_cost", 0),
})
}

let calculateTax = (
Expand Down
2 changes: 2 additions & 0 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -1377,3 +1377,5 @@ let getFirstAndLastNameFromFullName = fullName => {
}

let checkIsTestCardWildcard = val => ["1111222233334444"]->Array.includes(val)

let minorUnitToString = val => (val->Int.toFloat /. 100.)->Float.toString

0 comments on commit 6aa1156

Please sign in to comment.