@mygigsters/card-sdk 1.0.0 → 1.0.2
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 +52 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,7 +102,6 @@ GET /api/v1/client/me
|
|
|
102
102
|
|
|
103
103
|
| Environment | URL |
|
|
104
104
|
|-------------|-----|
|
|
105
|
-
| Local Development | `http://localhost:5000/api/v1/client/me` |
|
|
106
105
|
| Demo / QA | `https://qa-payments.mygigsters.com.au/api/v1/client/me` |
|
|
107
106
|
| Production | `https://prod-payments.mygigsters.com.au/api/v1/client/me` |
|
|
108
107
|
|
|
@@ -552,26 +551,61 @@ Runtime errors (Airwallex element failures, network issues, server rejections) a
|
|
|
552
551
|
|
|
553
552
|
## TypeScript
|
|
554
553
|
|
|
555
|
-
Type definitions are included at `dist/index.d.ts`.
|
|
554
|
+
Type definitions are included at `dist/index.d.ts`.
|
|
556
555
|
|
|
557
|
-
|
|
558
|
-
import { MygigstersCardSDK, MygigstersCardConfig, CardSuccessResponse } from '@mygigsters/card-sdk';
|
|
556
|
+
Import the SDK and its types:
|
|
559
557
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
apiSecret: process.env.MYGIGSTERS_API_SECRET!,
|
|
563
|
-
customerId: 'cus_hkdmcdjshhknkk4lc2t',
|
|
564
|
-
myGigsterId: '4407c3ba-10c9-4822-9f51-c2c96692f8d7',
|
|
565
|
-
containerId: 'mygigsters-card',
|
|
566
|
-
env: 'prod',
|
|
567
|
-
mode: 'dark',
|
|
568
|
-
onSuccess: (res: CardSuccessResponse) => {
|
|
569
|
-
console.log('Consent ID:', res.paymentConsentId);
|
|
570
|
-
},
|
|
571
|
-
};
|
|
558
|
+
```tsx
|
|
559
|
+
import { useEffect } from 'react';
|
|
572
560
|
|
|
573
|
-
|
|
574
|
-
|
|
561
|
+
import { MygigstersCardSDK } from '@mygigsters/card-sdk';
|
|
562
|
+
|
|
563
|
+
import type {
|
|
564
|
+
MygigstersCardConfig,
|
|
565
|
+
CardSuccessResponse,
|
|
566
|
+
} from '@mygigsters/card-sdk';
|
|
567
|
+
|
|
568
|
+
function SaveCardForm() {
|
|
569
|
+
useEffect(() => {
|
|
570
|
+
const initializeSDK = async () => {
|
|
571
|
+
const config: MygigstersCardConfig = {
|
|
572
|
+
apiKey: 'YOUR_API_KEY',
|
|
573
|
+
apiSecret: 'YOUR_API_SECRET',
|
|
574
|
+
|
|
575
|
+
customerId: 'cus_hkdmcdjshhknkk4lc2t',
|
|
576
|
+
myGigsterId: '4407c3ba-10c9-4822-9f51-c2c96692f8d7',
|
|
577
|
+
|
|
578
|
+
containerId: 'mygigsters-card',
|
|
579
|
+
|
|
580
|
+
env: 'demo',
|
|
581
|
+
mode: 'dark',
|
|
582
|
+
|
|
583
|
+
onSuccess: (res: CardSuccessResponse) => {
|
|
584
|
+
console.log('Card saved!');
|
|
585
|
+
console.log('Consent ID:', res.paymentConsentId);
|
|
586
|
+
},
|
|
587
|
+
|
|
588
|
+
onError: (err) => {
|
|
589
|
+
console.error('Card SDK error:', err);
|
|
590
|
+
},
|
|
591
|
+
|
|
592
|
+
onClose: () => {
|
|
593
|
+
console.log('Card form closed');
|
|
594
|
+
},
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
const sdk = new MygigstersCardSDK();
|
|
598
|
+
|
|
599
|
+
await sdk.init(config);
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
initializeSDK();
|
|
603
|
+
}, []);
|
|
604
|
+
|
|
605
|
+
return <div id="mygigsters-card" />;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export default SaveCardForm;
|
|
575
609
|
```
|
|
576
610
|
|
|
577
611
|
---
|
package/package.json
CHANGED