Skip to content

Commit

Permalink
Pull request #128: HS-93 Fixed ClientSecret as undefined for Sync Call
Browse files Browse the repository at this point in the history
Merge in EXC/orca-elements from fix/google-pay to master

* commit '8956e44d40c9847d34a2a338129cf1f266b0b5a1':
  HS-93 Fixed ClientSecret as undefined for Sync Call
  • Loading branch information
ArushKapoorJuspay authored and prafulkoppalkar committed Jul 13, 2023
2 parents 9905611 + 8956e44 commit 1aa5e81
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Payments/ApplePay.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type props = {sessionObj: option<Js.Json.t>, list: PaymentMethodListType.list}

let default = (props: props) => {
let {clientSecret, publishableKey} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys)
let {publishableKey} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys)
let (showApplePay, setShowApplePay) = React.useState(() => false)
let (showApplePayLoader, setShowApplePayLoader) = React.useState(() => false)
let intent = PaymentHelpers.usePaymentIntent(None, Applepay)
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/GPay.res
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ external resToJson: Fetch.Response.t => Js.Json.t = "%identity"
let default = (props: props) => {
let (loggerState, _setLoggerState) = Recoil.useRecoilState(loggerAtom)
let {iframeId} = Recoil.useRecoilValueFromAtom(keys)
let {clientSecret, publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let {publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let options = Recoil.useRecoilValueFromAtom(optionAtom)
let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), Gpay)
let sync = PaymentHelpers.usePaymentSync(Some(loggerState), Gpay)
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/PayPal.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let payPalIcon = <Icon size=35 width=90 name="paypal" />
let default = (props: props) => {
let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom)
let (paypalClicked, setPaypalClicked) = React.useState(_ => false)
let {clientSecret, publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let {publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let options = Recoil.useRecoilValueFromAtom(optionAtom)
let (_, _, labelType) = options.wallets.style.type_
let _label = switch labelType {
Expand Down
65 changes: 37 additions & 28 deletions src/Payments/PaymentRequestButtonElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,49 @@ let make = (~sessions, ~walletOptions, ~list) => {
Gpay,
)

let {clientSecret} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys)

<div className="flex flex-col gap-1 h-auto w-full max-w-[750px]">
{walletOptions
->Js.Array2.mapi((item, i) => {
<React.Suspense fallback={<WalletShimmer />} key={i->Belt.Int.toString}>
{switch item->paymentMode {
| GPayWallet =>
<SessionPaymentWrapper type_={Wallet}>
{switch gPayToken {
| OtherTokenOptional(optToken) =>
switch googlePayThirdPartyToken {
| GooglePayThirdPartyTokenOptional(googlePayThirdPartyOptToken) => <GPayLazy sessionObj=optToken list thirdPartySessionObj=googlePayThirdPartyOptToken />
| _ => <GPayLazy sessionObj=optToken list thirdPartySessionObj=None />
}
{switch clientSecret {
| Some(_) =>
switch item->paymentMode {
| GPayWallet =>
<SessionPaymentWrapper type_={Wallet}>
{switch gPayToken {
| OtherTokenOptional(optToken) =>
switch googlePayThirdPartyToken {
| GooglePayThirdPartyTokenOptional(googlePayThirdPartyOptToken) =>
<GPayLazy
sessionObj=optToken list thirdPartySessionObj=googlePayThirdPartyOptToken
/>
| _ => <GPayLazy sessionObj=optToken list thirdPartySessionObj=None />
}
| _ => React.null
}}
</SessionPaymentWrapper>
| PaypalWallet =>
<SessionPaymentWrapper type_={Wallet}>
{switch paypalToken {
| OtherTokenOptional(optToken) =>
switch optToken {
| Some(token) => <PaypalSDKLazy sessionObj=token list />
| None => <PayPalLazy list />
}
| _ => <PayPalLazy list />
}}
</SessionPaymentWrapper>
| ApplePayWallet =>
switch applePayToken {
| ApplePayTokenOptional(optToken) => <ApplePayLazy sessionObj=optToken list />
| _ => React.null
}}
</SessionPaymentWrapper>
| PaypalWallet =>
<SessionPaymentWrapper type_={Wallet}>
{switch paypalToken {
| OtherTokenOptional(optToken) =>
switch optToken {
| Some(token) => <PaypalSDKLazy sessionObj=token list />
| None => <PayPalLazy list />
}
| _ => <PayPalLazy list />
}}
</SessionPaymentWrapper>
| ApplePayWallet =>
switch applePayToken {
| ApplePayTokenOptional(optToken) => <ApplePayLazy sessionObj=optToken list />
| _ => React.null
}
}

| NONE => React.null
| NONE => React.null
}
| None => React.null
}}
</React.Suspense>
})
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/PaypalSDK.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open RecoilAtoms
type props = {sessionObj: SessionsType.token, list: PaymentMethodListType.list}

let default = (props: props) => {
let {iframeId, clientSecret, publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let {iframeId, publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let (loggerState, _setLoggerState) = Recoil.useRecoilState(loggerAtom)

let token = props.sessionObj.token
Expand Down

0 comments on commit 1aa5e81

Please sign in to comment.