@paykit-sdk/gopay 1.0.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 +185 -0
- package/dist/controllers/auth.d.mts +19 -0
- package/dist/controllers/auth.d.ts +19 -0
- package/dist/controllers/auth.js +41 -0
- package/dist/controllers/auth.mjs +39 -0
- package/dist/gopay-provider.d.mts +58 -0
- package/dist/gopay-provider.d.ts +58 -0
- package/dist/gopay-provider.js +4757 -0
- package/dist/gopay-provider.mjs +4735 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4777 -0
- package/dist/index.mjs +4754 -0
- package/dist/schema.d.mts +295 -0
- package/dist/schema.d.ts +295 -0
- package/dist/schema.js +2 -0
- package/dist/schema.mjs +1 -0
- package/dist/utils/mapper.d.mts +12 -0
- package/dist/utils/mapper.d.ts +12 -0
- package/dist/utils/mapper.js +105 -0
- package/dist/utils/mapper.mjs +100 -0
- package/package.json +47 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@paykit-sdk/core');
|
|
4
|
+
|
|
5
|
+
// src/utils/mapper.ts
|
|
6
|
+
var paykitPayment$InboundSchema = (data) => {
|
|
7
|
+
const itemId = JSON.parse(data.additional_params?.find((param) => param.name === core.PAYKIT_METADATA_KEY)?.value ?? "{}").itemId;
|
|
8
|
+
const metadata = core.omitInternalMetadata(
|
|
9
|
+
data.additional_params?.reduce(
|
|
10
|
+
(acc, param) => {
|
|
11
|
+
acc[param.name] = String(param.value);
|
|
12
|
+
return acc;
|
|
13
|
+
},
|
|
14
|
+
{}
|
|
15
|
+
) ?? {}
|
|
16
|
+
);
|
|
17
|
+
return {
|
|
18
|
+
id: data.id.toString(),
|
|
19
|
+
amount: data.amount,
|
|
20
|
+
currency: data.currency,
|
|
21
|
+
customer: data.payer ?? { email: data.payer?.email ?? "" },
|
|
22
|
+
status: data.state,
|
|
23
|
+
product_id: itemId,
|
|
24
|
+
metadata
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
var paykitInvoice$InboundSchema = (data, isSubscription) => {
|
|
28
|
+
const quantity = JSON.parse(data.additional_params?.find((param) => param.name === core.PAYKIT_METADATA_KEY)?.value ?? "{}").qty;
|
|
29
|
+
const itemId = JSON.parse(data.additional_params?.find((param) => param.name === core.PAYKIT_METADATA_KEY)?.value ?? "{}").itemId;
|
|
30
|
+
const status = (() => {
|
|
31
|
+
if (data.state === "PAID") return "paid";
|
|
32
|
+
return "open";
|
|
33
|
+
})();
|
|
34
|
+
const paidAt = isSubscription ? new Date(data.recurrence?.recurrence_date_from ?? "") : /* @__PURE__ */ new Date();
|
|
35
|
+
const metadata = core.omitInternalMetadata(
|
|
36
|
+
data.additional_params?.reduce(
|
|
37
|
+
(acc, param) => {
|
|
38
|
+
acc[param.name] = String(param.value);
|
|
39
|
+
return acc;
|
|
40
|
+
},
|
|
41
|
+
{}
|
|
42
|
+
) ?? {}
|
|
43
|
+
);
|
|
44
|
+
return {
|
|
45
|
+
id: data.id.toString(),
|
|
46
|
+
amount_paid: data.amount,
|
|
47
|
+
currency: data.currency,
|
|
48
|
+
customer: data.payer ?? { email: data.payer?.email ?? "" },
|
|
49
|
+
status,
|
|
50
|
+
paid_at: paidAt.toISOString(),
|
|
51
|
+
metadata: metadata ?? {},
|
|
52
|
+
custom_fields: null,
|
|
53
|
+
subscription_id: isSubscription ? data.id.toString() : null,
|
|
54
|
+
billing_mode: isSubscription ? "recurring" : "one_time",
|
|
55
|
+
line_items: [{ id: itemId, quantity: parseInt(quantity) }]
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
var paykitSubscription$InboundSchema = (data) => {
|
|
59
|
+
const itemId = JSON.parse(data.additional_params?.find((param) => param.name === core.PAYKIT_METADATA_KEY)?.value ?? "{}").itemId;
|
|
60
|
+
const billingIntervalMap = {
|
|
61
|
+
DAY: "day",
|
|
62
|
+
WEEK: "week",
|
|
63
|
+
MONTH: "month",
|
|
64
|
+
ON_DEMAND: "month"
|
|
65
|
+
};
|
|
66
|
+
const billingInterval = billingIntervalMap[data.recurrence?.recurrence_cycle ?? "ON_DEMAND"];
|
|
67
|
+
const currentPeriodStart = new Date(data.recurrence?.recurrence_date_from ?? "");
|
|
68
|
+
const currentPeriodEnd = new Date(data.recurrence?.recurrence_date_to ?? "");
|
|
69
|
+
const metadata = core.omitInternalMetadata(
|
|
70
|
+
data.additional_params?.reduce(
|
|
71
|
+
(acc, param) => {
|
|
72
|
+
acc[param.name] = String(param.value);
|
|
73
|
+
return acc;
|
|
74
|
+
},
|
|
75
|
+
{}
|
|
76
|
+
) ?? {}
|
|
77
|
+
);
|
|
78
|
+
return {
|
|
79
|
+
id: data.id.toString(),
|
|
80
|
+
status: "active",
|
|
81
|
+
customer: data.payer ?? { email: data.payer?.email ?? "" },
|
|
82
|
+
item_id: itemId,
|
|
83
|
+
billing_interval: billingInterval,
|
|
84
|
+
currency: data.currency,
|
|
85
|
+
amount: data.amount,
|
|
86
|
+
metadata: metadata ?? {},
|
|
87
|
+
custom_fields: null,
|
|
88
|
+
current_period_start: currentPeriodStart,
|
|
89
|
+
current_period_end: currentPeriodEnd
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
var paykitRefund$InboundSchema = (data) => {
|
|
93
|
+
return {
|
|
94
|
+
id: data.id.toString(),
|
|
95
|
+
amount: data.amount,
|
|
96
|
+
currency: data.currency,
|
|
97
|
+
reason: data.state,
|
|
98
|
+
metadata: {}
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
exports.paykitInvoice$InboundSchema = paykitInvoice$InboundSchema;
|
|
103
|
+
exports.paykitPayment$InboundSchema = paykitPayment$InboundSchema;
|
|
104
|
+
exports.paykitRefund$InboundSchema = paykitRefund$InboundSchema;
|
|
105
|
+
exports.paykitSubscription$InboundSchema = paykitSubscription$InboundSchema;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PAYKIT_METADATA_KEY, omitInternalMetadata } from '@paykit-sdk/core';
|
|
2
|
+
|
|
3
|
+
// src/utils/mapper.ts
|
|
4
|
+
var paykitPayment$InboundSchema = (data) => {
|
|
5
|
+
const itemId = JSON.parse(data.additional_params?.find((param) => param.name === PAYKIT_METADATA_KEY)?.value ?? "{}").itemId;
|
|
6
|
+
const metadata = omitInternalMetadata(
|
|
7
|
+
data.additional_params?.reduce(
|
|
8
|
+
(acc, param) => {
|
|
9
|
+
acc[param.name] = String(param.value);
|
|
10
|
+
return acc;
|
|
11
|
+
},
|
|
12
|
+
{}
|
|
13
|
+
) ?? {}
|
|
14
|
+
);
|
|
15
|
+
return {
|
|
16
|
+
id: data.id.toString(),
|
|
17
|
+
amount: data.amount,
|
|
18
|
+
currency: data.currency,
|
|
19
|
+
customer: data.payer ?? { email: data.payer?.email ?? "" },
|
|
20
|
+
status: data.state,
|
|
21
|
+
product_id: itemId,
|
|
22
|
+
metadata
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
var paykitInvoice$InboundSchema = (data, isSubscription) => {
|
|
26
|
+
const quantity = JSON.parse(data.additional_params?.find((param) => param.name === PAYKIT_METADATA_KEY)?.value ?? "{}").qty;
|
|
27
|
+
const itemId = JSON.parse(data.additional_params?.find((param) => param.name === PAYKIT_METADATA_KEY)?.value ?? "{}").itemId;
|
|
28
|
+
const status = (() => {
|
|
29
|
+
if (data.state === "PAID") return "paid";
|
|
30
|
+
return "open";
|
|
31
|
+
})();
|
|
32
|
+
const paidAt = isSubscription ? new Date(data.recurrence?.recurrence_date_from ?? "") : /* @__PURE__ */ new Date();
|
|
33
|
+
const metadata = omitInternalMetadata(
|
|
34
|
+
data.additional_params?.reduce(
|
|
35
|
+
(acc, param) => {
|
|
36
|
+
acc[param.name] = String(param.value);
|
|
37
|
+
return acc;
|
|
38
|
+
},
|
|
39
|
+
{}
|
|
40
|
+
) ?? {}
|
|
41
|
+
);
|
|
42
|
+
return {
|
|
43
|
+
id: data.id.toString(),
|
|
44
|
+
amount_paid: data.amount,
|
|
45
|
+
currency: data.currency,
|
|
46
|
+
customer: data.payer ?? { email: data.payer?.email ?? "" },
|
|
47
|
+
status,
|
|
48
|
+
paid_at: paidAt.toISOString(),
|
|
49
|
+
metadata: metadata ?? {},
|
|
50
|
+
custom_fields: null,
|
|
51
|
+
subscription_id: isSubscription ? data.id.toString() : null,
|
|
52
|
+
billing_mode: isSubscription ? "recurring" : "one_time",
|
|
53
|
+
line_items: [{ id: itemId, quantity: parseInt(quantity) }]
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
var paykitSubscription$InboundSchema = (data) => {
|
|
57
|
+
const itemId = JSON.parse(data.additional_params?.find((param) => param.name === PAYKIT_METADATA_KEY)?.value ?? "{}").itemId;
|
|
58
|
+
const billingIntervalMap = {
|
|
59
|
+
DAY: "day",
|
|
60
|
+
WEEK: "week",
|
|
61
|
+
MONTH: "month",
|
|
62
|
+
ON_DEMAND: "month"
|
|
63
|
+
};
|
|
64
|
+
const billingInterval = billingIntervalMap[data.recurrence?.recurrence_cycle ?? "ON_DEMAND"];
|
|
65
|
+
const currentPeriodStart = new Date(data.recurrence?.recurrence_date_from ?? "");
|
|
66
|
+
const currentPeriodEnd = new Date(data.recurrence?.recurrence_date_to ?? "");
|
|
67
|
+
const metadata = omitInternalMetadata(
|
|
68
|
+
data.additional_params?.reduce(
|
|
69
|
+
(acc, param) => {
|
|
70
|
+
acc[param.name] = String(param.value);
|
|
71
|
+
return acc;
|
|
72
|
+
},
|
|
73
|
+
{}
|
|
74
|
+
) ?? {}
|
|
75
|
+
);
|
|
76
|
+
return {
|
|
77
|
+
id: data.id.toString(),
|
|
78
|
+
status: "active",
|
|
79
|
+
customer: data.payer ?? { email: data.payer?.email ?? "" },
|
|
80
|
+
item_id: itemId,
|
|
81
|
+
billing_interval: billingInterval,
|
|
82
|
+
currency: data.currency,
|
|
83
|
+
amount: data.amount,
|
|
84
|
+
metadata: metadata ?? {},
|
|
85
|
+
custom_fields: null,
|
|
86
|
+
current_period_start: currentPeriodStart,
|
|
87
|
+
current_period_end: currentPeriodEnd
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var paykitRefund$InboundSchema = (data) => {
|
|
91
|
+
return {
|
|
92
|
+
id: data.id.toString(),
|
|
93
|
+
amount: data.amount,
|
|
94
|
+
currency: data.currency,
|
|
95
|
+
reason: data.state,
|
|
96
|
+
metadata: {}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export { paykitInvoice$InboundSchema, paykitPayment$InboundSchema, paykitRefund$InboundSchema, paykitSubscription$InboundSchema };
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paykit-sdk/gopay",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "GoPay provider for PayKit",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"prepublishOnly": "rm -rf dist && npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"paykit",
|
|
24
|
+
"gopay"
|
|
25
|
+
],
|
|
26
|
+
"author": "Emmanuel Odii",
|
|
27
|
+
"license": "ISC",
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@paykit-sdk/core": ">=1.1.9"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@paykit-sdk/core": "workspace:*",
|
|
33
|
+
"tsup": "^8.5.0",
|
|
34
|
+
"typescript": "^5.9.2",
|
|
35
|
+
"zod": "^3.24.2"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/usepaykit/paykit-sdk.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/usepaykit/paykit-sdk/issues"
|
|
46
|
+
}
|
|
47
|
+
}
|