@juspay-tech/react-native-hyperswitch 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +22 -1
- package/android/src/main/assets/hyperswitch.bundle +590 -590
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/NativeLog.kt +107 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/ReactNativeHyperswitchModule.kt +318 -117
- package/android/src/main/java/io/hyperswitch/paymentsession/ExitHeadlessCallBackManager.kt +4 -2
- package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSessionHandlerImpl.kt +20 -4
- package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSessionReactLauncher.kt +104 -9
- package/android/src/main/java/io/hyperswitch/paymentsheet/PaymentResult.kt +7 -1
- package/android/src/main/java/io/hyperswitch/react/HyperModule.kt +13 -0
- package/android/src/main/java/io/hyperswitch/view/PaymentWidgetView.kt +27 -4
- package/android/src/rn79/assets/hyperswitch.bundle +590 -590
- package/android/src/rn79/java/io/hyperswitch/react/HyperFragment.kt +20 -0
- package/android/src/rn81/java/io/hyperswitch/react/HyperFragment.kt +20 -0
- package/ios/Modules/ReactNative/NativeHyperswitchModuleImpl.swift +3 -1
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayHandler.swift +49 -38
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+UIKit.swift +1 -5
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModuleImpl.swift +49 -34
- package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +2 -12
- package/ios/hyperswitchSDK/Core/Resources/hyperswitch-rn82plus.bundle +590 -590
- package/ios/hyperswitchSDK/Core/Resources/hyperswitch.bundle +590 -590
- package/ios/hyperswitchSDK/Shared/Environment.swift +49 -3
- package/ios/hyperswitchSDK/Shared/HyperswitchEnvironment.swift +1 -0
- package/ios/hyperswitchSDK/Shared/NativeLogger/LogBuilder.swift +15 -0
- package/ios/hyperswitchSDK/Shared/NativeLogger/LogManager.swift +10 -2
- package/ios/hyperswitchSDK/Shared/NativeLogger/LogPayload.swift +1 -0
- package/ios/hyperswitchSDK/Shared/NativeLogger/NativeLog.swift +101 -0
- package/ios/hyperswitchSDK/Shared/PaymentSession.swift +8 -1
- package/lib/commonjs/index.bundle.js +2 -2
- package/lib/commonjs/index.bundle.js.map +1 -1
- package/lib/module/index.bundle.js +2 -2
- package/lib/module/index.bundle.js.map +1 -1
- package/lib/typescript/src/context/HyperElements.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/NativeResponseMapper.d.ts +2 -1
- package/lib/typescript/src/native/NativeResponseMapper.d.ts.map +1 -1
- package/lib/typescript/src/session/SavedPaymentMethods.d.ts.map +1 -1
- package/lib/typescript/src/session/presentPaymentSheet.d.ts +0 -12
- package/lib/typescript/src/session/presentPaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/views/PaymentElement.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/context/HyperElements.tsx +7 -6
- package/src/index.ts +9 -1
- package/src/native/NativeResponseMapper.ts +20 -4
- package/src/session/SavedPaymentMethods.ts +10 -2
- package/src/session/presentPaymentSheet.ts +7 -1
- package/src/views/PaymentElement.tsx +17 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{TurboModuleRegistry as e,NativeModules as t,requireNativeComponent as n,findNodeHandle as r,UIManager as o,Platform as a,useColorScheme as i,Pressable as s,StyleSheet as l}from"react-native";import u,{createContext as c,useContext as y,useState as d,useCallback as p,useEffect as f,forwardRef as m,useRef as g,useMemo as h,useImperativeHandle as b}from"react";const v=e.get("NativeHyperswitchModule")??t.NativeHyperswitchModule,w=e.get("NativeWidgetHelperModule")??t.NativeWidgetHelperModule;function S(e){switch(e){case"succeeded":case"completed":case"requires_capture":case"success":return"completed";case"cancelled":case"canceled":return"canceled";default:return"failed"}}
|
|
1
|
+
import{TurboModuleRegistry as e,NativeModules as t,requireNativeComponent as n,findNodeHandle as r,UIManager as o,Platform as a,useColorScheme as i,Pressable as s,StyleSheet as l}from"react-native";import u,{createContext as c,useContext as y,useState as d,useCallback as p,useEffect as f,forwardRef as m,useRef as g,useMemo as h,useImperativeHandle as b}from"react";const v=e.get("NativeHyperswitchModule")??t.NativeHyperswitchModule,w=e.get("NativeWidgetHelperModule")??t.NativeWidgetHelperModule;function S(e){if("object"==typeof e&&null!==e)return e;try{return JSON.parse(e)}catch{return{status:"failed",message:String(e)}}}function P(...e){for(const t of e)if("string"==typeof t&&""!==t.trim())return t}function E(e){const t=S(e),n=function(e){switch(e){case"succeeded":case"completed":case"requires_capture":case"success":return"completed";case"cancelled":case"canceled":return"canceled";default:return"failed"}}(t.status),r=P(t.message,t.error,t.code);return{status:n,type:P(t.type,t.code,n)??"",message:r??("failed"===n?"The payment failed but no error detail was returned.":"")}}const _=new Map;function C(e,t){_.set(e,t)}function k(e){_.delete(e)}function O(e){const t=[..._.values()].map(t=>new Promise(n=>{w.updateIntentCompleteForWidget(t,e,e=>n(E(e)))}));return Promise.all(t)}let N=!1;function R(e){N=e}let A=!1;function T(e){A=e}let j=0;async function M(e){if(N)return{status:"failed",type:"initialization_in_progress",message:"SDK is reloading. Please wait for initialisation to complete before presenting the payment sheet."};if(A)return{status:"canceled",type:"sheet_already_presented",message:"A payment sheet is already presented."};const t=++j;T(!0);try{return E(await v.presentPaymentSheet({hyperswitchConfig:e.hyperswitchConfig,paymentSessionConfig:e.paymentSessionConfig,configuration:e.configuration}))}finally{t===j&&T(!1)}}function W(e){if(!e)throw new Error("A widgetId is required to confirm a saved payment method");const t=function(e){return _.get(e)}(e);if(void 0===t)throw new Error(`Widget ${e} not found or not mounted`);return t}function D(e){if(null==e||"string"!=typeof e)return e??null;try{return JSON.parse(e)}catch{return null}}function x(e){try{const t=JSON.parse(e);return{...t,billing:D(t.billing)}}catch{return null}}async function I(e,t,n){const r={hyperswitchConfig:e,paymentSessionConfig:t,configuration:{...n,paymentMethodLayout:{savedMethodCustomization:{hiddenPaymentMethods:n?.hiddenPaymentMethods??[]}}}},o=await v.getCustomerSavedPaymentMethods(r),{status:a,code:i,message:s}=S(o);if("failed"===a||"error"===i)throw new Error(s??"Failed to load saved payment methods");return{getCustomerLastUsedPaymentMethodData:async()=>x(await v.getCustomerLastUsedPaymentMethodData()),getCustomerDefaultSavedPaymentMethodData:async()=>x(await v.getCustomerDefaultSavedPaymentMethodData()),getCustomerSavedPaymentMethodData:async()=>x(await v.getCustomerSavedPaymentMethodData()),confirmWithCustomerLastUsedPaymentMethod:async e=>E(await v.confirmWithCustomerLastUsedPaymentMethod(W(e?.id))),confirmWithCustomerDefaultPaymentMethod:async e=>E(await v.confirmWithCustomerDefaultPaymentMethod(W(e?.id)))}}async function L(e,t){const n=await(r=v.getWalletSession({hyperswitchConfig:e,paymentSessionConfig:t}),o="getWalletSession",new Promise((e,t)=>{const n=setTimeout(()=>{t(new Error(`${o} timed out after 15000ms`))},15e3);r.then(t=>{clearTimeout(n),e(t)},e=>{clearTimeout(n),t(e)})}));var r,o;let a,i;try{const e=JSON.parse(n);a=e.status,i=e.message}catch{a=void 0}if("failed"===a)throw new Error(i??"Failed to initialise the wallet session");return{isWalletEligible:e=>v.isWalletEligible(e).catch(()=>!1),isGooglePayEligible:()=>v.isWalletEligible("google_pay").catch(()=>!1),isApplePayEligible:()=>v.isWalletEligible("apple_pay").catch(()=>!1),launchWallet:async e=>E(await v.launchWallet(e)),launchGooglePay:async()=>E(await v.launchWallet("google_pay")),launchApplePay:async()=>E(await v.launchWallet("apple_pay"))}}function U(e){return async function(t){const n=function(e,t,n){const r={...e};return delete r.platformPublishableKey,{hyperswitchConfig:r,paymentSessionConfig:t,configuration:n??{}}}(e.hyperswitchConfig,e.paymentSessionConfig,t);return M(n)}}function $(e){return function(t){return I(e.hyperswitchConfig,e.paymentSessionConfig,t)}}function z(e){return function(){return L(e.hyperswitchConfig,e.paymentSessionConfig)}}async function F(e){let t;try{await function(){const e=[..._.values()].map(e=>new Promise(t=>{w.updateIntentInitForWidget(e,e=>t(E(e)))}));return Promise.all(e)}(),t=await e(),await O(t.sdkAuthorization)}catch{return void await O("")}}function H(e,t){const n={hyperswitchConfig:e,paymentSessionConfig:t};return{presentPaymentSheet:U(n),async confirmPayment(e,t){if("string"==typeof e){return E(await function(e){const t=_.get(e);return void 0===t?Promise.resolve(JSON.stringify({status:"failed",message:`Widget ${e} not found or not mounted`,type:void 0})):new Promise(e=>{w.confirmPayment(t,e)})}(e))}const n=e.current;if(!n)throw new Error("PaymentElement reference is not mounted");return n.confirmPayment(t)},getCustomerSavedPaymentMethods:$(n),getWalletSession:z(n),updateIntent:F}}var B,K={exports:{}},G={};var J,V,Y={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.development.js
|
|
@@ -7,5 +7,5 @@ import{TurboModuleRegistry as e,NativeModules as t,requireNativeComponent as n,f
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/function V(){return K||(K=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===C?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case f:return"Fragment";case g:return"Profiler";case m:return"StrictMode";case w:return"Suspense";case S:return"SuspenseList";case _:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case p:return"Portal";case b:return t.displayName||"Context";case h:return(t._context.displayName||"Context")+".Consumer";case v:var n=t.render;return(t=t.displayName)||(t=""!==(t=n.displayName||n.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case P:return null!==(n=t.displayName||null)?n:e(t.type)||"Memo";case E:n=t._payload,t=t._init;try{return e(t(n))}catch(e){}}return null}function t(e){return""+e}function n(e){try{t(e);var n=!1}catch(e){n=!0}if(n){var r=(n=console).error,o="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),t(e)}}function r(t){if(t===f)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===E)return"<...>";try{var n=e(t);return n?"<"+n+">":"<...>"}catch(e){return"<...>"}}function o(){return Error("react-stack-top-frame")}function a(){var t=e(this.type);return A[t]||(A[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function i(t,r,o,i,l,u){var y,p=r.children;if(void 0!==p)if(i)if(N(p)){for(i=0;i<p.length;i++)s(p[i]);Object.freeze&&Object.freeze(p)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else s(p);if(O.call(r,"key")){p=e(t);var f=Object.keys(r).filter(function(e){return"key"!==e});i=0<f.length?"{key: someKey, "+f.join(": ..., ")+": ...}":"{key: someKey}",M[p+i]||(f=0<f.length?"{"+f.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',i,p,f,p),M[p+i]=!0)}if(p=null,void 0!==o&&(n(o),p=""+o),function(e){if(O.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(r)&&(n(r.key),p=""+r.key),"key"in r)for(var m in o={},r)"key"!==m&&(o[m]=r[m]);else o=r;return p&&function(e,t){function n(){c||(c=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(o,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,n,r,o,i){var s=n.ref;return e={$$typeof:d,type:e,key:t,props:n,_owner:r},null!==(void 0!==s?s:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:a}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:o}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,p,o,null===(y=k.A)?null:y.getOwner(),l,u)}function s(e){l(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===E&&("fulfilled"===e._payload.status?l(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function l(e){return"object"==typeof e&&null!==e&&e.$$typeof===d}var c,y=u,d=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),h=Symbol.for("react.consumer"),b=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),k=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=Object.prototype.hasOwnProperty,N=Array.isArray,R=console.createTask?console.createTask:function(){return null},A={},T=(y={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(y,o)(),j=R(r(o)),M={};J.Fragment=f,J.jsx=function(e,t,n){var o=1e4>k.recentlyCreatedOwnerStacks++;return i(e,t,n,!1,o?Error("react-stack-top-frame"):T,o?R(r(e)):j)},J.jsxs=function(e,t,n){var o=1e4>k.recentlyCreatedOwnerStacks++;return i(e,t,n,!0,o?Error("react-stack-top-frame"):T,o?R(r(e)):j)}}()),J}var Y=(G||(G=1,"production"===process.env.NODE_ENV?H.exports=function(){if(F)return B;F=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==n.key&&(o=""+n.key),"key"in n)for(var a in r={},n)"key"!==a&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:e,type:t,key:o,ref:void 0!==n?n:null,props:r}}return B.Fragment=t,B.jsx=n,B.jsxs=n,B}():H.exports=V()),H.exports);const q=c(void 0);function X({hyper:e,options:t,children:n}){const[r,o]=d(null),[a,i]=d(null),[s,l]=d(null),[u,c]=d(null),[y,m]=d(null),[g,h]=d(null),[b,v]=d(!0),[w,S]=d(null),[P,E]=d(null),[_,C]=d({googlePay:!1,applePay:!1}),[k,O]=d(!1),N=p(async()=>{if(!r)return null;O(!0);try{const e=await r.getWalletSession(),[t,n]=await Promise.all([e.isGooglePayEligible(),e.isApplePayEligible()]);return E(e),C({googlePay:t,applePay:n}),e}catch{return E(null),C({googlePay:!1,applePay:!1}),null}finally{O(!1)}},[r]);return f(()=>{E(null),C({googlePay:!1,applePay:!1})},[r]),f(()=>{if(!e)return;let n=!1;return(async()=>{try{const r=await Promise.resolve(e),a={sdkAuthorization:t.sdkAuthorization},s=await r.elements(a);n||(o({...s}),l(s.hyperswitchConfig),c(a),i(s),m(r.publishableKey??null),h(t.sdkAuthorization??null),v(!1))}catch(e){n||(S(e instanceof Error?e:new Error(String(e))),v(!1))}})(),()=>{n=!0}},[e,t.sdkAuthorization]),Y.jsx(q.Provider,{value:{paymentSession:r,walletSession:P,walletEligibility:_,walletLoading:k,loadWalletSession:N,elements:a,publishableKey:y,sdkAuthorization:g,loading:b,error:w,paymentSessionConfig:u,hyperswitchConfig:s},children:n})}function Q(){const e=y(q);if(void 0===e)throw new Error("useHyperElementsContext must be used inside <HyperElements>");return e}function Z(){const e=Q();return{walletSession:e.walletSession,isGooglePayEligible:e.walletEligibility.googlePay,isApplePayEligible:e.walletEligibility.applePay,loading:e.walletLoading,load:e.loadWalletSession}}function ee(){const e=y(q);return{walletSession:e?.walletSession??null,isGooglePayEligible:e?.walletEligibility.googlePay??!1,isApplePayEligible:e?.walletEligibility.applePay??!1,loading:e?.walletLoading??!1,load:e?.loadWalletSession??(async()=>null)}}function te(){const e=y(q);return e?.paymentSession??null}function ne(){return Q().paymentSession}function re(){return Q().elements}q.displayName="HyperElementsContext";const oe=null!=global.nativeFabricUIManager?require("../codegen/components/PaymentWidgetNativeComponent").default:n("RCTNativePaymentWidget");function ae(e,t){const[n,o]=d(void 0);return f(()=>{if(void 0!==n)return;let a,i=!0;const s=n=>{if(!i)return;if(null==e.current)return void(n<20&&(a=setTimeout(()=>s(n+1),100)));const l=r(e.current)??-1;-1!==l?(t?.(),o(l)):n<20&&(a=setTimeout(()=>s(n+1),100))};return s(0),()=>{i=!1,void 0!==a&&clearTimeout(a)}},[n]),n}const ie=m((e,t)=>{const{id:n,options:r,onChange:o,onFocus:a,onBlur:i,onPaymentResult:s,style:l,onReady:u}=e,{paymentSessionConfig:c,hyperswitchConfig:y}=Q(),d=g(null),p=ae(d,u),m=void 0!==n&&void 0!==p;f(()=>{if(!m)return;const e=n;return _(e,p),()=>C(e)},[m]);const b=h(()=>{const e=r,t=e?.paymentMethodLayout;return{...e,paymentMethodLayout:{...t,savedMethodCustomization:{...t?.savedMethodCustomization,cvcIcon:e?.cvcIcon??"shown"}}}},[r]);return Y.jsx(oe,{ref:d,widgetType:"cvcWidget",sdkAuthorization:c?.sdkAuthorization??"",onPaymentEvent:e=>{if(o?.(e.nativeEvent),"CVC_STATUS"===e.nativeEvent.eventName)try{const t=e.nativeEvent.payload,n="string"==typeof t?JSON.parse(t):t;if(!n)return;const r=n.cvcStatus;if(!r)return;const o=Boolean(r.isCvcFocused),s=Boolean(r.isCvcBlur);o&&a?.(),s&&i?.()}catch{}},onPaymentResult:e=>{var t;s?.((t=e.nativeEvent.result??"",JSON.parse(t)))},options:{hyperswitchConfig:y||void 0,paymentSessionConfig:c||void 0,configuration:b},style:l})}),se=["PAYMENT_METHOD_INFO_CARD","PAYMENT_METHOD_STATUS","FORM_STATUS","PAYMENT_METHOD_INFO_ADDRESS","PAYMENT_METHOD_INFO_BILLING_ADDRESS","CVC_STATUS"];function le(e){return{message:`Unknown event(s) subscribed: [${e.join(", ")}]. Valid events are: ${se.join(", ")}`,invalidEvents:e,validEvents:se}}const ue=m((e,t)=>{const{widgetId:n,options:i,onPaymentResult:s,onChange:l,onReady:u,style:c}=e,{paymentSessionConfig:y,hyperswitchConfig:d}=Q(),p=g(null),m=ae(p,u);f(()=>{if(void 0!==m)return _(n,m),()=>C(n)},[m,n]),f(()=>{void 0!==m&&o.dispatchViewManagerCommand(m,1,[])},[m]),b(t,()=>({confirmPayment:e=>{if(null==p.current)return Promise.resolve({status:"failed",type:"widget_not_ready",message:"Widget not ready"});const t=r(p.current)??-1;return-1===t?Promise.resolve({status:"failed",type:"widget_not_ready",message:"Unable to find native view handle"}):new Promise(e=>{w.confirmPayment(t,t=>{e(P(t))})})}}),[m]);const h=g(!1);f(()=>{if(!i||!l||h.current)return;const e=function(e){return e?e.filter(e=>!se.includes(e)):[]}(i.subscribedEvents);if(e.length>0){h.current=!0;const t=le(e);l({eventName:"UNKNOWN_EVENT_SUBSCRIBED",payload:JSON.stringify({message:t.message,invalidEvents:t.invalidEvents,validEvents:t.validEvents})})}},[i,l]);return Y.jsx(oe,{ref:p,sdkAuthorization:y?.sdkAuthorization??"",widgetType:"widgetPaymentSheet",onPaymentEvent:e=>{l?.(e.nativeEvent)},onPaymentResult:e=>{s(P("ios"===a.OS?e.nativeEvent.result??"":e.nativeEvent.payload??""))},options:{hyperswitchConfig:d||void 0,paymentSessionConfig:y||void 0,configuration:i},style:{...c,flex:1}})});function ce(){return v.isGooglePaySupported().catch(()=>!1)}function ye(){return v.isApplePaySupported().catch(()=>!1)}function de(e){return"google_pay"===e?ce():ye()}function pe(){return"ios"===a.OS?ye():"android"===a.OS?ce():Promise.resolve(!1)}function fe({wallet:e,label:t,session:n,onPaymentResult:r}){const o=te(),{walletSession:a,load:i}=ee(),s=g(!1);return async()=>{const l=n??o;if(!l&&!a){const e=new Error(`${t} was pressed without a payment session. Pass a "session" prop or render it inside <HyperElements>.`);if(!r)throw e;return void r({status:"failed",type:"no_session",message:e.message})}if(s.current){const e=new Error(`${t} is already processing a payment. Ignoring this press.`);if(!r)throw e;return void r({status:"failed",type:"already_in_progress",message:e.message})}s.current=!0;try{const n=a??await i()??await l.getWalletSession();if(!await n.isWalletEligible(e)){const e=new Error(`${t} is not eligible for this payment.`);if(!r)throw e;return void r({status:"failed",type:"not_eligible",message:e.message})}const o=await n.launchWallet(e);r?.(o)}catch(e){const t=e instanceof Error?e.message:String(e);if(!r)throw e;r({status:"failed",type:"launch_failed",message:t})}finally{s.current=!1}}}function me({wallet:e,label:t,session:n,onReady:r,onLoadError:o}){const a=te(),{walletSession:i,load:s}=ee(),l=g(r),u=g(o),c=g(i),y=g(s);f(()=>{l.current=r,u.current=o,c.current=i,y.current=s},[r,o,i,s]),f(()=>{let r=!1;const o=(e,t)=>{u.current?.({status:"failed",type:e,message:t})};return(async()=>{try{const i=await(async()=>n?n.getWalletSession():c.current?c.current:a?y.current():null)();if(r)return;if(!i)return void o("no_session",`${t} has no payment session. Pass a "session" prop or render it inside <HyperElements>.`);const s=await i.isWalletEligible(e);if(r)return;s?l.current?.():o("not_eligible",`${t} is not eligible for this payment.`)}catch(e){if(r)return;o("launch_failed",e instanceof Error?e.message:String(e))}})(),()=>{r=!0}},[n,a,e,t])}const ge={BUY:1,BOOK:6,CHECKOUT:5,DONATE:4,ORDER:11,PAY:1e3,SUBSCRIBE:7,PLAIN:1001},he={light:1,dark:2},be={plain:0,buy:1,setUp:2,inStore:3,donate:4,checkout:5,book:6,subscribe:7},ve={white:0,whiteOutline:1,black:2};function we(e){return"hidden"===e?.visibility}function Se(e){return e?.appearance?.primaryButton?.shapes?.borderRadius??e?.appearance?.shapes?.borderRadius??4}function Pe(e,t){const n=e?.appearance?.theme;return"Dark"===n||"Light"!==n&&"dark"===t}const Ee=function(){if("android"!==a.OS)return null;try{return null!=globalThis.nativeFabricUIManager?require("../codegen/components/HyperGooglePayNativeComponent").default:n("HyperGooglePayButton")}catch{return null}}();function _e({options:e,session:t,onPaymentResult:n,onReady:r,onLoadError:o,style:a}){const u=i(),c=fe({wallet:"google_pay",label:"Google Pay",session:t,onPaymentResult:n});me({wallet:"google_pay",label:"Google Pay",session:t,onReady:r,onLoadError:o});const{hidden:y,type:d,appearance:p,borderRadius:f}=function(e,t){const n=e?.walletButtonsConfiguration?.googlePay,r=Pe(e,t),o=r?n?.buttonStyle?.dark:n?.buttonStyle?.light;return{hidden:we(n),type:ge[n?.buttonType??"PLAIN"],appearance:he[o??(r?"dark":"light")],borderRadius:Se(e)}}(e,"dark"===u?"dark":"light");return y||null==Ee?null:Y.jsx(s,{focusable:!0,accessible:!0,accessibilityRole:"button",accessibilityLabel:"Google Pay",onPress:c,style:a,children:Y.jsx(Ee,{type:d,appearance:p,borderRadius:f,style:l.absoluteFill})})}const Ce=function(){if("ios"!==a.OS)return null;try{return null!=globalThis.nativeFabricUIManager?require("../codegen/components/HyperApplePayNativeComponent").default:n("HyperApplePayButton")}catch{return null}}();function ke({options:e,session:t,onPaymentResult:n,onReady:r,onLoadError:o,disabled:a=!1,style:u}){const c=i(),y=fe({wallet:"apple_pay",label:"Apple Pay",session:t,onPaymentResult:n});me({wallet:"apple_pay",label:"Apple Pay",session:t,onReady:r,onLoadError:o});const{hidden:d,type:p,buttonStyle:f,borderRadius:m}=function(e,t){const n=e?.walletButtonsConfiguration?.applePay,r=Pe(e,t),o=r?n?.buttonStyle?.dark:n?.buttonStyle?.light;return{hidden:we(n),type:be[n?.buttonType??"plain"],buttonStyle:ve[o??(r?"white":"black")],borderRadius:Se(e)}}(e,"dark"===c?"dark":"light");return d||null==Ce?null:Y.jsx(s,{focusable:!0,accessible:!0,accessibilityRole:"button",accessibilityLabel:"Apple Pay",onPress:y,disabled:a,style:u,children:Y.jsx(Ce,{type:p,buttonStyle:f,buttonBorderRadius:m,disabled:a,style:l.absoluteFill})})}function Oe(e){return N(!0),v.initialise(e.publishableKey,e.platformPublishableKey??"",e.profileId??"",e.environment??"PROD",e.customEndpoints??{}).then(()=>(N(!1),{publishableKey:e.publishableKey,initPaymentSession:async t=>function(e,t){const n={hyperswitchConfig:e,paymentSessionConfig:t};return{presentPaymentSheet:I(n),getCustomerSavedPaymentMethods:L(n),getWalletSession:U(n),updateIntent:$}}(e,t),async elements(t){return{hyperswitchConfig:n=e,...z(n,t)};var n}})).catch(e=>{throw N(!1),console.error("Error initializing Hyperswitch SDK:",e),e})}const Ne={init:Oe};export{ke as ApplePayButton,ie as CardCVCElement,_e as GooglePayButton,X as HyperElements,Ne as Hyperswitch,ue as PaymentElement,Ne as default,ye as isApplePaySupported,ce as isGooglePaySupported,pe as isPlatformPaySupported,de as isWalletSupported,Oe as loadHyper,re as useElements,ne as usePaymentSession,Z as useWalletSession,re as useWidgets};
|
|
10
|
+
*/function q(){return J||(J=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===C?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case f:return"Fragment";case g:return"Profiler";case m:return"StrictMode";case w:return"Suspense";case S:return"SuspenseList";case _:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case p:return"Portal";case b:return t.displayName||"Context";case h:return(t._context.displayName||"Context")+".Consumer";case v:var n=t.render;return(t=t.displayName)||(t=""!==(t=n.displayName||n.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case P:return null!==(n=t.displayName||null)?n:e(t.type)||"Memo";case E:n=t._payload,t=t._init;try{return e(t(n))}catch(e){}}return null}function t(e){return""+e}function n(e){try{t(e);var n=!1}catch(e){n=!0}if(n){var r=(n=console).error,o="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),t(e)}}function r(t){if(t===f)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===E)return"<...>";try{var n=e(t);return n?"<"+n+">":"<...>"}catch(e){return"<...>"}}function o(){return Error("react-stack-top-frame")}function a(){var t=e(this.type);return A[t]||(A[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function i(t,r,o,i,l,u){var y,p=r.children;if(void 0!==p)if(i)if(N(p)){for(i=0;i<p.length;i++)s(p[i]);Object.freeze&&Object.freeze(p)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else s(p);if(O.call(r,"key")){p=e(t);var f=Object.keys(r).filter(function(e){return"key"!==e});i=0<f.length?"{key: someKey, "+f.join(": ..., ")+": ...}":"{key: someKey}",M[p+i]||(f=0<f.length?"{"+f.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',i,p,f,p),M[p+i]=!0)}if(p=null,void 0!==o&&(n(o),p=""+o),function(e){if(O.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(r)&&(n(r.key),p=""+r.key),"key"in r)for(var m in o={},r)"key"!==m&&(o[m]=r[m]);else o=r;return p&&function(e,t){function n(){c||(c=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(o,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,n,r,o,i){var s=n.ref;return e={$$typeof:d,type:e,key:t,props:n,_owner:r},null!==(void 0!==s?s:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:a}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:o}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,p,o,null===(y=k.A)?null:y.getOwner(),l,u)}function s(e){l(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===E&&("fulfilled"===e._payload.status?l(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function l(e){return"object"==typeof e&&null!==e&&e.$$typeof===d}var c,y=u,d=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),h=Symbol.for("react.consumer"),b=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),k=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=Object.prototype.hasOwnProperty,N=Array.isArray,R=console.createTask?console.createTask:function(){return null},A={},T=(y={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(y,o)(),j=R(r(o)),M={};Y.Fragment=f,Y.jsx=function(e,t,n){var o=1e4>k.recentlyCreatedOwnerStacks++;return i(e,t,n,!1,o?Error("react-stack-top-frame"):T,o?R(r(e)):j)},Y.jsxs=function(e,t,n){var o=1e4>k.recentlyCreatedOwnerStacks++;return i(e,t,n,!0,o?Error("react-stack-top-frame"):T,o?R(r(e)):j)}}()),Y}var X=(V||(V=1,"production"===process.env.NODE_ENV?K.exports=function(){if(B)return G;B=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==n.key&&(o=""+n.key),"key"in n)for(var a in r={},n)"key"!==a&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:e,type:t,key:o,ref:void 0!==n?n:null,props:r}}return G.Fragment=t,G.jsx=n,G.jsxs=n,G}():K.exports=q()),K.exports);const Q=c(void 0);function Z({hyper:e,options:t,children:n}){const[r,o]=d(null),[a,i]=d(null),[s,l]=d(null),[u,c]=d(null),[y,m]=d(null),[g,h]=d(null),[b,v]=d(!0),[w,S]=d(null),[P,E]=d(null),[_,C]=d({googlePay:!1,applePay:!1}),[k,O]=d(!1),N=p(async()=>{if(!r)return null;O(!0);try{const e=await r.getWalletSession(),[t,n]=await Promise.all([e.isGooglePayEligible(),e.isApplePayEligible()]);return E(e),C({googlePay:t,applePay:n}),e}catch{return E(null),C({googlePay:!1,applePay:!1}),null}finally{O(!1)}},[r]);return f(()=>{E(null),C({googlePay:!1,applePay:!1})},[r]),f(()=>{if(!e)return;let n=!1;return(async()=>{try{const r=await Promise.resolve(e),a={sdkAuthorization:t.sdkAuthorization},s=await r.elements(a);n||(o({...s}),l(s.hyperswitchConfig),c(a),i(s),m(r.publishableKey??null),h(t.sdkAuthorization??null),v(!1))}catch(e){n||(S(e instanceof Error?e:new Error(String(e))),v(!1))}})(),()=>{n=!0}},[e,t.sdkAuthorization]),X.jsx(Q.Provider,{value:{paymentSession:r,walletSession:P,walletEligibility:_,walletLoading:k,loadWalletSession:N,elements:a,publishableKey:y,sdkAuthorization:g,loading:b,error:w,paymentSessionConfig:u,hyperswitchConfig:s},children:n})}function ee(){const e=y(Q);if(void 0===e)throw new Error("useHyperElementsContext must be used inside <HyperElements>");return e}function te(){const e=ee();return{walletSession:e.walletSession,isGooglePayEligible:e.walletEligibility.googlePay,isApplePayEligible:e.walletEligibility.applePay,loading:e.walletLoading,load:e.loadWalletSession}}function ne(){const e=y(Q);return{walletSession:e?.walletSession??null,isGooglePayEligible:e?.walletEligibility.googlePay??!1,isApplePayEligible:e?.walletEligibility.applePay??!1,loading:e?.walletLoading??!1,load:e?.loadWalletSession??(async()=>null)}}function re(){const e=y(Q);return e?.paymentSession??null}function oe(){return ee().paymentSession}function ae(){return ee().elements}Q.displayName="HyperElementsContext";const ie=null!=global.nativeFabricUIManager?require("../codegen/components/PaymentWidgetNativeComponent").default:n("RCTNativePaymentWidget");function se(e,t){const[n,o]=d(void 0);return f(()=>{if(void 0!==n)return;let a,i=!0;const s=n=>{if(!i)return;if(null==e.current)return void(n<20&&(a=setTimeout(()=>s(n+1),100)));const l=r(e.current)??-1;-1!==l?(t?.(),o(l)):n<20&&(a=setTimeout(()=>s(n+1),100))};return s(0),()=>{i=!1,void 0!==a&&clearTimeout(a)}},[n]),n}const le=m((e,t)=>{const{id:n,options:r,onChange:o,onFocus:a,onBlur:i,onPaymentResult:s,style:l,onReady:u}=e,{paymentSessionConfig:c,hyperswitchConfig:y}=ee(),d=g(null),p=se(d,u),m=void 0!==n&&void 0!==p;f(()=>{if(!m)return;const e=n;return C(e,p),()=>k(e)},[m]);const b=h(()=>{const e=r,t=e?.paymentMethodLayout;return{...e,paymentMethodLayout:{...t,savedMethodCustomization:{...t?.savedMethodCustomization,cvcIcon:e?.cvcIcon??"shown"}}}},[r]);return X.jsx(ie,{ref:d,widgetType:"cvcWidget",sdkAuthorization:c?.sdkAuthorization??"",onPaymentEvent:e=>{if(o?.(e.nativeEvent),"CVC_STATUS"===e.nativeEvent.eventName)try{const t=e.nativeEvent.payload,n="string"==typeof t?JSON.parse(t):t;if(!n)return;const r=n.cvcStatus;if(!r)return;const o=Boolean(r.isCvcFocused),s=Boolean(r.isCvcBlur);o&&a?.(),s&&i?.()}catch{}},onPaymentResult:e=>{var t;s?.((t=e.nativeEvent.result??"",JSON.parse(t)))},options:{hyperswitchConfig:y||void 0,paymentSessionConfig:c||void 0,configuration:b},style:l})}),ue=["PAYMENT_METHOD_INFO_CARD","PAYMENT_METHOD_STATUS","FORM_STATUS","PAYMENT_METHOD_INFO_ADDRESS","PAYMENT_METHOD_INFO_BILLING_ADDRESS","CVC_STATUS"];function ce(e){return{message:`Unknown event(s) subscribed: [${e.join(", ")}]. Valid events are: ${ue.join(", ")}`,invalidEvents:e,validEvents:ue}}const ye=m((e,t)=>{const{widgetId:n,options:i,onPaymentResult:s,onChange:l,onReady:u,style:c}=e,{paymentSessionConfig:y,hyperswitchConfig:d}=ee(),p=g(null),m=se(p,u);f(()=>{if(void 0!==m)return C(n,m),()=>k(n)},[m,n]),f(()=>{void 0!==m&&o.dispatchViewManagerCommand(m,1,[])},[m]),b(t,()=>({confirmPayment:e=>{if(null==p.current)return Promise.resolve({status:"failed",type:"widget_not_ready",message:"Widget not ready"});const t=r(p.current)??-1;return-1===t?Promise.resolve({status:"failed",type:"widget_not_ready",message:"Unable to find native view handle"}):new Promise(e=>{w.confirmPayment(t,t=>{e(E(t))})})}}),[m]);const h=g(!1);f(()=>{if(!i||!l||h.current)return;const e=function(e){return e?e.filter(e=>!ue.includes(e)):[]}(i.subscribedEvents);if(e.length>0){h.current=!0;const t=ce(e);l({eventName:"UNKNOWN_EVENT_SUBSCRIBED",payload:JSON.stringify({message:t.message,invalidEvents:t.invalidEvents,validEvents:t.validEvents})})}},[i,l]);return X.jsx(ie,{ref:p,sdkAuthorization:y?.sdkAuthorization??"",widgetType:"widgetPaymentSheet",onPaymentEvent:e=>{l?.(e.nativeEvent)},onPaymentResult:e=>{s(E("ios"===a.OS?e.nativeEvent.result??"":e.nativeEvent.payload??""))},options:{hyperswitchConfig:d||void 0,paymentSessionConfig:y||void 0,configuration:i},style:{...c,flex:1}})});function de(){return v.isGooglePaySupported().catch(()=>!1)}function pe(){return v.isApplePaySupported().catch(()=>!1)}function fe(e){return"google_pay"===e?de():pe()}function me(){return"ios"===a.OS?pe():"android"===a.OS?de():Promise.resolve(!1)}function ge({wallet:e,label:t,session:n,onPaymentResult:r}){const o=re(),{walletSession:a,load:i}=ne(),s=g(!1);return async()=>{const l=n??o;if(!l&&!a){const e=new Error(`${t} was pressed without a payment session. Pass a "session" prop or render it inside <HyperElements>.`);if(!r)throw e;return void r({status:"failed",type:"no_session",message:e.message})}if(s.current){const e=new Error(`${t} is already processing a payment. Ignoring this press.`);if(!r)throw e;return void r({status:"failed",type:"already_in_progress",message:e.message})}s.current=!0;try{const n=a??await i()??await l.getWalletSession();if(!await n.isWalletEligible(e)){const e=new Error(`${t} is not eligible for this payment.`);if(!r)throw e;return void r({status:"failed",type:"not_eligible",message:e.message})}const o=await n.launchWallet(e);r?.(o)}catch(e){const t=e instanceof Error?e.message:String(e);if(!r)throw e;r({status:"failed",type:"launch_failed",message:t})}finally{s.current=!1}}}function he({wallet:e,label:t,session:n,onReady:r,onLoadError:o}){const a=re(),{walletSession:i,load:s}=ne(),l=g(r),u=g(o),c=g(i),y=g(s);f(()=>{l.current=r,u.current=o,c.current=i,y.current=s},[r,o,i,s]),f(()=>{let r=!1;const o=(e,t)=>{u.current?.({status:"failed",type:e,message:t})};return(async()=>{try{const i=await(async()=>n?n.getWalletSession():c.current?c.current:a?y.current():null)();if(r)return;if(!i)return void o("no_session",`${t} has no payment session. Pass a "session" prop or render it inside <HyperElements>.`);const s=await i.isWalletEligible(e);if(r)return;s?l.current?.():o("not_eligible",`${t} is not eligible for this payment.`)}catch(e){if(r)return;o("launch_failed",e instanceof Error?e.message:String(e))}})(),()=>{r=!0}},[n,a,e,t])}const be={BUY:1,BOOK:6,CHECKOUT:5,DONATE:4,ORDER:11,PAY:1e3,SUBSCRIBE:7,PLAIN:1001},ve={light:1,dark:2},we={plain:0,buy:1,setUp:2,inStore:3,donate:4,checkout:5,book:6,subscribe:7},Se={white:0,whiteOutline:1,black:2};function Pe(e){return"hidden"===e?.visibility}function Ee(e){return e?.appearance?.primaryButton?.shapes?.borderRadius??e?.appearance?.shapes?.borderRadius??4}function _e(e,t){const n=e?.appearance?.theme;return"Dark"===n||"Light"!==n&&"dark"===t}const Ce=function(){if("android"!==a.OS)return null;try{return null!=globalThis.nativeFabricUIManager?require("../codegen/components/HyperGooglePayNativeComponent").default:n("HyperGooglePayButton")}catch{return null}}();function ke({options:e,session:t,onPaymentResult:n,onReady:r,onLoadError:o,style:a}){const u=i(),c=ge({wallet:"google_pay",label:"Google Pay",session:t,onPaymentResult:n});he({wallet:"google_pay",label:"Google Pay",session:t,onReady:r,onLoadError:o});const{hidden:y,type:d,appearance:p,borderRadius:f}=function(e,t){const n=e?.walletButtonsConfiguration?.googlePay,r=_e(e,t),o=r?n?.buttonStyle?.dark:n?.buttonStyle?.light;return{hidden:Pe(n),type:be[n?.buttonType??"PLAIN"],appearance:ve[o??(r?"dark":"light")],borderRadius:Ee(e)}}(e,"dark"===u?"dark":"light");return y||null==Ce?null:X.jsx(s,{focusable:!0,accessible:!0,accessibilityRole:"button",accessibilityLabel:"Google Pay",onPress:c,style:a,children:X.jsx(Ce,{type:d,appearance:p,borderRadius:f,style:l.absoluteFill})})}const Oe=function(){if("ios"!==a.OS)return null;try{return null!=globalThis.nativeFabricUIManager?require("../codegen/components/HyperApplePayNativeComponent").default:n("HyperApplePayButton")}catch{return null}}();function Ne({options:e,session:t,onPaymentResult:n,onReady:r,onLoadError:o,disabled:a=!1,style:u}){const c=i(),y=ge({wallet:"apple_pay",label:"Apple Pay",session:t,onPaymentResult:n});he({wallet:"apple_pay",label:"Apple Pay",session:t,onReady:r,onLoadError:o});const{hidden:d,type:p,buttonStyle:f,borderRadius:m}=function(e,t){const n=e?.walletButtonsConfiguration?.applePay,r=_e(e,t),o=r?n?.buttonStyle?.dark:n?.buttonStyle?.light;return{hidden:Pe(n),type:we[n?.buttonType??"plain"],buttonStyle:Se[o??(r?"white":"black")],borderRadius:Ee(e)}}(e,"dark"===c?"dark":"light");return d||null==Oe?null:X.jsx(s,{focusable:!0,accessible:!0,accessibilityRole:"button",accessibilityLabel:"Apple Pay",onPress:y,disabled:a,style:u,children:X.jsx(Oe,{type:p,buttonStyle:f,buttonBorderRadius:m,disabled:a,style:l.absoluteFill})})}function Re(e){return R(!0),T(!1),v.initialise(e.publishableKey,e.platformPublishableKey??"",e.profileId??"",e.environment??"PROD",e.customEndpoints??{}).then(()=>(R(!1),{publishableKey:e.publishableKey,initPaymentSession:async t=>function(e,t){const n={hyperswitchConfig:e,paymentSessionConfig:t};return{presentPaymentSheet:U(n),getCustomerSavedPaymentMethods:$(n),getWalletSession:z(n),updateIntent:F}}(e,t),async elements(t){return{hyperswitchConfig:n=e,...H(n,t)};var n}})).catch(e=>{throw R(!1),console.error("Error initializing Hyperswitch SDK:",e),e})}const Ae={init:Re};export{Ne as ApplePayButton,le as CardCVCElement,ke as GooglePayButton,Z as HyperElements,Ae as Hyperswitch,ye as PaymentElement,Ae as default,pe as isApplePaySupported,de as isGooglePaySupported,me as isPlatformPaySupported,fe as isWalletSupported,Re as loadHyper,ae as useElements,oe as usePaymentSession,te as useWalletSession,ae as useWidgets};
|
|
11
11
|
//# sourceMappingURL=index.bundle.js.map
|