azirid-react 0.10.5 → 0.11.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 +40 -15
- package/dist/index.cjs +470 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -4
- package/dist/index.d.ts +33 -4
- package/dist/index.js +470 -109
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -639,9 +639,27 @@ const { data: providers } = usePaymentProviders()
|
|
|
639
639
|
// [{ provider: 'STRIPE', checkout: true, subscriptions: true }, ...]
|
|
640
640
|
```
|
|
641
641
|
|
|
642
|
+
### `useUploadTransferProof`
|
|
643
|
+
|
|
644
|
+
Upload a file (image or PDF) to S3 via presigned URL for use as transfer proof.
|
|
645
|
+
|
|
646
|
+
```tsx
|
|
647
|
+
import { useUploadTransferProof } from 'azirid-react'
|
|
648
|
+
|
|
649
|
+
const { upload, isUploading, publicUrl, error, reset } = useUploadTransferProof({
|
|
650
|
+
onSuccess: (result) => console.log('Uploaded:', result.publicUrl),
|
|
651
|
+
onError: (err) => console.error(err),
|
|
652
|
+
})
|
|
653
|
+
|
|
654
|
+
// Upload a file (returns { uploadUrl, publicUrl })
|
|
655
|
+
const result = await upload(file) // File from <input type="file">
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
**Accepted file types:** PNG, JPG, WebP, PDF (max 10MB)
|
|
659
|
+
|
|
642
660
|
### `useSubmitTransferProof`
|
|
643
661
|
|
|
644
|
-
Submit proof of a manual bank transfer payment.
|
|
662
|
+
Submit proof of a manual bank transfer payment (requires a pre-uploaded file URL).
|
|
645
663
|
|
|
646
664
|
```tsx
|
|
647
665
|
import { useSubmitTransferProof } from 'azirid-react'
|
|
@@ -651,9 +669,9 @@ const { submit, isPending } = useSubmitTransferProof({
|
|
|
651
669
|
})
|
|
652
670
|
|
|
653
671
|
submit({
|
|
654
|
-
|
|
672
|
+
intentId: 'intent_123',
|
|
655
673
|
fileUrl: 'https://storage.example.com/receipt.pdf',
|
|
656
|
-
amount:
|
|
674
|
+
amount: 29.99,
|
|
657
675
|
currency: 'USD',
|
|
658
676
|
notes: 'Bank transfer from Account #1234',
|
|
659
677
|
})
|
|
@@ -785,28 +803,30 @@ function CheckoutPage({ intentId }: { intentId: string }) {
|
|
|
785
803
|
|
|
786
804
|
### `useTransferPayment`
|
|
787
805
|
|
|
788
|
-
Hook for manual bank transfer payments. Pass an `intentId` and get a component with bank details +
|
|
806
|
+
Hook for manual bank transfer payments. Pass an `intentId` and get a component with bank details + functions to upload and submit proof of payment.
|
|
789
807
|
|
|
790
808
|
```tsx
|
|
791
809
|
import { useTransferPayment } from 'azirid-react'
|
|
792
810
|
|
|
793
811
|
function TransferPage({ intentId }: { intentId: string }) {
|
|
794
|
-
const {
|
|
812
|
+
const {
|
|
813
|
+
TransferDetails, uploadAndSubmitProof, status, error,
|
|
814
|
+
} = useTransferPayment({
|
|
795
815
|
intentId,
|
|
796
816
|
onProofSubmitted: (proof) => console.log('Proof sent:', proof.id),
|
|
797
817
|
onError: (err) => console.error(err),
|
|
798
818
|
})
|
|
799
819
|
|
|
820
|
+
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
821
|
+
const file = e.target.files?.[0]
|
|
822
|
+
if (file) uploadAndSubmitProof(file, 'Transfer ref #123')
|
|
823
|
+
}
|
|
824
|
+
|
|
800
825
|
return (
|
|
801
826
|
<div>
|
|
802
827
|
<TransferDetails />
|
|
803
|
-
{status === 'ready' &&
|
|
804
|
-
|
|
805
|
-
fileUrl: 'https://...', amount: 29.99, notes: 'Transfer ref #123'
|
|
806
|
-
})}>
|
|
807
|
-
Submit proof
|
|
808
|
-
</button>
|
|
809
|
-
)}
|
|
828
|
+
{status === 'ready' && <input type="file" accept="image/*,.pdf" onChange={handleFileChange} />}
|
|
829
|
+
{status === 'uploading' && <p>Uploading...</p>}
|
|
810
830
|
{status === 'submitting' && <p>Submitting...</p>}
|
|
811
831
|
{status === 'submitted' && <p>Proof submitted!</p>}
|
|
812
832
|
{status === 'error' && <p>Error: {error?.message}</p>}
|
|
@@ -825,9 +845,11 @@ function TransferPage({ intentId }: { intentId: string }) {
|
|
|
825
845
|
| Return | Type | Description |
|
|
826
846
|
|--------|------|-------------|
|
|
827
847
|
| `TransferDetails` | Component | Amount, bank details, and transfer instructions |
|
|
828
|
-
| `
|
|
829
|
-
| `
|
|
848
|
+
| `uploadAndSubmitProof` | `(file: File, notes?: string) => Promise<void>` | Upload file to S3 and submit proof in one step |
|
|
849
|
+
| `submitProof` | `(data) => void` | Submit transfer proof with pre-uploaded file URL |
|
|
850
|
+
| `status` | `TransferPaymentStatus` | `'idle' \| 'loading' \| 'ready' \| 'uploading' \| 'submitting' \| 'submitted' \| 'error'` |
|
|
830
851
|
| `checkoutData` | `CheckoutResponse \| null` | Full checkout response |
|
|
852
|
+
| `isUploading` | `boolean` | File upload in progress |
|
|
831
853
|
| `isSubmitting` | `boolean` | Proof submission in progress |
|
|
832
854
|
| `error` | `Error \| null` | Error details |
|
|
833
855
|
|
|
@@ -894,6 +916,7 @@ import { PayButton } from 'azirid-react'
|
|
|
894
916
|
| `onSuccess` | `(data) => void` | — | Called on successful checkout. For `MANUAL_TRANSFER` and `PAYPHONE`, deferred until the user closes the modal |
|
|
895
917
|
| `onError` | `(error) => void` | — | Called on error |
|
|
896
918
|
| `onProviderSelect` | `(provider: string) => void` | — | Called when a provider is selected |
|
|
919
|
+
| `onProofSubmitted` | `(proof) => void` | — | Called when transfer proof is submitted (MANUAL_TRANSFER only) |
|
|
897
920
|
| `children` | `ReactNode` | — | Button label |
|
|
898
921
|
| `disabled` | `boolean` | — | Disable the button |
|
|
899
922
|
|
|
@@ -1704,8 +1727,10 @@ import type {
|
|
|
1704
1727
|
| `BillingInvoice` | Invoice (`amount`, `currency`, `status`, `paidAt`, `invoiceUrl`, ...) |
|
|
1705
1728
|
| `PaymentProviderType` | `'STRIPE' \| 'PAYPAL' \| 'PAYPHONE' \| 'NUVEI' \| 'MANUAL_TRANSFER'` |
|
|
1706
1729
|
| `AvailableProvider` | Provider info (`provider`, `checkout`, `subscriptions`) |
|
|
1707
|
-
| `SubmitTransferProofData` | Transfer proof payload (`
|
|
1730
|
+
| `SubmitTransferProofData` | Transfer proof payload (`intentId`, `fileUrl`, `amount`, ...) |
|
|
1708
1731
|
| `TransferProof` | Transfer proof object (`status`: `PENDING_REVIEW \| APPROVED \| REJECTED`, ...) |
|
|
1732
|
+
| `UploadTransferProofRequest` | Upload request (`contentType`, `fileSize`) |
|
|
1733
|
+
| `UploadTransferProofResponse` | Upload response (`uploadUrl`, `publicUrl`) |
|
|
1709
1734
|
| `PayphoneWidgetConfig` | Payphone widget config (`token`, `storeId`, `amount`, ...) |
|
|
1710
1735
|
| `PaymentIntent` | Payment intent (`amount`, `subtotal?`, `taxRate?`, `taxAmount?`, `reference?`, ...) |
|
|
1711
1736
|
|