@superlogic/spree-pay 0.1.1 → 0.1.3

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 CHANGED
@@ -12,15 +12,17 @@ npm i @superlogic/spree-pay
12
12
 
13
13
  ```tsx
14
14
  import { useState } from 'react';
15
+
15
16
  import { SpreePay, SpreePayProvider, useSpreePay } from '@superlogic/spree-pay';
16
17
 
17
18
  const spreeEnv = {
18
- environment: 'dev', // 'stg' or 'prod' for other environments
19
- accessToken: 'demo-access-token', // Use env vars in production
19
+ tenantId: 'moca' // Keep moca for crypto payments on BASE network
20
+ environment: 'dev',
21
+ accessToken: 'eyJhbGciOiJSUzI1NiIs...', // Use user JWT token
22
+ redirect3dsURI: '/3ds' // Any valid URI in your app that captures 3ds redirect
20
23
  };
21
24
 
22
- const [status, setStatus] = useState<'idle' | 'processing' | 'success' | 'error'>('idle');
23
-
25
+ function Checkout() {
24
26
  return (
25
27
  <SpreePayProvider env={spreeEnv}>
26
28
  <CheckoutContent />
@@ -46,10 +48,25 @@ function CheckoutContent() {
46
48
 
47
49
  return (
48
50
  <div style={{ maxWidth: 540 }}>
49
- <SpreePay amount="$199.00" onProcess={handleProcess} />
51
+ <SpreePay amount={99} onProcess={handleProcess} />
50
52
  {status === 'success' && <p>Payment successful! Thank you for your order.</p>}
51
53
  {status === 'error' && <p>Payment failed. Please try again.</p>}
52
54
  </div>
53
55
  );
54
56
  }
57
+
58
+ import { useCapture3DS } from '@superlogic/spree-pay';
59
+
60
+ // example 3DS redirect page hosted on /3ds
61
+ export default function ThreeDSRedirectPage() {
62
+ // take payment intent from search params as payment_intent
63
+ const searchParams = exampleGetSearchParams();
64
+
65
+ // place that hook, it will take paymentIntent and close 3ds modal
66
+ useCapture3DS({ paymentIntent: searchParams['payment_intent'] });
67
+
68
+ // Render null or any other UI/Loader
69
+ return null;
70
+ }
71
+
55
72
  ```