Skip to content

Commit

Permalink
fix: HS-183: ApplePay Payment Request to take client's country in cas…
Browse files Browse the repository at this point in the history
…e session sends null (#78)

Co-authored-by: arun.mishra <arun.mishra@juspay.in>
  • Loading branch information
arun-mi and arun.mishra committed Dec 21, 2023
1 parent 06b3f3e commit 2ee7afc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Types/ApplePayTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ type paymentRequestData = {
}

let jsonToPaymentRequestDataType: Js.Dict.t<Js.Json.t> => paymentRequestData = jsonDict => {
let clientTimeZone = CardUtils.dateTimeFormat(.).resolvedOptions(.).timeZone
let clientCountry = Utils.getClientCountry(clientTimeZone)
let defaultCountryCode = clientCountry.isoAlpha2

let getTotal = totalDict => {
Utils.getString(totalDict, "type", "") == ""
? total(
Expand All @@ -59,7 +63,7 @@ let jsonToPaymentRequestDataType: Js.Dict.t<Js.Json.t> => paymentRequestData = j

if Utils.getString(jsonDict, "merchant_identifier", "") == "" {
paymentRequestData(
~countryCode=Utils.getString(jsonDict, "country_code", ""),
~countryCode=Utils.getString(jsonDict, "country_code", defaultCountryCode),
~currencyCode=Utils.getString(jsonDict, "currency_code", ""),
~merchantCapabilities=Utils.getStrArray(jsonDict, "merchant_capabilities"),
~supportedNetworks=Utils.getStrArray(jsonDict, "supported_networks"),
Expand Down

0 comments on commit 2ee7afc

Please sign in to comment.