@first-iraqi-bank/sdk 0.1.0 → 0.1.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 +8 -23
- package/dist/payment.cjs +13 -3
- package/dist/payment.d.cts +2 -1
- package/dist/payment.d.ts +2 -1
- package/dist/payment.js +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,30 +42,10 @@ pnpm add @first-iraqi-bank/sdk
|
|
|
42
42
|
|
|
43
43
|
### deno
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
import { PaymentSDK } from "npm:@first-iraqi-bank/sdk@pre/payment"
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Or after adding the package to the import maps of your `deno.json` file:
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"imports": {
|
|
56
|
-
"@first-iraqi-bank/sdk": "npm:@first-iraqi-bank/sdk@pre"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
import using the name of the package only:
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
import { PaymentSDK } from "@first-iraqi-bank/sdk/payment"
|
|
45
|
+
```sh
|
|
46
|
+
deno add npm:@first-iraqi-bank/sdk
|
|
65
47
|
```
|
|
66
48
|
|
|
67
|
-
in `deno.json`:
|
|
68
|
-
|
|
69
49
|
### bun
|
|
70
50
|
|
|
71
51
|
```sh
|
|
@@ -151,6 +131,9 @@ This method sends a request to the First Iraqi Bank's server, creating a payment
|
|
|
151
131
|
1. Bigger than 12 Hours
|
|
152
132
|
2. Smaller than 7 Days
|
|
153
133
|
|
|
134
|
+
- `redirectUri` _(optional)_: an instance of [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL_API) class, you can provide
|
|
135
|
+
a URL of your app where the user should be redirected when the payment was authorized, for example if you want FIB app to redirect user
|
|
136
|
+
back to some screen inside your app/website, this is used when you use **Pay with FIB** button in your.
|
|
154
137
|
- `statusCallbackUrl` _(optional)_: an instance of [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL_API) class, this must be the URL of your backend and specifically of an endpoint that can accept `POST` request, as FIB backend will call this endpoint when the status of the transaction changes. Omit it if you're not interested.
|
|
155
138
|
|
|
156
139
|
2. `accessToken`: a previously fetched access token from [`authenticate`](#authenticate) method.
|
|
@@ -164,7 +147,8 @@ import { FIB } from "./fib.js"
|
|
|
164
147
|
const paymentInput = {
|
|
165
148
|
amount: 1000, // amount in IQD
|
|
166
149
|
description: "Payment for Order #12345",
|
|
167
|
-
|
|
150
|
+
redirectUri: new URL("https://example.com/payments"),
|
|
151
|
+
statusCallbackUrl: new URL("https://example.com/api/callbacks/payment/status"),
|
|
168
152
|
refundableFor: { days: 1 },
|
|
169
153
|
expiresIn: { hours: 1 },
|
|
170
154
|
}
|
|
@@ -245,6 +229,7 @@ const res = await FIB.refundPayment(paymentId, accessToken)
|
|
|
245
229
|
type PaymentInput = {
|
|
246
230
|
amount: number
|
|
247
231
|
description?: string
|
|
232
|
+
redirectUri?: URL
|
|
248
233
|
statusCallbackUrl?: URL
|
|
249
234
|
expiresIn?: Duration
|
|
250
235
|
refundableFor?: Duration
|
package/dist/payment.cjs
CHANGED
|
@@ -89,11 +89,13 @@ var HTTP = class extends BaseHTTP {
|
|
|
89
89
|
description,
|
|
90
90
|
expiresIn,
|
|
91
91
|
refundableFor,
|
|
92
|
+
redirectUri,
|
|
92
93
|
statusCallbackUrl
|
|
93
94
|
}, accessToken, signal) {
|
|
94
95
|
const url = new URL("/protected/v1/payments", this.getBaseUrl());
|
|
95
96
|
const body = {
|
|
96
97
|
description,
|
|
98
|
+
redirectUri: redirectUri?.toString(),
|
|
97
99
|
statusCallbackUrl: statusCallbackUrl?.toString(),
|
|
98
100
|
refundableFor: refundableFor ? formatISODuration(refundableFor) : void 0,
|
|
99
101
|
expiresIn: expiresIn ? formatISODuration(expiresIn) : void 0,
|
|
@@ -154,13 +156,21 @@ var PaymentSDK = class {
|
|
|
154
156
|
}
|
|
155
157
|
createPayment({
|
|
156
158
|
amount,
|
|
157
|
-
statusCallbackUrl,
|
|
158
159
|
description,
|
|
160
|
+
expiresIn,
|
|
159
161
|
refundableFor,
|
|
160
|
-
|
|
162
|
+
redirectUri,
|
|
163
|
+
statusCallbackUrl
|
|
161
164
|
}, accessToken, signal) {
|
|
162
165
|
return this.#http.createPayment(
|
|
163
|
-
{
|
|
166
|
+
{
|
|
167
|
+
amount,
|
|
168
|
+
description,
|
|
169
|
+
expiresIn,
|
|
170
|
+
refundableFor,
|
|
171
|
+
redirectUri,
|
|
172
|
+
statusCallbackUrl
|
|
173
|
+
},
|
|
164
174
|
accessToken,
|
|
165
175
|
signal
|
|
166
176
|
);
|
package/dist/payment.d.cts
CHANGED
|
@@ -25,6 +25,7 @@ type PaymentInput = {
|
|
|
25
25
|
amount: number;
|
|
26
26
|
description?: string;
|
|
27
27
|
statusCallbackUrl?: URL;
|
|
28
|
+
redirectUri?: URL;
|
|
28
29
|
expiresIn?: Duration;
|
|
29
30
|
refundableFor?: Duration;
|
|
30
31
|
};
|
|
@@ -86,7 +87,7 @@ declare class PaymentSDK {
|
|
|
86
87
|
#private;
|
|
87
88
|
private constructor();
|
|
88
89
|
authenticate(signal?: AbortSignal): Promise<TypedResponse<TokenResponse>>;
|
|
89
|
-
createPayment({ amount,
|
|
90
|
+
createPayment({ amount, description, expiresIn, refundableFor, redirectUri, statusCallbackUrl, }: PaymentInput, accessToken: string, signal?: AbortSignal): Promise<TypedResponse<PaymentResponse>>;
|
|
90
91
|
getPaymentStatus(paymentId: string, accessToken: string, signal?: AbortSignal): Promise<TypedResponse<PaymentStatusResponse>>;
|
|
91
92
|
cancelPayment(paymentId: string, accessToken: string, signal?: AbortSignal): Promise<Response>;
|
|
92
93
|
refundPayment(paymentId: string, accessToken: string, signal?: AbortSignal): Promise<Response>;
|
package/dist/payment.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ type PaymentInput = {
|
|
|
25
25
|
amount: number;
|
|
26
26
|
description?: string;
|
|
27
27
|
statusCallbackUrl?: URL;
|
|
28
|
+
redirectUri?: URL;
|
|
28
29
|
expiresIn?: Duration;
|
|
29
30
|
refundableFor?: Duration;
|
|
30
31
|
};
|
|
@@ -86,7 +87,7 @@ declare class PaymentSDK {
|
|
|
86
87
|
#private;
|
|
87
88
|
private constructor();
|
|
88
89
|
authenticate(signal?: AbortSignal): Promise<TypedResponse<TokenResponse>>;
|
|
89
|
-
createPayment({ amount,
|
|
90
|
+
createPayment({ amount, description, expiresIn, refundableFor, redirectUri, statusCallbackUrl, }: PaymentInput, accessToken: string, signal?: AbortSignal): Promise<TypedResponse<PaymentResponse>>;
|
|
90
91
|
getPaymentStatus(paymentId: string, accessToken: string, signal?: AbortSignal): Promise<TypedResponse<PaymentStatusResponse>>;
|
|
91
92
|
cancelPayment(paymentId: string, accessToken: string, signal?: AbortSignal): Promise<Response>;
|
|
92
93
|
refundPayment(paymentId: string, accessToken: string, signal?: AbortSignal): Promise<Response>;
|
package/dist/payment.js
CHANGED
|
@@ -63,11 +63,13 @@ var HTTP = class extends BaseHTTP {
|
|
|
63
63
|
description,
|
|
64
64
|
expiresIn,
|
|
65
65
|
refundableFor,
|
|
66
|
+
redirectUri,
|
|
66
67
|
statusCallbackUrl
|
|
67
68
|
}, accessToken, signal) {
|
|
68
69
|
const url = new URL("/protected/v1/payments", this.getBaseUrl());
|
|
69
70
|
const body = {
|
|
70
71
|
description,
|
|
72
|
+
redirectUri: redirectUri?.toString(),
|
|
71
73
|
statusCallbackUrl: statusCallbackUrl?.toString(),
|
|
72
74
|
refundableFor: refundableFor ? formatISODuration(refundableFor) : void 0,
|
|
73
75
|
expiresIn: expiresIn ? formatISODuration(expiresIn) : void 0,
|
|
@@ -128,13 +130,21 @@ var PaymentSDK = class {
|
|
|
128
130
|
}
|
|
129
131
|
createPayment({
|
|
130
132
|
amount,
|
|
131
|
-
statusCallbackUrl,
|
|
132
133
|
description,
|
|
134
|
+
expiresIn,
|
|
133
135
|
refundableFor,
|
|
134
|
-
|
|
136
|
+
redirectUri,
|
|
137
|
+
statusCallbackUrl
|
|
135
138
|
}, accessToken, signal) {
|
|
136
139
|
return this.#http.createPayment(
|
|
137
|
-
{
|
|
140
|
+
{
|
|
141
|
+
amount,
|
|
142
|
+
description,
|
|
143
|
+
expiresIn,
|
|
144
|
+
refundableFor,
|
|
145
|
+
redirectUri,
|
|
146
|
+
statusCallbackUrl
|
|
147
|
+
},
|
|
138
148
|
accessToken,
|
|
139
149
|
signal
|
|
140
150
|
);
|