@paykit-sdk/polar 1.1.9 → 1.1.91
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 +1 -1
- package/dist/index.js +26 -5
- package/dist/index.mjs +26 -5
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -62,17 +62,37 @@ var toPaykitSubscription = (subscription) => {
|
|
|
62
62
|
status: toPaykitSubscriptionStatus(subscription.status),
|
|
63
63
|
current_period_start: new Date(subscription.currentPeriodStart),
|
|
64
64
|
current_period_end: new Date(subscription.currentPeriodEnd),
|
|
65
|
-
metadata: (0, import_core.stringifyObjectValues)({ ...subscription.metadata ?? {}
|
|
65
|
+
metadata: (0, import_core.stringifyObjectValues)({ ...subscription.metadata ?? {} }),
|
|
66
|
+
custom_fields: subscription.customFieldData ?? null,
|
|
67
|
+
item_id: subscription.productId,
|
|
68
|
+
billing_interval: subscription.recurringInterval,
|
|
69
|
+
currency: subscription.currency,
|
|
70
|
+
amount: subscription.amount,
|
|
71
|
+
/**
|
|
72
|
+
* todo: fix
|
|
73
|
+
*/
|
|
74
|
+
billing_interval_count: 1,
|
|
75
|
+
current_cycle: 0,
|
|
76
|
+
total_cycles: 0
|
|
66
77
|
};
|
|
67
78
|
};
|
|
68
79
|
var toPaykitInvoice = (invoice) => {
|
|
80
|
+
const status = (() => {
|
|
81
|
+
if (invoice.status == "paid") return "paid";
|
|
82
|
+
return "open";
|
|
83
|
+
})();
|
|
69
84
|
return {
|
|
70
85
|
id: invoice.id,
|
|
71
|
-
|
|
86
|
+
amount_paid: invoice.totalAmount,
|
|
72
87
|
currency: invoice.currency,
|
|
73
|
-
metadata: (0, import_core.stringifyObjectValues)({ ...invoice.metadata ?? {}
|
|
88
|
+
metadata: (0, import_core.stringifyObjectValues)({ ...invoice.metadata ?? {} }),
|
|
74
89
|
customer_id: invoice.customerId,
|
|
75
|
-
billing_mode: invoice.billingMode
|
|
90
|
+
billing_mode: invoice.billingMode,
|
|
91
|
+
custom_fields: invoice.customFieldData ?? null,
|
|
92
|
+
status,
|
|
93
|
+
subscription_id: invoice.subscription?.id ?? null,
|
|
94
|
+
paid_at: new Date(invoice.createdAt).toISOString(),
|
|
95
|
+
line_items: []
|
|
76
96
|
};
|
|
77
97
|
};
|
|
78
98
|
|
|
@@ -134,7 +154,8 @@ var PolarProvider = class {
|
|
|
134
154
|
*/
|
|
135
155
|
this.handleWebhook = async (params) => {
|
|
136
156
|
const { body, headers, webhookSecret } = params;
|
|
137
|
-
const
|
|
157
|
+
const requiredHeaders = ["webhook-id", "webhook-timestamp", "webhook-signature"];
|
|
158
|
+
const webhookHeaders = (0, import_core2.headersExtractor)(headers, requiredHeaders).reduce(
|
|
138
159
|
(acc, kv) => {
|
|
139
160
|
acc[kv.key] = Array.isArray(kv.value) ? kv.value.join(",") : kv.value;
|
|
140
161
|
return acc;
|
package/dist/index.mjs
CHANGED
|
@@ -42,17 +42,37 @@ var toPaykitSubscription = (subscription) => {
|
|
|
42
42
|
status: toPaykitSubscriptionStatus(subscription.status),
|
|
43
43
|
current_period_start: new Date(subscription.currentPeriodStart),
|
|
44
44
|
current_period_end: new Date(subscription.currentPeriodEnd),
|
|
45
|
-
metadata: stringifyObjectValues({ ...subscription.metadata ?? {}
|
|
45
|
+
metadata: stringifyObjectValues({ ...subscription.metadata ?? {} }),
|
|
46
|
+
custom_fields: subscription.customFieldData ?? null,
|
|
47
|
+
item_id: subscription.productId,
|
|
48
|
+
billing_interval: subscription.recurringInterval,
|
|
49
|
+
currency: subscription.currency,
|
|
50
|
+
amount: subscription.amount,
|
|
51
|
+
/**
|
|
52
|
+
* todo: fix
|
|
53
|
+
*/
|
|
54
|
+
billing_interval_count: 1,
|
|
55
|
+
current_cycle: 0,
|
|
56
|
+
total_cycles: 0
|
|
46
57
|
};
|
|
47
58
|
};
|
|
48
59
|
var toPaykitInvoice = (invoice) => {
|
|
60
|
+
const status = (() => {
|
|
61
|
+
if (invoice.status == "paid") return "paid";
|
|
62
|
+
return "open";
|
|
63
|
+
})();
|
|
49
64
|
return {
|
|
50
65
|
id: invoice.id,
|
|
51
|
-
|
|
66
|
+
amount_paid: invoice.totalAmount,
|
|
52
67
|
currency: invoice.currency,
|
|
53
|
-
metadata: stringifyObjectValues({ ...invoice.metadata ?? {}
|
|
68
|
+
metadata: stringifyObjectValues({ ...invoice.metadata ?? {} }),
|
|
54
69
|
customer_id: invoice.customerId,
|
|
55
|
-
billing_mode: invoice.billingMode
|
|
70
|
+
billing_mode: invoice.billingMode,
|
|
71
|
+
custom_fields: invoice.customFieldData ?? null,
|
|
72
|
+
status,
|
|
73
|
+
subscription_id: invoice.subscription?.id ?? null,
|
|
74
|
+
paid_at: new Date(invoice.createdAt).toISOString(),
|
|
75
|
+
line_items: []
|
|
56
76
|
};
|
|
57
77
|
};
|
|
58
78
|
|
|
@@ -114,7 +134,8 @@ var PolarProvider = class {
|
|
|
114
134
|
*/
|
|
115
135
|
this.handleWebhook = async (params) => {
|
|
116
136
|
const { body, headers, webhookSecret } = params;
|
|
117
|
-
const
|
|
137
|
+
const requiredHeaders = ["webhook-id", "webhook-timestamp", "webhook-signature"];
|
|
138
|
+
const webhookHeaders = headersExtractor(headers, requiredHeaders).reduce(
|
|
118
139
|
(acc, kv) => {
|
|
119
140
|
acc[kv.key] = Array.isArray(kv.value) ? kv.value.join(",") : kv.value;
|
|
120
141
|
return acc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paykit-sdk/polar",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.91",
|
|
4
4
|
"description": "Polar provider for PayKit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"typescript"
|
|
20
20
|
],
|
|
21
21
|
"author": "Emmanuel Odii",
|
|
22
|
-
"license": "
|
|
22
|
+
"license": "GPL-3.0",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@polar-sh/sdk": "^0.33.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@paykit-sdk/core": "^1.1.
|
|
27
|
+
"@paykit-sdk/core": "^1.1.8"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@paykit-sdk/core": "workspace:*",
|