Skip to content

Commit

Permalink
fix: gpay unified checkout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ImSagnik007 committed Oct 30, 2024
1 parent b6bf372 commit a74438c
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -952,31 +952,30 @@ let make = (
)->then(resp => {
switch resp->TaxCalculation.taxResponseToObjMapper {
| Some(taxCalculationResponse) => {
let updatePaymentRequest =
[
(
"newTransactionInfo",
[
(
"countryCode",
shippingAddress.countryCode->JSON.Encode.string,
),
(
"currencyCode",
transactionInfo
->getString("currency_code", "")
->JSON.Encode.string,
),
("totalPriceStatus", "FINAL"->JSON.Encode.string),
(
"totalPrice",
taxCalculationResponse.net_amount
->minorUnitToString
->JSON.Encode.string,
),
]->getJsonFromArrayOfJson,
),
]->getJsonFromArrayOfJson
let updatePaymentRequest = [
(
"newTransactionInfo",
[
(
"countryCode",
shippingAddress.countryCode->JSON.Encode.string,
),
(
"currencyCode",
transactionInfo
->getString("currency_code", "")
->JSON.Encode.string,
),
("totalPriceStatus", "FINAL"->JSON.Encode.string),
(
"totalPrice",
taxCalculationResponse.net_amount
->minorUnitToString
->JSON.Encode.string,
),
]->getJsonFromArrayOfJson,
),
]->getJsonFromArrayOfJson
updatePaymentRequest->resolve
}
| None => JSON.Encode.null->resolve
Expand All @@ -986,16 +985,23 @@ let make = (
JSON.Encode.null->resolve
}
}
let gPayClient = GooglePayType.google(
let gpayClientRequest = if componentType->getIsExpressCheckoutComponent {
{
"environment": publishableKey->String.startsWith("pk_prd_")
? "PRODUCTION"
: "TEST",
"paymentDataCallbacks": {
"onPaymentDataChanged": onPaymentDataChanged,
},
}->Identity.anyTypeToJson,
)
}->Identity.anyTypeToJson
} else {
{
"environment": publishableKey->String.startsWith("pk_prd_")
? "PRODUCTION"
: "TEST",
}->Identity.anyTypeToJson
}
let gPayClient = GooglePayType.google(gpayClientRequest)

gPayClient.isReadyToPay(payRequest)
->then(res => {
Expand Down

0 comments on commit a74438c

Please sign in to comment.