Skip to content

Commit

Permalink
Merge branch 'main' into plaid-pis-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Aug 7, 2024
2 parents 195a42f + 812cd74 commit f721ca3
Show file tree
Hide file tree
Showing 14 changed files with 244 additions and 213 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [0.81.1](https://github.com/juspay/hyperswitch-web/compare/v0.81.0...v0.81.1) (2024-08-07)


### Bug Fixes

* fixed structure of billing details in payment body ([#546](https://github.com/juspay/hyperswitch-web/issues/546)) ([1e63aad](https://github.com/juspay/hyperswitch-web/commit/1e63aad43e7de2cfca8bd8127395445fbb43e109))

# [0.81.0](https://github.com/juspay/hyperswitch-web/compare/v0.80.7...v0.81.0) (2024-08-07)


### Features

* sdk pay now button enable prop added ([#543](https://github.com/juspay/hyperswitch-web/issues/543)) ([bf7a505](https://github.com/juspay/hyperswitch-web/commit/bf7a50518d74a5cd0d5e74b420d49d5320b515d0))

## [0.80.7](https://github.com/juspay/hyperswitch-web/compare/v0.80.6...v0.80.7) (2024-08-06)

## [0.80.6](https://github.com/juspay/hyperswitch-web/compare/v0.80.5...v0.80.6) (2024-08-06)
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.80.7",
"version": "0.81.1",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions src/Components/PayNowButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ let make = () => {
let confirmPayload = sdkHandleConfirmPayment->PaymentBody.confirmPayloadForSDKButton
let buttonText = sdkHandleConfirmPayment.buttonText->Option.getOr(localeString.payNowButton)

React.useEffect1(() => {
setIsPayNowButtonDisable(_ => !sdkHandleConfirmPayment.allowButtonBeforeValidation)
None
}, [sdkHandleConfirmPayment.allowButtonBeforeValidation])

let handleMessage = (event: Types.event) => {
let json = event.data->Identity.anyTypeToJson->getStringFromJson("")->safeParse
let dict = json->getDictFromJson
Expand Down
13 changes: 9 additions & 4 deletions src/Hooks/UtilityHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ let useIsGuestCustomer = () => {
}

let useHandlePostMessages = (~complete, ~empty, ~paymentType, ~savedMethod=false) => {
let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
let setIsPayNowButtonDisable = RecoilAtoms.payNowButtonDisable->Recoil.useSetRecoilState
open RecoilAtoms

let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom)
let setIsPayNowButtonDisable = Recoil.useSetRecoilState(payNowButtonDisable)
let {sdkHandleConfirmPayment} = Recoil.useRecoilValueFromAtom(optionAtom)

React.useEffect(() => {
let isCompletelyFilled = complete && paymentType !== ""
setIsPayNowButtonDisable(_ => !isCompletelyFilled)
if !sdkHandleConfirmPayment.allowButtonBeforeValidation {
let isCompletelyFilled = complete && paymentType !== ""
setIsPayNowButtonDisable(_ => !isCompletelyFilled)
}
Utils.handlePostMessageEvents(~complete, ~empty, ~paymentType, ~loggerState, ~savedMethod)
None
}, (complete, empty, paymentType))
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/PaymentMethodsRecord.res
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ let paymentMethodsFields = [
miniIcon: None,
},
{
paymentMethodName: "multibanco",
paymentMethodName: "multibanco_transfer",
icon: Some(icon("multibanco", ~size=19)),
displayName: "Multibanco",
fields: [Email, InfoElement],
Expand Down
3 changes: 2 additions & 1 deletion src/TabCard.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let make = (~paymentOption: PaymentMethodsRecord.paymentFieldsInfo, ~isActive: b
let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom)
let {readOnly, customMethodNames} = Recoil.useRecoilValueFromAtom(optionAtom)
let setSelectedOption = Recoil.useSetRecoilState(selectedOptionAtom)
let {sdkHandleConfirmPayment} = optionAtom->Recoil.useRecoilValueFromAtom
let setIsPayNowButtonDisable = Recoil.useSetRecoilState(payNowButtonDisable)
let (tabClass, tabLabelClass, tabIconClass) = React.useMemo(
() => isActive ? ("Tab--selected", "TabLabel--selected", "TabIcon--selected") : ("", "", ""),
Expand All @@ -16,7 +17,7 @@ let make = (~paymentOption: PaymentMethodsRecord.paymentFieldsInfo, ~isActive: b
paymentOption.icon,
)
let onClick = _ => {
setIsPayNowButtonDisable(_ => true)
setIsPayNowButtonDisable(_ => !sdkHandleConfirmPayment.allowButtonBeforeValidation)
setSelectedOption(_ => paymentOption.paymentMethodName)
}
<button
Expand Down
3 changes: 3 additions & 0 deletions src/Types/PaymentType.res
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ type sdkHandleConfirmPayment = {
handleConfirm: bool,
buttonText?: string,
confirmParams: ConfirmType.confirmParams,
allowButtonBeforeValidation: bool,
}

type options = {
Expand Down Expand Up @@ -286,6 +287,7 @@ let defaultBillingAddress = {
let defaultSdkHandleConfirmPayment = {
handleConfirm: false,
confirmParams: ConfirmType.defaultConfirm,
allowButtonBeforeValidation: false,
}

let defaultOptions = {
Expand Down Expand Up @@ -983,6 +985,7 @@ let getSdkHandleConfirmPaymentProps = dict => {
handleConfirm: dict->getBool("handleConfirm", false),
buttonText: ?dict->getOptionString("buttonText"),
confirmParams: dict->getDictFromDict("confirmParams")->getConfirmParams,
allowButtonBeforeValidation: dict->getBool("allowButtonBeforeValidation", false),
}

let itemToObjMapper = (dict, logger) => {
Expand Down
16 changes: 8 additions & 8 deletions src/Utilities/DynamicFieldsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ let isBillingAddressFieldType = (fieldType: PaymentMethodsRecord.paymentMethodsF

let getBillingAddressPathFromFieldType = (fieldType: PaymentMethodsRecord.paymentMethodsFields) => {
switch fieldType {
| AddressLine1 => "billing.address.line1"
| AddressLine2 => "billing.address.line2"
| AddressCity => "billing.address.city"
| AddressState => "billing.address.state"
| AddressCountry(_) => "billing.address.country"
| AddressPincode => "billing.address.zip"
| AddressLine1 => "payment_method_data.billing.address.line1"
| AddressLine2 => "payment_method_data.billing.address.line2"
| AddressCity => "payment_method_data.billing.address.city"
| AddressState => "payment_method_data.billing.address.state"
| AddressCountry(_) => "payment_method_data.billing.address.country"
| AddressPincode => "payment_method_data.billing.address.zip"
| _ => ""
}
}
Expand Down Expand Up @@ -552,11 +552,11 @@ let useRequiredFieldsBody = (
if item === BillingName {
let arr = value->String.split(" ")
acc->Dict.set(
"billing.address.first_name",
"payment_method_data.billing.address.first_name",
arr->Array.get(0)->Option.getOr("")->JSON.Encode.string,
)
acc->Dict.set(
"billing.address.last_name",
"payment_method_data.billing.address.last_name",
arr->Array.get(1)->Option.getOr("")->JSON.Encode.string,
)
} else {
Expand Down
Loading

0 comments on commit f721ca3

Please sign in to comment.