Skip to content

Commit

Permalink
refactor: refactor
Browse files Browse the repository at this point in the history
refactor
  • Loading branch information
Sagnik Mitra authored and Sagnik Mitra committed Sep 13, 2024
1 parent f9e27c1 commit 421ba6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Types/ApplePayTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type event = {validationURL: string, payment: paymentResult}
type lineItem = {
label: string,
amount: string,
@optional \"type": string,
\"type": string,
}
type shippingAddressChangeEvent = {shippingContact: JSON.t}
type updatedOrderDetails = {newTotal: lineItem, newLineItems: array<lineItem>}
Expand Down
16 changes: 7 additions & 9 deletions src/Utilities/ApplePayHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ let startApplePaySession = (
->shippingContactItemToObjMapper
let newShippingAddress =
[
("state", newShippingContact.locality),
("country", newShippingContact.countryCode),
("zip", newShippingContact.postalCode),
]
->Array.map(((key, val)) => (key, val->Js.Json.string))
->getJsonFromArrayOfJson
("state", newShippingContact.locality->JSON.Encode.string),
("country", newShippingContact.countryCode->JSON.Encode.string),
("zip", newShippingContact.postalCode->JSON.Encode.string),
]->getJsonFromArrayOfJson

let paymentMethodType = "apple_pay"->JSON.Encode.string

Expand Down Expand Up @@ -328,9 +326,9 @@ let useSubmitCallback = (~isWallet, ~sessionObj, ~componentName) => {
let json = ev.data->safeParse
let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper
if confirm.doSubmit && areRequiredFieldsValid && !areRequiredFieldsEmpty {
options.readOnly
? ()
: handleApplePayButtonClicked(~sessionObj, ~componentName, ~paymentMethodListValue)
if !options.readOnly {
handleApplePayButtonClicked(~sessionObj, ~componentName, ~paymentMethodListValue)
}
} else if areRequiredFieldsEmpty {
postFailedSubmitResponse(
~errortype="validation_error",
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/TaxCalculation.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let taxResponseToObjMapper = dict => {

let calculateTax = (~shippingAddress, ~logger, ~clientSecret, ~publishableKey, ~paymentMethodType) => {
PaymentHelpers.calculateTax(
~clientSecret=clientSecret->Js.Json.string,
~clientSecret=clientSecret->JSON.Encode.string,
~apiKey=publishableKey,
~paymentId=clientSecret->getPaymentId,
~paymentMethodType,
Expand Down

0 comments on commit 421ba6b

Please sign in to comment.