@unify-payment/node 0.0.5 → 0.0.7
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/package.json +20 -12
- package/dist/index.d.mts +0 -345
- package/dist/index.d.ts +0 -345
- package/dist/index.js +0 -1
- package/dist/index.mjs +0 -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/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
|
-
}
|