diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res index e593a671b..3fec27740 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res @@ -262,7 +262,7 @@ let make = (~connectProcessorValue: connectProcessor) => { onClick={_ => updateTestPaymentEnum(~paymentId="pay_default")->ignore} />}> SDKPaymentUtils.initialValueForForm} + initialValues={activeBusinessProfile->SDKPaymentUtils.initialValueForForm} returnUrl={`${HSwitchGlobalVars.hyperSwitchFEPrefix}/quick-start`} onProceed={updateTestPaymentEnum} keyValue=key diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPage.res b/src/screens/HyperSwitch/SDKPayment/SDKPage.res index 790c37925..101429608 100644 --- a/src/screens/HyperSwitch/SDKPayment/SDKPage.res +++ b/src/screens/HyperSwitch/SDKPayment/SDKPage.res @@ -1,10 +1,10 @@ let h3Leading2Style = HSwitchUtils.getTextClass(~textVariant=H3, ~h3TextVariant=Leading_2, ()) external toJson: 'a => Js.Json.t = "%identity" -module SDKConfifiguarationFields = { +module SDKConfiguarationFields = { open HSwitchMerchantAccountUtils @react.component - let make = () => { + let make = (~initialValues: SDKPaymentTypes.paymentType) => { let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom) let arrayOfBusinessProfile = businessProfiles->getArrayOfBusinessProfile let disableSelectionForProfile = arrayOfBusinessProfile->HomeUtils.isDefaultBusinessProfile @@ -70,7 +70,9 @@ module SDKConfifiguarationFields = { - + Js.String2.length > 0)} + /> } } @@ -86,7 +88,7 @@ let make = () => { let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom) let defaultBusinessProfile = businessProfiles->getValueFromBusinessProfile let (initialValues, setInitialValues) = React.useState(_ => - defaultBusinessProfile.profile_id->SDKPaymentUtils.initialValueForForm + defaultBusinessProfile->SDKPaymentUtils.initialValueForForm ) React.useEffect1(() => { let paymentIntentOptional = filtersFromUrl->Js.Dict.get("payment_intent_client_secret") @@ -96,6 +98,11 @@ let make = () => { None }, [filtersFromUrl]) + React.useEffect1(() => { + setInitialValues(_ => defaultBusinessProfile->SDKPaymentUtils.initialValueForForm) + None + }, [defaultBusinessProfile.profile_id->Js.String2.length]) + let onProceed = async (~paymentId as _) => { let paymentId = filtersFromUrl @@ -138,7 +145,7 @@ let make = () => { initialValues={initialValues->toJson} formClass="grid grid-cols-2 gap-x-8 gap-y-4" onSubmit> - + diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res b/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res index 546b37b09..42146dfe9 100644 --- a/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res +++ b/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res @@ -3,4 +3,5 @@ type paymentType = { currency: string, profile_id: string, customer_id: string, + description: string, } diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res b/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res index 14184cbdc..1680b7392 100644 --- a/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res +++ b/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res @@ -1,8 +1,11 @@ -let initialValueForForm: string => SDKPaymentTypes.paymentType = profileId => { - amount: 100, - currency: "United States-USD", - profile_id: profileId, - customer_id: "hyperswitch_sdk_demo_id", +let initialValueForForm: HSwitchSettingTypes.profileEntity => SDKPaymentTypes.paymentType = defaultBusinessProfile => { + { + amount: 100, + currency: "United States-USD", + profile_id: defaultBusinessProfile.profile_id, + description: "Default value", + customer_id: "hyperswitch_sdk_demo_id", + } } let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values => { @@ -13,6 +16,7 @@ let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values = currency: dictOfValues->getString("currency", "United States-USD"), profile_id: dictOfValues->getString("profile_id", ""), customer_id: dictOfValues->getString("customer_id", ""), + description: dictOfValues->getString("description", "Default value"), } } diff --git a/src/screens/HyperSwitch/SDKPayment/TestPayment.res b/src/screens/HyperSwitch/SDKPayment/TestPayment.res index b10d705ca..0c5b7fd42 100644 --- a/src/screens/HyperSwitch/SDKPayment/TestPayment.res +++ b/src/screens/HyperSwitch/SDKPayment/TestPayment.res @@ -1,3 +1,4 @@ +external toJson: 'a => Js.Json.t = "%identity" let headerTextStyle = "text-xl font-semibold text-grey-700" let subTextStyle = "text-base font-normal text-grey-700 opacity-50" let dividerColor = "bg-grey-700 bg-opacity-20 h-px w-full" @@ -46,6 +47,7 @@ let make = ( ), ("profile_id", initialValues.profile_id->Js.Json.string), ("customer_id", "hyperswitch_sdk_demo_id"->Js.Json.string), + ("description", initialValues.description->Js.Json.string), ])->Js.Json.object_ let response = await updateDetails(url, body, Post) let clientSecret = response->getDictFromJsonObject->getOptionString("client_secret") diff --git a/src/screens/HyperSwitch/StripePlusPaypal/StripePlusPaypalUIUtils.res b/src/screens/HyperSwitch/StripePlusPaypal/StripePlusPaypalUIUtils.res index f91d6c9ed..99a79cc1a 100644 --- a/src/screens/HyperSwitch/StripePlusPaypal/StripePlusPaypalUIUtils.res +++ b/src/screens/HyperSwitch/StripePlusPaypal/StripePlusPaypalUIUtils.res @@ -173,7 +173,7 @@ module TestPayment = { }} />}> SDKPaymentUtils.initialValueForForm} + initialValues={defaultBusinessProfile->SDKPaymentUtils.initialValueForForm} returnUrl={`${HSwitchGlobalVars.hyperSwitchFEPrefix}/stripe-plus-paypal`} onProceed={sptestPaymentProceed} keyValue={key}