@unify-payment/node 0.0.5 → 0.0.6
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -15
- package/src/lib/bkash.ts +0 -73
- package/src/lib/lemonsqueezy.ts +0 -83
- package/src/lib/paypal.ts +0 -73
- package/src/lib/sslcommerz.ts +0 -72
- package/src/lib/stripe.ts +0 -43
- package/src/types/bkash.ts +0 -49
- package/src/types/lemonsqueezy.ts +0 -163
- package/src/types/paypal.ts +0 -57
- package/src/types/sslcommerz.ts +0 -116
- package/src/types/stripe.ts +0 -5
- package/src/utils/fetch.ts +0 -19
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Bkash } from "./lib/bkash";
|
|
2
|
-
import { LemonSqueezy } from "./lib/lemonsqueezy";
|
|
3
|
-
import { Paypal } from "./lib/paypal";
|
|
4
|
-
import { SSLCommerz } from "./lib/sslcommerz";
|
|
5
|
-
import { Stripe } from "./lib/stripe";
|
|
6
|
-
|
|
7
|
-
const UnifyPayment = {
|
|
8
|
-
LemonSqueezy,
|
|
9
|
-
Bkash,
|
|
10
|
-
Paypal,
|
|
11
|
-
SSLCommerz,
|
|
12
|
-
Stripe,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { UnifyPayment };
|
package/src/lib/bkash.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IBkashAccessTokenResponse,
|
|
3
|
-
IBkashCheckoutOptions,
|
|
4
|
-
IBkashCheckoutResponse,
|
|
5
|
-
IBkashErrorResponse,
|
|
6
|
-
IBkashPayloadProps,
|
|
7
|
-
} from "../types/bkash";
|
|
8
|
-
import { UnifyFetch } from "../utils/fetch";
|
|
9
|
-
|
|
10
|
-
export class Bkash extends UnifyFetch {
|
|
11
|
-
constructor(private options: IBkashPayloadProps) {
|
|
12
|
-
super();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
private getAppKey() {
|
|
16
|
-
return this.options.app_key;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
private getApiBaseUrl() {
|
|
20
|
-
return this.options.apiUrl;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private getApiRequestHeaders() {
|
|
24
|
-
return {
|
|
25
|
-
"Content-Type": "application/json",
|
|
26
|
-
Accept: "application/json",
|
|
27
|
-
username: this.options.username,
|
|
28
|
-
password: this.options.password,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async getAccessToken() {
|
|
33
|
-
const [res] = await this.jsonFetch<
|
|
34
|
-
IBkashAccessTokenResponse | IBkashErrorResponse
|
|
35
|
-
>(`${this.getApiBaseUrl()}/tokenized/checkout/token/grant`, {
|
|
36
|
-
method: "POST",
|
|
37
|
-
headers: this.getApiRequestHeaders(),
|
|
38
|
-
body: JSON.stringify({
|
|
39
|
-
app_key: this.options.app_key,
|
|
40
|
-
app_secret: this.options.app_secret,
|
|
41
|
-
}),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
if ("errorMessage" in res) {
|
|
45
|
-
throw new Error(res.errorMessage);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return res.id_token;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async getCheckoutUrl(options: IBkashCheckoutOptions) {
|
|
52
|
-
const accessToken = await this.getAccessToken();
|
|
53
|
-
|
|
54
|
-
const [res] = await this.jsonFetch<
|
|
55
|
-
IBkashCheckoutResponse | IBkashErrorResponse
|
|
56
|
-
>(`${this.getApiBaseUrl()}/tokenized/checkout/create`, {
|
|
57
|
-
method: "POST",
|
|
58
|
-
headers: {
|
|
59
|
-
Accept: "application/json",
|
|
60
|
-
"Content-Type": "application/json",
|
|
61
|
-
"X-App-Key": this.getAppKey(),
|
|
62
|
-
Authorization: `Bearer ${accessToken}`,
|
|
63
|
-
},
|
|
64
|
-
body: JSON.stringify(options),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if ("errorMessage" in res) {
|
|
68
|
-
throw new Error(res.errorMessage);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return res.bkashURL;
|
|
72
|
-
}
|
|
73
|
-
}
|
package/src/lib/lemonsqueezy.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ILemonSqueezyCheckoutOptions,
|
|
3
|
-
TGetCheckoutUrl,
|
|
4
|
-
TWebhookEventResponse,
|
|
5
|
-
} from "../types/lemonsqueezy";
|
|
6
|
-
import { UnifyFetch } from "../utils/fetch";
|
|
7
|
-
|
|
8
|
-
export class LemonSqueezy extends UnifyFetch {
|
|
9
|
-
constructor(private apiKey: string) {
|
|
10
|
-
super();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
private getApiBaseUrl() {
|
|
14
|
-
return "https://api.lemonsqueezy.com/v1";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private getApiRequestHeaders() {
|
|
18
|
-
return {
|
|
19
|
-
Accept: "application/vnd.api+json",
|
|
20
|
-
"Content-Type": "application/vnd.api+json",
|
|
21
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async getCheckoutUrl(options: ILemonSqueezyCheckoutOptions) {
|
|
26
|
-
const [res] = await this.jsonFetch<TGetCheckoutUrl>(
|
|
27
|
-
`${this.getApiBaseUrl()}/checkouts`,
|
|
28
|
-
{
|
|
29
|
-
method: "POST",
|
|
30
|
-
body: JSON.stringify({ data: options }),
|
|
31
|
-
headers: this.getApiRequestHeaders(),
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
if ("errors" in res) {
|
|
36
|
-
throw new Error(res.errors[0].detail);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return res.data.attributes.url;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async verifySignature(payload: {
|
|
43
|
-
signature: string;
|
|
44
|
-
secret: string;
|
|
45
|
-
body: string;
|
|
46
|
-
x_event: string;
|
|
47
|
-
}): Promise<TWebhookEventResponse> {
|
|
48
|
-
try {
|
|
49
|
-
const encoder = new TextEncoder();
|
|
50
|
-
|
|
51
|
-
const key = await crypto.subtle.importKey(
|
|
52
|
-
"raw",
|
|
53
|
-
encoder.encode(payload.secret),
|
|
54
|
-
{ name: "HMAC", hash: "SHA-256" },
|
|
55
|
-
false,
|
|
56
|
-
["sign"]
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const hmac = await crypto.subtle.sign(
|
|
60
|
-
"HMAC",
|
|
61
|
-
key,
|
|
62
|
-
encoder.encode(payload.body)
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const digest = Array.from(new Uint8Array(hmac))
|
|
66
|
-
.map((b) => b.toString(16).padStart(2, "0"))
|
|
67
|
-
.join("");
|
|
68
|
-
|
|
69
|
-
if (digest !== payload.signature) {
|
|
70
|
-
throw new Error("Invalid signature");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
event: JSON.parse(payload.body),
|
|
75
|
-
type: payload.x_event as any,
|
|
76
|
-
};
|
|
77
|
-
} catch (err) {
|
|
78
|
-
return {
|
|
79
|
-
error: err as Error,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
package/src/lib/paypal.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IPaypalAuthResponse,
|
|
3
|
-
IPaypalOptions,
|
|
4
|
-
IPayPalOrderResponse,
|
|
5
|
-
IPaypalPayload,
|
|
6
|
-
} from "../types/paypal";
|
|
7
|
-
import { UnifyFetch } from "../utils/fetch";
|
|
8
|
-
|
|
9
|
-
export class Paypal extends UnifyFetch {
|
|
10
|
-
constructor(private options: IPaypalOptions) {
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
private getApiBaseUrl() {
|
|
15
|
-
if (this.options.sandbox) {
|
|
16
|
-
return "https://api-m.sandbox.paypal.com";
|
|
17
|
-
}
|
|
18
|
-
return "https://api.paypal.com";
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
private getClientId() {
|
|
22
|
-
return this.options.clientId;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private getClientSecret() {
|
|
26
|
-
return this.options.clientSecret;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private getApiCheckoutUrl() {
|
|
30
|
-
return `${this.getApiBaseUrl()}/v2/checkout/orders`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async getAccessToken() {
|
|
34
|
-
const url = `${this.getApiBaseUrl()}/v1/oauth2/token`;
|
|
35
|
-
|
|
36
|
-
const auth = btoa(`${this.getClientId()}:${this.getClientSecret()}`);
|
|
37
|
-
|
|
38
|
-
const [response] = await this.jsonFetch<IPaypalAuthResponse>(url, {
|
|
39
|
-
method: "POST",
|
|
40
|
-
headers: {
|
|
41
|
-
Authorization: `Basic ${auth}`,
|
|
42
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
43
|
-
},
|
|
44
|
-
body: "grant_type=client_credentials",
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return response.access_token;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async getCheckoutUrl(payload: IPaypalPayload) {
|
|
51
|
-
const accessToken = await this.getAccessToken();
|
|
52
|
-
|
|
53
|
-
const [res] = await this.jsonFetch<IPayPalOrderResponse>(
|
|
54
|
-
this.getApiCheckoutUrl(),
|
|
55
|
-
{
|
|
56
|
-
method: "POST",
|
|
57
|
-
body: JSON.stringify(payload),
|
|
58
|
-
headers: {
|
|
59
|
-
"Content-Type": "application/json",
|
|
60
|
-
Authorization: `Bearer ${accessToken}`,
|
|
61
|
-
},
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const url = res.links.find((link) => link.rel === "approve")?.href;
|
|
66
|
-
|
|
67
|
-
if (!url) {
|
|
68
|
-
throw new Error("Failed to get checkout url");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return url;
|
|
72
|
-
}
|
|
73
|
-
}
|
package/src/lib/sslcommerz.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ISSLCommerzCheckoutResponse,
|
|
3
|
-
ISSLCommerzCreateCheckoutPayload,
|
|
4
|
-
ISSLCommerzOptions,
|
|
5
|
-
} from "../types/sslcommerz";
|
|
6
|
-
import { UnifyFetch } from "../utils/fetch";
|
|
7
|
-
|
|
8
|
-
export class SSLCommerz extends UnifyFetch {
|
|
9
|
-
constructor(private options: ISSLCommerzOptions) {
|
|
10
|
-
super();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
private getApiBaseUrl() {
|
|
14
|
-
return this.options.apiUrl;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private getApiCheckoutUrl() {
|
|
18
|
-
return `${this.getApiBaseUrl()}/gwprocess/v4/api.php`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
private getApiValidationUrl() {
|
|
22
|
-
return `${this.getApiBaseUrl()}/validator/api/validationserverAPI.php`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private getApiRefundUrl() {
|
|
26
|
-
return `${this.getApiBaseUrl()}/validator/api/merchantTransIDvalidationAPI.php`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private getApiRefundQueryUrl() {
|
|
30
|
-
return `${this.getApiBaseUrl()}/validator/api/merchantTransIDvalidationAPI.php`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private getApiTransactionQueryBySessionIdUrl() {
|
|
34
|
-
return `${this.getApiBaseUrl()}/validator/api/merchantTransIDvalidationAPI.php`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private getApiTransactionQueryByTransactionIdUrl() {
|
|
38
|
-
return `${this.getApiBaseUrl()}/validator/api/merchantTransIDvalidationAPI.php`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private getApiHeaders() {
|
|
42
|
-
return {
|
|
43
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private urlFormEncode(payload: Record<string, string | number>) {
|
|
48
|
-
return Object.entries(payload)
|
|
49
|
-
.map(
|
|
50
|
-
([key, value]) =>
|
|
51
|
-
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
|
|
52
|
-
)
|
|
53
|
-
.join("&");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async getCheckoutUrl(payload: ISSLCommerzCreateCheckoutPayload) {
|
|
57
|
-
const [res] = await this.jsonFetch<ISSLCommerzCheckoutResponse>(
|
|
58
|
-
this.getApiCheckoutUrl(),
|
|
59
|
-
{
|
|
60
|
-
method: "POST",
|
|
61
|
-
body: this.urlFormEncode(payload),
|
|
62
|
-
headers: this.getApiHeaders(),
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
if (res.status === "FAILED") {
|
|
67
|
-
throw new Error(res.failedreason);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return res.redirectGatewayURL;
|
|
71
|
-
}
|
|
72
|
-
}
|
package/src/lib/stripe.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Stripe as StripeSDK } from "stripe";
|
|
2
|
-
import { TStripeWebhookEventResponse } from "../types/stripe";
|
|
3
|
-
|
|
4
|
-
export class Stripe {
|
|
5
|
-
private stripe: StripeSDK;
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
8
|
-
private apiKey: string,
|
|
9
|
-
config?: StripeSDK.StripeConfig
|
|
10
|
-
) {
|
|
11
|
-
this.stripe = new StripeSDK(apiKey, config);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async getCheckoutUrl(params: StripeSDK.Checkout.SessionCreateParams) {
|
|
15
|
-
const session = await this.stripe.checkout.sessions.create(params);
|
|
16
|
-
if (!session.url) {
|
|
17
|
-
throw new Error("Failed to get checkout url");
|
|
18
|
-
}
|
|
19
|
-
return session.url;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async verifySignature(payload: {
|
|
23
|
-
signature: string;
|
|
24
|
-
secret: string;
|
|
25
|
-
body: string;
|
|
26
|
-
}): Promise<TStripeWebhookEventResponse> {
|
|
27
|
-
try {
|
|
28
|
-
const event = await this.stripe.webhooks.constructEventAsync(
|
|
29
|
-
payload.body,
|
|
30
|
-
payload.signature,
|
|
31
|
-
payload.secret
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
event,
|
|
36
|
-
};
|
|
37
|
-
} catch (err) {
|
|
38
|
-
return {
|
|
39
|
-
error: err as Error,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/types/bkash.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export interface IBkashAccessTokenResponse {
|
|
2
|
-
expires_in: string;
|
|
3
|
-
id_token: string;
|
|
4
|
-
refresh_token: string;
|
|
5
|
-
token_type: "Bearer" | string;
|
|
6
|
-
statusCode: string;
|
|
7
|
-
statusMessage: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface IBkashErrorResponse {
|
|
11
|
-
errorCode: string;
|
|
12
|
-
errorMessage: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface IBkashCheckoutOptions {
|
|
16
|
-
code: "0011";
|
|
17
|
-
payerReference: string;
|
|
18
|
-
callbackURL: string;
|
|
19
|
-
amount: string;
|
|
20
|
-
currency: "BDT";
|
|
21
|
-
intent: "sale";
|
|
22
|
-
merchantInvoiceNumber: string;
|
|
23
|
-
merchantAssociationInfo?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface IBkashCheckoutResponse {
|
|
27
|
-
paymentID: string;
|
|
28
|
-
paymentCreateTime: string;
|
|
29
|
-
transactionStatus: string;
|
|
30
|
-
amount: string;
|
|
31
|
-
currency: "BDT";
|
|
32
|
-
intent: "sale";
|
|
33
|
-
merchantInvoiceNumber: string;
|
|
34
|
-
bkashURL: string;
|
|
35
|
-
callbackURL: string;
|
|
36
|
-
successCallbackURL: string;
|
|
37
|
-
failureCallbackURL: string;
|
|
38
|
-
cancelledCallbackURL: string;
|
|
39
|
-
statusCode: string;
|
|
40
|
-
statusMessage: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface IBkashPayloadProps {
|
|
44
|
-
apiUrl: string;
|
|
45
|
-
username: string;
|
|
46
|
-
password: string;
|
|
47
|
-
app_key: string;
|
|
48
|
-
app_secret: string;
|
|
49
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
export type TLemonSqueezyWebhookEvents =
|
|
2
|
-
| "order_created"
|
|
3
|
-
| "order_refunded"
|
|
4
|
-
| "subscription_created"
|
|
5
|
-
| "subscription_updated"
|
|
6
|
-
| "subscription_cancelled"
|
|
7
|
-
| "subscription_resumed"
|
|
8
|
-
| "subscription_expired"
|
|
9
|
-
| "subscription_paused"
|
|
10
|
-
| "subscription_unpaused"
|
|
11
|
-
| "subscription_payment_success"
|
|
12
|
-
| "subscription_payment_failed"
|
|
13
|
-
| "subscription_payment_recovered"
|
|
14
|
-
| "subscription_payment_refunded"
|
|
15
|
-
| "license_key_created"
|
|
16
|
-
| "license_key_updated";
|
|
17
|
-
|
|
18
|
-
export type TGetCheckoutUrl =
|
|
19
|
-
| { data: { attributes: { url: string } } }
|
|
20
|
-
| { errors: [{ detail: string }] };
|
|
21
|
-
|
|
22
|
-
export type TWebhookEventResponse =
|
|
23
|
-
| { error: Error }
|
|
24
|
-
| {
|
|
25
|
-
event: ILemonSqueezyWebhookEeventResponse;
|
|
26
|
-
type: TLemonSqueezyWebhookEvents;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export interface ILemonSqueezyWebhookEeventResponse {
|
|
30
|
-
meta: {
|
|
31
|
-
event_name: string;
|
|
32
|
-
custom_data: {
|
|
33
|
-
customer_id: number;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
data: {
|
|
37
|
-
type: "orders" | "subscriptions";
|
|
38
|
-
id: string;
|
|
39
|
-
attributes: {
|
|
40
|
-
store_id: number;
|
|
41
|
-
customer_id: number;
|
|
42
|
-
identifier: string;
|
|
43
|
-
order_number: number;
|
|
44
|
-
user_name: string;
|
|
45
|
-
user_email: string;
|
|
46
|
-
currency: string;
|
|
47
|
-
currency_rate: string;
|
|
48
|
-
subtotal: number;
|
|
49
|
-
discount_total: number;
|
|
50
|
-
tax: number;
|
|
51
|
-
total: number;
|
|
52
|
-
subtotal_usd: number;
|
|
53
|
-
discount_total_usd: number;
|
|
54
|
-
tax_usd: number;
|
|
55
|
-
total_usd: number;
|
|
56
|
-
tax_name: string;
|
|
57
|
-
tax_rate: string;
|
|
58
|
-
status: string;
|
|
59
|
-
status_formatted: string;
|
|
60
|
-
refunded: boolean;
|
|
61
|
-
refunded_at: any;
|
|
62
|
-
subtotal_formatted: string;
|
|
63
|
-
discount_total_formatted: string;
|
|
64
|
-
tax_formatted: string;
|
|
65
|
-
total_formatted: string;
|
|
66
|
-
first_order_item: {
|
|
67
|
-
id: number;
|
|
68
|
-
order_id: number;
|
|
69
|
-
product_id: number;
|
|
70
|
-
variant_id: number;
|
|
71
|
-
product_name: string;
|
|
72
|
-
variant_name: string;
|
|
73
|
-
price: number;
|
|
74
|
-
created_at: string;
|
|
75
|
-
updated_at: string;
|
|
76
|
-
deleted_at: any;
|
|
77
|
-
test_mode: boolean;
|
|
78
|
-
};
|
|
79
|
-
urls: {
|
|
80
|
-
receipt: string;
|
|
81
|
-
};
|
|
82
|
-
created_at: string;
|
|
83
|
-
updated_at: string;
|
|
84
|
-
};
|
|
85
|
-
relationships: {
|
|
86
|
-
store: {
|
|
87
|
-
links: {
|
|
88
|
-
related: string;
|
|
89
|
-
self: string;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
customer: {
|
|
93
|
-
links: {
|
|
94
|
-
related: string;
|
|
95
|
-
self: string;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
"order-items": {
|
|
99
|
-
links: {
|
|
100
|
-
related: string;
|
|
101
|
-
self: string;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
subscriptions: {
|
|
105
|
-
links: {
|
|
106
|
-
related: string;
|
|
107
|
-
self: string;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
"license-keys": {
|
|
111
|
-
links: {
|
|
112
|
-
related: string;
|
|
113
|
-
self: string;
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
"discount-redemptions": {
|
|
117
|
-
links: {
|
|
118
|
-
related: string;
|
|
119
|
-
self: string;
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
links: {
|
|
124
|
-
self: string;
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface ILemonSqueezyCheckoutOptions {
|
|
130
|
-
type: "checkouts";
|
|
131
|
-
attributes?: {
|
|
132
|
-
custom_price?: number;
|
|
133
|
-
product_options?: {
|
|
134
|
-
redirect_url?: string;
|
|
135
|
-
enabled_variants?: number[];
|
|
136
|
-
};
|
|
137
|
-
checkout_options?: {
|
|
138
|
-
button_color: string;
|
|
139
|
-
};
|
|
140
|
-
checkout_data?: {
|
|
141
|
-
discount_code?: string;
|
|
142
|
-
custom?: {
|
|
143
|
-
user_id: number;
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
expires_at?: string;
|
|
147
|
-
preview?: boolean;
|
|
148
|
-
};
|
|
149
|
-
relationships: {
|
|
150
|
-
store: {
|
|
151
|
-
data: {
|
|
152
|
-
type: string;
|
|
153
|
-
id: string;
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
variant: {
|
|
157
|
-
data: {
|
|
158
|
-
type: string;
|
|
159
|
-
id: string;
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
}
|
package/src/types/paypal.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export interface IPaypalOptions {
|
|
2
|
-
clientId: string;
|
|
3
|
-
clientSecret: string;
|
|
4
|
-
sandbox?: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface IPaypalPayload {
|
|
8
|
-
intent: "CAPTURE";
|
|
9
|
-
purchase_units: {
|
|
10
|
-
items: {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
quantity: number;
|
|
14
|
-
unit_amount: {
|
|
15
|
-
currency_code: "USD" | "EUR";
|
|
16
|
-
value: string;
|
|
17
|
-
};
|
|
18
|
-
}[];
|
|
19
|
-
|
|
20
|
-
amount: {
|
|
21
|
-
currency_code: "USD" | "EUR";
|
|
22
|
-
value: string;
|
|
23
|
-
breakdown: {
|
|
24
|
-
item_total: {
|
|
25
|
-
currency_code: "USD" | "EUR";
|
|
26
|
-
value: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
}[];
|
|
31
|
-
application_context: {
|
|
32
|
-
return_url: string;
|
|
33
|
-
cancel_url: string;
|
|
34
|
-
shipping_preference?: "NO_SHIPPING";
|
|
35
|
-
user_action?: "PAY_NOW";
|
|
36
|
-
brand_name?: string;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface IPaypalAuthResponse {
|
|
41
|
-
access_token: string;
|
|
42
|
-
token_type: string;
|
|
43
|
-
app_id: string;
|
|
44
|
-
expires_in: number;
|
|
45
|
-
nonce: string;
|
|
46
|
-
scope: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface IPayPalOrderResponse {
|
|
50
|
-
id: string;
|
|
51
|
-
status: string;
|
|
52
|
-
links: {
|
|
53
|
-
href: string;
|
|
54
|
-
rel: string;
|
|
55
|
-
method: string;
|
|
56
|
-
}[];
|
|
57
|
-
}
|
package/src/types/sslcommerz.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
export type ISSLCommerzCreateCheckoutPayload =
|
|
2
|
-
| {
|
|
3
|
-
tran_id: string;
|
|
4
|
-
store_id: string;
|
|
5
|
-
store_passwd: string;
|
|
6
|
-
|
|
7
|
-
total_amount: number;
|
|
8
|
-
currency: "USD" | "EUR";
|
|
9
|
-
|
|
10
|
-
success_url?: string;
|
|
11
|
-
cancel_url?: string;
|
|
12
|
-
|
|
13
|
-
cus_name: string;
|
|
14
|
-
cus_email: string;
|
|
15
|
-
cus_add1: string;
|
|
16
|
-
cus_add2?: string;
|
|
17
|
-
cus_city: string;
|
|
18
|
-
cus_state: string;
|
|
19
|
-
cus_postcode: string;
|
|
20
|
-
cus_country: string;
|
|
21
|
-
cus_phone: string;
|
|
22
|
-
cus_fax?: string;
|
|
23
|
-
|
|
24
|
-
shipping_method: "NO";
|
|
25
|
-
|
|
26
|
-
product_name: string;
|
|
27
|
-
product_category: string;
|
|
28
|
-
product_profile:
|
|
29
|
-
| "general"
|
|
30
|
-
| "physical-goods"
|
|
31
|
-
| "non-physical-goods"
|
|
32
|
-
| "airline-tickets"
|
|
33
|
-
| "travel-vertical"
|
|
34
|
-
| "telecom-vertical";
|
|
35
|
-
}
|
|
36
|
-
| {
|
|
37
|
-
tran_id: string;
|
|
38
|
-
store_id: string;
|
|
39
|
-
store_passwd: string;
|
|
40
|
-
|
|
41
|
-
total_amount: number;
|
|
42
|
-
currency: "USD" | "EUR";
|
|
43
|
-
|
|
44
|
-
success_url?: string;
|
|
45
|
-
cancel_url?: string;
|
|
46
|
-
|
|
47
|
-
cus_name: string;
|
|
48
|
-
cus_email: string;
|
|
49
|
-
cus_add1: string;
|
|
50
|
-
cus_add2?: string;
|
|
51
|
-
cus_city: string;
|
|
52
|
-
cus_state: string;
|
|
53
|
-
cus_postcode: string;
|
|
54
|
-
cus_country: string;
|
|
55
|
-
cus_phone: string;
|
|
56
|
-
cus_fax?: string;
|
|
57
|
-
|
|
58
|
-
shipping_method: "YES";
|
|
59
|
-
|
|
60
|
-
ship_name: string;
|
|
61
|
-
ship_add1: string;
|
|
62
|
-
ship_add2?: string;
|
|
63
|
-
ship_city: string;
|
|
64
|
-
ship_state: string;
|
|
65
|
-
ship_postcode: string;
|
|
66
|
-
ship_country: string;
|
|
67
|
-
|
|
68
|
-
product_name: string;
|
|
69
|
-
product_category: string;
|
|
70
|
-
product_profile:
|
|
71
|
-
| "general"
|
|
72
|
-
| "physical-goods"
|
|
73
|
-
| "non-physical-goods"
|
|
74
|
-
| "airline-tickets"
|
|
75
|
-
| "travel-vertical"
|
|
76
|
-
| "telecom-vertical";
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export interface ISSLCommerzCheckoutResponse {
|
|
80
|
-
status: "SUCCESS" | "FAILED";
|
|
81
|
-
failedreason: string;
|
|
82
|
-
sessionkey: string;
|
|
83
|
-
gw: {
|
|
84
|
-
visa: string;
|
|
85
|
-
master: string;
|
|
86
|
-
amex: string;
|
|
87
|
-
othercards: string;
|
|
88
|
-
internetbanking: string;
|
|
89
|
-
mobilebanking: string;
|
|
90
|
-
};
|
|
91
|
-
redirectGatewayURL: string;
|
|
92
|
-
directPaymentURLBank: string;
|
|
93
|
-
directPaymentURLCard: string;
|
|
94
|
-
directPaymentURL: string;
|
|
95
|
-
redirectGatewayURLFailed: string;
|
|
96
|
-
GatewayPageURL: string;
|
|
97
|
-
storeBanner: string;
|
|
98
|
-
storeLogo: string;
|
|
99
|
-
store_name: string;
|
|
100
|
-
desc: {
|
|
101
|
-
name: string;
|
|
102
|
-
type: string;
|
|
103
|
-
logo: string;
|
|
104
|
-
gw: string;
|
|
105
|
-
r_flag?: string;
|
|
106
|
-
redirectGatewayURL?: string;
|
|
107
|
-
}[];
|
|
108
|
-
is_direct_pay_enable: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export type ISSLCommerzOptions = {
|
|
112
|
-
apiUrl: string;
|
|
113
|
-
store_id: string;
|
|
114
|
-
store_url?: string;
|
|
115
|
-
store_passwd: string;
|
|
116
|
-
};
|
package/src/types/stripe.ts
DELETED
package/src/utils/fetch.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
type TFetchOptions = {
|
|
2
|
-
method?: string;
|
|
3
|
-
headers?: HeadersInit;
|
|
4
|
-
body?: BodyInit;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export class UnifyFetch {
|
|
8
|
-
async jsonFetch<T>(
|
|
9
|
-
url: string,
|
|
10
|
-
options?: TFetchOptions
|
|
11
|
-
): Promise<[T, Response]> {
|
|
12
|
-
const req = await fetch(url, options);
|
|
13
|
-
const res = (await req.json()) as T;
|
|
14
|
-
|
|
15
|
-
return [res, req];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async axios<T>(url: string, options?: TFetchOptions) {}
|
|
19
|
-
}
|