@stitch-money/client 1.0.0

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/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @stitch-money/client
2
+
3
+ A JavaScript client-side package for accepting digital wallet payments powered by [Stitch Money](https://stitch.money/).
4
+
5
+ # Install
6
+
7
+ ```bash
8
+ npm install @stitch-money/client
9
+ ```
10
+
11
+ # Usage
12
+
13
+ The SDK provides functionality for determining supported wallet payment methods and exports `onClick` event handler functions for verifying and creating payments with Apple Pay, Samsung Pay or Google Pay.
14
+
15
+ For more information, contact [Stitch](https://stitch.money/contact)
16
+
17
+ # License
18
+
19
+ The @stitch-money/client package is open source and available under the MIT license. See the [LICENSE](https://github.com/Stitch-Money/stitch-js/blob/main/LICENSE) file for more information.
@@ -0,0 +1,103 @@
1
+ declare enum WalletType {
2
+ ApplePay = "APPLE_PAY",
3
+ SamsungPay = "SAMSUNG_PAY",
4
+ GooglePay = "GOOGLE_PAY"
5
+ }
6
+ type StitchTransactionState = 'TransactionPending' | 'TransactionSuccess' | 'TransactionFailure';
7
+ interface StitchTransaction {
8
+ id: string;
9
+ externalReference: string;
10
+ quantity: number;
11
+ currency: string;
12
+ nonce: string;
13
+ status: StitchTransactionState;
14
+ statusReason?: string | null;
15
+ }
16
+ interface StitchWalletClientInitialisationProperties {
17
+ merchantId: string;
18
+ onCancelPayment?: () => void;
19
+ }
20
+ type WalletPaySession = ApplePaySession | SamsungPaySession;
21
+ interface ApplePaySession {
22
+ epochTimestamp: number;
23
+ expiresAt: number;
24
+ merchantSessionIdentifier: string;
25
+ nonce: string;
26
+ merchantIdentifier: string;
27
+ domainName: string;
28
+ displayName: string;
29
+ signature: string;
30
+ operationalAnalyticsIdentifier: string;
31
+ retries: number;
32
+ pspId: string;
33
+ }
34
+ interface SamsungPaySession {
35
+ id: string;
36
+ href: string;
37
+ encInfo: {
38
+ mod: string;
39
+ exp: string;
40
+ keyId: string;
41
+ };
42
+ }
43
+ type ApplePayVerifyCallback = (url: string) => Promise<WalletPaySession>;
44
+ type SamsungPayVerifyCallback = (amount: number, currency: string) => Promise<WalletPaySession>;
45
+ type CreatePaymentCallback = (paymentToken: ApplePayJS.ApplePayPaymentToken | google.payments.api.PaymentMethodTokenizationData['token']) => Promise<CreatePaymentCallbackResponse>;
46
+ interface CreatePaymentCallbackResponse {
47
+ status: StitchTransaction['status'];
48
+ }
49
+
50
+ /**
51
+ * Client-side SDK for handling Stitch wallet payments
52
+ */
53
+ declare class StitchWalletClientSdk {
54
+ private readonly merchantId;
55
+ private readonly onCancelPayment;
56
+ private applePayIsSupported;
57
+ private samsungPayIsSupported;
58
+ private googlePayIsSupported;
59
+ /**
60
+ * Initializes a StitchWalletClientSdk instance
61
+ *
62
+ * @param {StitchWalletClientInitialisationProperties} intialisationProperties
63
+ */
64
+ constructor(intialisationProperties: StitchWalletClientInitialisationProperties);
65
+ /**
66
+ * Checks if the specified payment method is supported on the device and/or browser
67
+ *
68
+ * @param {WalletType} walletType - The enum type of wallet we are confirming support for.
69
+ * @returns {Promise<boolean>} True if the payment method is supported, otherwise false.
70
+ */
71
+ isPaymentMethodSupported(walletType: WalletType): Promise<boolean>;
72
+ /**
73
+ * Returns a list of wallet payment methods supported on the device and/or browser
74
+ *
75
+ * @returns {Promise<WalletType[]>} Array of supported payment methods
76
+ */
77
+ supportedPaymentMethods(): Promise<WalletType[]>;
78
+ /**
79
+ * Returns a onClick handler function for an Apple Pay session encapsulating merchant validation and payment creation
80
+ *
81
+ * @param {string} currency - Payment currency in ISO 4127 format e.g. ZAR.
82
+ * @param {number} amount - Payment amount.
83
+ * @param {string} label - Payment sheet label
84
+ * @param {ApplePayVerifyCallback} verifyCallback - Callback for merchant validation.
85
+ * @param {CreatePaymentCallback} createPaymentCallback - Callback for payment creation.
86
+ * @returns {() => void} Function to handle Apple Pay button interaction
87
+ */
88
+ onClickApplePaySessionHandler(currency: string, amount: number, label: string, verifyCallback: ApplePayVerifyCallback, createPaymentCallback: CreatePaymentCallback): () => void;
89
+ /**
90
+ * Returns a onClick handler function for a Samsung Pay session encapsulating payment verification and creation
91
+ *
92
+ * @param {string} currency - Payment currency in ISO 4127 format e.g. ZAR.
93
+ * @param {number} amount - Payment amount.
94
+ * @param {string} callbackUrl - Payment callback URL.
95
+ * @param {number} cancelUrl - Payment cancellation URL.
96
+ * @param {SamsungPayVerifyCallback} verifyCallback - Callback for payment verification.
97
+ * @returns {() => void} Function to handle Apple Pay button interaction
98
+ */
99
+ onClickSamsungPaySessionHandler(currency: string, amount: number, callbackUrl: string, cancelUrl: string, verifyCallback: SamsungPayVerifyCallback): () => Promise<void>;
100
+ onClickGooglePaySessionHandler(createPaymentCallback: CreatePaymentCallback): (paymentData: google.payments.api.PaymentData) => void;
101
+ }
102
+
103
+ export { type ApplePaySession, type ApplePayVerifyCallback, type CreatePaymentCallback, type CreatePaymentCallbackResponse, type SamsungPaySession, type SamsungPayVerifyCallback, type StitchTransaction, type StitchTransactionState, type StitchWalletClientInitialisationProperties, StitchWalletClientSdk, type WalletPaySession, WalletType };
package/build/index.js ADDED
@@ -0,0 +1,3 @@
1
+ "use client"
2
+ var k=Object.defineProperty;var I=(s,e,t)=>e in s?k(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var y=(s,e,t)=>(I(s,typeof e!="symbol"?e+"":e,t),t);var i=(s,e,t)=>new Promise((a,l)=>{var u=n=>{try{p(t.next(n))}catch(r){l(r)}},m=n=>{try{p(t.throw(n))}catch(r){l(r)}},p=n=>n.done?a(n.value):Promise.resolve(n.value).then(u,m);p((t=t.apply(s,e)).next())});var b=(a=>(a.ApplePay="APPLE_PAY",a.SamsungPay="SAMSUNG_PAY",a.GooglePay="GOOGLE_PAY",a))(b||{});function h(s){return i(this,null,function*(){if(!window.ApplePaySession)return{canMakePayments:!1,canMakePaymentsWithActiveCard:!1,maxSupportedVersion:P()};let e=ApplePaySession.canMakePayments(),t=yield ApplePaySession.canMakePaymentsWithActiveCard(s);return{canMakePayments:e,canMakePaymentsWithActiveCard:t,maxSupportedVersion:P()}})}function P(){if(!window.ApplePaySession)return-1;let e=t=>t===0?-1:ApplePaySession.supportsVersion(t)?t:e(t-1);return e(14)}function d(){return!!window}var S=class extends Error{constructor(e){super(e),this.name="UserInputError"}},o=class extends Error{constructor(e){super(e),this.name="SessionError"}};var g=s=>s instanceof Error?s.toString():JSON.stringify(s);var C="9ba67dd8d5b247cfb3f76e",A=class{constructor(e){y(this,"merchantId");y(this,"onCancelPayment");y(this,"applePayIsSupported");y(this,"samsungPayIsSupported");y(this,"googlePayIsSupported");let{merchantId:t,onCancelPayment:a}=e;this.applePayIsSupported=!1,this.samsungPayIsSupported=d(),this.googlePayIsSupported=!0,this.merchantId=t,this.onCancelPayment=a!=null?a:()=>{}}isPaymentMethodSupported(e){return i(this,null,function*(){switch(e){case"APPLE_PAY":{let t=yield h(this.merchantId);return this.applePayIsSupported=t.canMakePayments,this.applePayIsSupported}case"SAMSUNG_PAY":return this.samsungPayIsSupported=d(),this.samsungPayIsSupported;case"GOOGLE_PAY":return this.googlePayIsSupported=!0,this.googlePayIsSupported;default:throw new S(`Unsupported wallet: ${e}`)}})}supportedPaymentMethods(){return i(this,null,function*(){let e=[],t=yield h(this.merchantId);return this.applePayIsSupported=t.canMakePayments,this.applePayIsSupported&&e.push("APPLE_PAY"),this.samsungPayIsSupported=d(),this.samsungPayIsSupported&&e.push("SAMSUNG_PAY"),this.googlePayIsSupported&&e.push("GOOGLE_PAY"),e})}onClickApplePaySessionHandler(e,t,a,l,u){if(!this.applePayIsSupported)throw new o("Apple Pay is not supported on this device");let m=P();return()=>{let p={countryCode:"ZA",currencyCode:e,supportedNetworks:["visa","masterCard"],merchantCapabilities:["supports3DS"],total:{label:a,amount:t.toString()}},n=new ApplePaySession(m,p);n.onvalidatemerchant=r=>i(this,null,function*(){try{let c=yield l(r.validationURL);n.completeMerchantValidation(c)}catch(c){throw new o(`Failed to complete merchant validation: ${g(c)}`)}}),n.onpaymentauthorized=r=>i(this,null,function*(){try{let c=r.payment.token,f=yield u(c);switch(f.status){case"TransactionPending":case"TransactionSuccess":{n.completePayment(ApplePaySession.STATUS_SUCCESS);break}case"TransactionFailure":{n.completePayment(ApplePaySession.STATUS_FAILURE);break}default:throw new o(`Invalid transaction status: ${f.status}`)}}catch(c){throw n.completePayment(ApplePaySession.STATUS_FAILURE),new o(`Failed to create payment: ${g(c)}`)}}),n.oncancel=()=>{this.onCancelPayment()},n.begin()}}onClickSamsungPaySessionHandler(e,t,a,l,u){return()=>i(this,null,function*(){let m=yield u(t,e),{id:p,href:n,encInfo:r}=m;if(window!=null&&window.SamsungPay)window.SamsungPay.connect(p,n,C,a,l,"uk",r.mod,r.exp,r.keyId);else throw new o("Samsung Pay client unavailable")})}onClickGooglePaySessionHandler(e){return t=>i(this,null,function*(){try{let a=yield e(t.paymentMethodData.tokenizationData.token);switch(a.status){case"TransactionPending":case"TransactionFailure":case"TransactionSuccess":break;default:throw new o(`Invalid transaction status: ${a.status}`)}}catch(a){throw new o(`Failed to create payment: ${g(a)}`)}})}};export{A as StitchWalletClientSdk,b as WalletType};
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts","../src/utils/browser-support.ts","../src/utils/errors.ts","../src/utils/helpers.ts","../src/wallets/client.ts"],"sourcesContent":["export enum WalletType {\n ApplePay = 'APPLE_PAY',\n SamsungPay = 'SAMSUNG_PAY',\n GooglePay = 'GOOGLE_PAY',\n}\n\nexport type StitchTransactionState =\n | 'TransactionPending'\n | 'TransactionSuccess'\n | 'TransactionFailure';\n\nexport interface StitchTransaction {\n id: string;\n externalReference: string;\n quantity: number;\n currency: string;\n nonce: string;\n status: StitchTransactionState;\n statusReason?: string | null;\n}\nexport interface StitchWalletClientInitialisationProperties {\n merchantId: string; // Apple Pay Merchant ID\n onCancelPayment?: () => void;\n}\n\nexport type WalletPaySession = ApplePaySession | SamsungPaySession;\n\nexport interface ApplePaySession {\n epochTimestamp: number;\n expiresAt: number;\n merchantSessionIdentifier: string;\n nonce: string;\n merchantIdentifier: string;\n domainName: string;\n displayName: string;\n signature: string;\n operationalAnalyticsIdentifier: string;\n retries: number;\n pspId: string;\n}\nexport interface SamsungPaySession {\n id: string;\n href: string;\n encInfo: {\n mod: string;\n exp: string;\n keyId: string;\n };\n}\n\nexport type ApplePayVerifyCallback = (url: string) => Promise<WalletPaySession>;\nexport type SamsungPayVerifyCallback = (\n amount: number,\n currency: string,\n) => Promise<WalletPaySession>;\n\nexport type CreatePaymentCallback = (\n paymentToken:\n | ApplePayJS.ApplePayPaymentToken\n | google.payments.api.PaymentMethodTokenizationData['token'],\n) => Promise<CreatePaymentCallbackResponse>;\n\nexport interface CreatePaymentCallbackResponse {\n status: StitchTransaction['status'];\n}\n","interface SamsungPay {\n connect: (\n transactionId: string,\n href: string,\n serviceId: string,\n callbackUrl: string,\n cancelUrl: string,\n countryCode: string,\n // eslint-disable-next-line unicorn/prevent-abbreviations\n publicKeyMod: string,\n publicKeyExp: string,\n keyId: string,\n ) => void;\n}\n\ndeclare global {\n interface Window {\n ApplePaySession: ApplePaySession;\n SamsungPay: SamsungPay;\n }\n}\n\n/**\n * Asynchronously checks for Apple Pay support, including payment capabilities and the maximum supported version.\n *\n * @param {string} merchantIdentifier - Merchant's Apple Pay identifier.\n * @returns {Promise<{\n * canMakePayments: boolean;\n * canMakePaymentsWithActiveCard: boolean;\n * maxSupportedVersion: number;\n * }>} An object indicating Apple Pay support details.\n */\nexport async function determineApplePaySupport(merchantIdentifier: string): Promise<{\n canMakePayments: boolean;\n canMakePaymentsWithActiveCard: boolean;\n maxSupportedVersion: number;\n}> {\n if (!window.ApplePaySession) {\n return {\n canMakePayments: false,\n canMakePaymentsWithActiveCard: false,\n maxSupportedVersion: getApplePayVersion(),\n };\n }\n const canMakePayments = ApplePaySession.canMakePayments();\n const canMakePaymentsWithActiveCard =\n await ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);\n return {\n canMakePayments,\n canMakePaymentsWithActiveCard,\n maxSupportedVersion: getApplePayVersion(),\n };\n}\n\n/**\n * Determines the maximum supported Apple Pay version by the browser.\n *\n * @returns {number} The maximum supported version, or -1 if unsupported.\n */\nexport function getApplePayVersion(): number {\n const noSupportedVersion = -1;\n if (!window.ApplePaySession) {\n return noSupportedVersion;\n }\n\n const findMaxSupportedVersion = (version: number): number => {\n if (version === 0) return noSupportedVersion;\n if (ApplePaySession.supportsVersion(version)) {\n return version;\n }\n return findMaxSupportedVersion(version - 1);\n };\n\n return findMaxSupportedVersion(14);\n}\n\n/**\n * Determines whether Samsung Pay is supported by the browser.\n *\n * @returns {boolean} Whether Samsung Pay is supported.\n */\nexport function determineSamsungPaySupport(): boolean {\n return !!window;\n}\n","export class ApiError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport class UserInputError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UserInputError';\n }\n}\n\nexport class SessionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'SessionError';\n }\n}\n","/**\n * Converts any error object into a string representation.\n *\n * @param {unknown} error - The error object to convert.\n * @returns {string} String representation of the error.\n */\nexport const getErrorAsString = (error: unknown): string => {\n return error instanceof Error ? error.toString() : JSON.stringify(error);\n};\n","import {\n WalletType,\n type ApplePayVerifyCallback,\n type CreatePaymentCallback,\n type SamsungPaySession,\n type SamsungPayVerifyCallback,\n type StitchWalletClientInitialisationProperties,\n} from 'src/types';\nimport {\n determineApplePaySupport,\n determineSamsungPaySupport,\n getApplePayVersion,\n} from 'src/utils/browser-support';\nimport { SessionError, UserInputError } from 'src/utils/errors';\nimport { getErrorAsString } from 'src/utils/helpers';\n\nconst SAMSUNG_PAY_SERVICE_ID = '9ba67dd8d5b247cfb3f76e';\n\n/**\n * Client-side SDK for handling Stitch wallet payments\n */\nexport class StitchWalletClientSdk {\n private readonly merchantId: string;\n private readonly onCancelPayment: () => void;\n\n private applePayIsSupported: boolean;\n private samsungPayIsSupported: boolean;\n private googlePayIsSupported: boolean;\n\n /**\n * Initializes a StitchWalletClientSdk instance\n *\n * @param {StitchWalletClientInitialisationProperties} intialisationProperties\n */\n constructor(intialisationProperties: StitchWalletClientInitialisationProperties) {\n const { merchantId, onCancelPayment } = intialisationProperties;\n this.applePayIsSupported = false;\n this.samsungPayIsSupported = determineSamsungPaySupport();\n this.googlePayIsSupported = true;\n this.merchantId = merchantId;\n this.onCancelPayment = onCancelPayment ?? (() => {});\n }\n\n /**\n * Checks if the specified payment method is supported on the device and/or browser\n *\n * @param {WalletType} walletType - The enum type of wallet we are confirming support for.\n * @returns {Promise<boolean>} True if the payment method is supported, otherwise false.\n */\n public async isPaymentMethodSupported(walletType: WalletType): Promise<boolean> {\n switch (walletType) {\n case WalletType.ApplePay: {\n const applePaySupport = await determineApplePaySupport(this.merchantId);\n this.applePayIsSupported = applePaySupport.canMakePayments;\n return this.applePayIsSupported;\n }\n case WalletType.SamsungPay: {\n this.samsungPayIsSupported = determineSamsungPaySupport();\n return this.samsungPayIsSupported;\n }\n case WalletType.GooglePay: {\n this.googlePayIsSupported = true;\n return this.googlePayIsSupported;\n }\n default: {\n throw new UserInputError(`Unsupported wallet: ${walletType}`);\n }\n }\n }\n\n /**\n * Returns a list of wallet payment methods supported on the device and/or browser\n *\n * @returns {Promise<WalletType[]>} Array of supported payment methods\n */\n public async supportedPaymentMethods(): Promise<WalletType[]> {\n const supportedWallets: WalletType[] = [];\n\n const applePaySupport = await determineApplePaySupport(this.merchantId);\n this.applePayIsSupported = applePaySupport.canMakePayments;\n if (this.applePayIsSupported) {\n supportedWallets.push(WalletType.ApplePay);\n }\n\n this.samsungPayIsSupported = determineSamsungPaySupport();\n if (this.samsungPayIsSupported) {\n supportedWallets.push(WalletType.SamsungPay);\n }\n\n if (this.googlePayIsSupported) {\n supportedWallets.push(WalletType.GooglePay);\n }\n\n return supportedWallets;\n }\n\n /**\n * Returns a onClick handler function for an Apple Pay session encapsulating merchant validation and payment creation\n *\n * @param {string} currency - Payment currency in ISO 4127 format e.g. ZAR.\n * @param {number} amount - Payment amount.\n * @param {string} label - Payment sheet label\n * @param {ApplePayVerifyCallback} verifyCallback - Callback for merchant validation.\n * @param {CreatePaymentCallback} createPaymentCallback - Callback for payment creation.\n * @returns {() => void} Function to handle Apple Pay button interaction\n */\n public onClickApplePaySessionHandler(\n currency: string,\n amount: number,\n label: string,\n verifyCallback: ApplePayVerifyCallback,\n createPaymentCallback: CreatePaymentCallback,\n ): () => void {\n if (!this.applePayIsSupported) {\n throw new SessionError('Apple Pay is not supported on this device');\n }\n\n const version = getApplePayVersion();\n\n return () => {\n const request: ApplePayJS.ApplePayPaymentRequest = {\n countryCode: 'ZA',\n currencyCode: currency,\n supportedNetworks: ['visa', 'masterCard'],\n merchantCapabilities: ['supports3DS'],\n total: {\n label,\n amount: amount.toString(),\n },\n };\n const session = new ApplePaySession(version, request);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n session.onvalidatemerchant = async (event) => {\n try {\n const verifyCallbackResponse = await verifyCallback(event.validationURL);\n session.completeMerchantValidation(verifyCallbackResponse);\n } catch (error) {\n throw new SessionError(\n `Failed to complete merchant validation: ${getErrorAsString(error)}`,\n );\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n session.onpaymentauthorized = async (event) => {\n try {\n const paymentToken = event.payment.token;\n const createPaymentCallbackResponse = await createPaymentCallback(paymentToken);\n\n switch (createPaymentCallbackResponse.status) {\n case 'TransactionPending':\n case 'TransactionSuccess': {\n session.completePayment(ApplePaySession.STATUS_SUCCESS);\n break;\n }\n case 'TransactionFailure': {\n session.completePayment(ApplePaySession.STATUS_FAILURE);\n break;\n }\n default: {\n throw new SessionError(\n `Invalid transaction status: ${createPaymentCallbackResponse.status}`,\n );\n }\n }\n } catch (error) {\n session.completePayment(ApplePaySession.STATUS_FAILURE);\n throw new SessionError(`Failed to create payment: ${getErrorAsString(error)}`);\n }\n };\n // eslint-disable-next-line unicorn/prefer-add-event-listener\n session.oncancel = () => {\n this.onCancelPayment();\n };\n\n session.begin();\n };\n }\n\n /**\n * Returns a onClick handler function for a Samsung Pay session encapsulating payment verification and creation\n *\n * @param {string} currency - Payment currency in ISO 4127 format e.g. ZAR.\n * @param {number} amount - Payment amount.\n * @param {string} callbackUrl - Payment callback URL.\n * @param {number} cancelUrl - Payment cancellation URL.\n * @param {SamsungPayVerifyCallback} verifyCallback - Callback for payment verification.\n * @returns {() => void} Function to handle Apple Pay button interaction\n */\n public onClickSamsungPaySessionHandler(\n currency: string,\n amount: number,\n callbackUrl: string,\n cancelUrl: string,\n verifyCallback: SamsungPayVerifyCallback,\n ): () => Promise<void> {\n return async () => {\n const verifyCallbackResponse = await verifyCallback(amount, currency);\n const { id, href, encInfo } = verifyCallbackResponse as SamsungPaySession;\n\n if (window?.SamsungPay) {\n window.SamsungPay.connect(\n id,\n href,\n SAMSUNG_PAY_SERVICE_ID,\n callbackUrl,\n cancelUrl,\n 'uk',\n encInfo.mod,\n encInfo.exp,\n encInfo.keyId,\n );\n } else {\n throw new SessionError('Samsung Pay client unavailable');\n }\n };\n }\n\n public onClickGooglePaySessionHandler(\n createPaymentCallback: CreatePaymentCallback,\n ): (paymentData: google.payments.api.PaymentData) => void {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return async (paymentData) => {\n try {\n const createPaymentCallbackResponse = await createPaymentCallback(\n paymentData.paymentMethodData.tokenizationData.token,\n );\n\n switch (createPaymentCallbackResponse.status) {\n case 'TransactionPending':\n case 'TransactionFailure':\n case 'TransactionSuccess': {\n break;\n }\n default: {\n throw new SessionError(\n `Invalid transaction status: ${createPaymentCallbackResponse.status}`,\n );\n }\n }\n } catch (error) {\n throw new SessionError(`Failed to create payment: ${getErrorAsString(error)}`);\n }\n };\n }\n}\n"],"mappings":";qXAAO,IAAKA,OACRA,EAAA,SAAW,YACXA,EAAA,WAAa,cACbA,EAAA,UAAY,aAHJA,OAAA,ICgCZ,SAAsBC,E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ApplePayVersion","canMakePayments","canMakePaymentsWithActiveCard","findMaxSupportedVersion","version","determineSamsungPaySupport","UserInputError","message","SessionError","getErrorAsString","error","SAMSUNG_PAY_SERVICE_ID","StitchWalletClientSdk","intialisationProperties","__publicField","merchantId","onCancelPayment","determineSamsungPaySupport","walletType","__async","applePaySupport","determineApplePaySupport","UserInputError","supportedWallets","currency","amount","label","verifyCallback","createPaymentCallback","SessionError","version","getApplePayVersion","request","session","event","verifyCallbackResponse","error","getErrorAsString","paymentToken","createPaymentCallbackResponse","callbackUrl","cancelUrl","id","href","encInfo","paymentData"]}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@stitch-money/client",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "JavaScript package for the Stitch SDK",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Stitch-Money/stitch-js.git",
9
+ "directory": "packages/client"
10
+ },
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "main": "./build/index.js",
14
+ "module": "./build/index.js",
15
+ "types": "./build/index.d.ts",
16
+ "files": [
17
+ "build"
18
+ ],
19
+ "scripts": {
20
+ "build": "wireit",
21
+ "lint": "eslint .",
22
+ "prepublishOnly": "wireit",
23
+ "test": "vitest",
24
+ "typecheck": "tsc --noEmit"
25
+ },
26
+ "dependencies": {},
27
+ "devDependencies": {
28
+ "@types/applepayjs": "14.0.6",
29
+ "@types/googlepay": "^0.7.6",
30
+ "@types/uuid": "9.0.8",
31
+ "@vitejs/plugin-react": "4.2.1",
32
+ "eslint-config-stitch": "workspace:*",
33
+ "jsdom": "24.0.0",
34
+ "prop-types": "^15.8.1",
35
+ "tsconfig-stitch": "workspace:*",
36
+ "tsup": "8.0.2",
37
+ "vite-tsconfig-paths": "4.3.1",
38
+ "vitest": "1.3.1"
39
+ },
40
+ "peerDependencies": {
41
+ "uuid": "9.0.1"
42
+ },
43
+ "wireit": {
44
+ "build": {
45
+ "command": "tsup",
46
+ "files": [
47
+ "src/**",
48
+ "tsup.config.ts"
49
+ ],
50
+ "output": [
51
+ "build/**"
52
+ ]
53
+ },
54
+ "prepublishOnly": {
55
+ "dependencies": [
56
+ "build"
57
+ ]
58
+ }
59
+ }
60
+ }