@paykit-sdk/polar 1.3.0 → 1.3.1
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.js +17 -13
- package/dist/index.mjs +18 -14
- package/dist/polar-provider.d.mts +6 -0
- package/dist/polar-provider.d.ts +6 -0
- package/dist/polar-provider.js +17 -13
- package/dist/polar-provider.mjs +18 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -139,9 +139,6 @@ var PolarProvider = class extends core.AbstractPayKitProvider {
|
|
|
139
139
|
this.providerName = providerName;
|
|
140
140
|
this.productionURL = sdk.ServerList["production"];
|
|
141
141
|
this.sandboxURL = sdk.ServerList["sandbox"];
|
|
142
|
-
/**
|
|
143
|
-
* Checkout management
|
|
144
|
-
*/
|
|
145
142
|
this.createCheckout = async (params) => {
|
|
146
143
|
const { error, data } = core.createCheckoutSchema.safeParse(params);
|
|
147
144
|
if (error) {
|
|
@@ -159,11 +156,7 @@ var PolarProvider = class extends core.AbstractPayKitProvider {
|
|
|
159
156
|
products: [item_id],
|
|
160
157
|
successUrl: data.success_url
|
|
161
158
|
};
|
|
162
|
-
|
|
163
|
-
checkoutCreateOptions.customerEmail = data.customer.email;
|
|
164
|
-
} else if (typeof data.customer === "string") {
|
|
165
|
-
checkoutCreateOptions.customerId = data.customer;
|
|
166
|
-
}
|
|
159
|
+
this.applyCustomer(checkoutCreateOptions, data.customer);
|
|
167
160
|
if (data.billing) {
|
|
168
161
|
checkoutCreateOptions.customerBillingAddress = {
|
|
169
162
|
line1: data.billing.address.line1,
|
|
@@ -383,11 +376,7 @@ var PolarProvider = class extends core.AbstractPayKitProvider {
|
|
|
383
376
|
metadata: paymentMetadata,
|
|
384
377
|
products: data.item_id ? [data.item_id] : []
|
|
385
378
|
};
|
|
386
|
-
|
|
387
|
-
checkoutCreateOptions.customerId = String(data.customer.id);
|
|
388
|
-
} else if (core.isEmailCustomer(data.customer)) {
|
|
389
|
-
checkoutCreateOptions.customerEmail = data.customer.email;
|
|
390
|
-
}
|
|
379
|
+
this.applyCustomer(checkoutCreateOptions, data.customer);
|
|
391
380
|
if (data.billing) {
|
|
392
381
|
checkoutCreateOptions.customerBillingAddress = {
|
|
393
382
|
line1: data.billing.address.line1,
|
|
@@ -669,6 +658,21 @@ var PolarProvider = class extends core.AbstractPayKitProvider {
|
|
|
669
658
|
get _native() {
|
|
670
659
|
return this.polar;
|
|
671
660
|
}
|
|
661
|
+
/**
|
|
662
|
+
* Checkout management
|
|
663
|
+
*/
|
|
664
|
+
/**
|
|
665
|
+
* Polar's checkoutCreateOptions accepts the customer as either
|
|
666
|
+
* customerId or customerEmail, regardless of whether the checkout
|
|
667
|
+
* originates from createCheckout or createPayment.
|
|
668
|
+
*/
|
|
669
|
+
applyCustomer(options, customer) {
|
|
670
|
+
if (core.isIdCustomer(customer)) {
|
|
671
|
+
options.customerId = String(customer.id);
|
|
672
|
+
} else if (core.isEmailCustomer(customer)) {
|
|
673
|
+
options.customerEmail = customer.email;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
672
676
|
};
|
|
673
677
|
|
|
674
678
|
// src/index.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { schema, Schema, validateRequiredKeys, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, updateCheckoutSchema, retrieveCheckoutSchema, ProviderNotSupportedError, createCustomerSchema, parseCustomerName, PAYKIT_METADATA_KEY, updateCustomerSchema, retrieveCustomerSchema, retrieveSubscriptionSchema, updateSubscriptionSchema, createPaymentSchema,
|
|
1
|
+
import { schema, Schema, validateRequiredKeys, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, updateCheckoutSchema, retrieveCheckoutSchema, ProviderNotSupportedError, createCustomerSchema, parseCustomerName, PAYKIT_METADATA_KEY, updateCustomerSchema, retrieveCustomerSchema, retrieveSubscriptionSchema, updateSubscriptionSchema, createPaymentSchema, updatePaymentSchema, capturePaymentSchema, createRefundSchema, ResourceNotFoundError, refundReasonMatcher, OperationFailedError, WebhookError, isIdCustomer, isEmailCustomer, paykitEvent$InboundSchema, billingModeSchema, omitInternalMetadata } from '@paykit-sdk/core';
|
|
2
2
|
import { ServerList, Polar } from '@polar-sh/sdk';
|
|
3
3
|
import { Refunds } from '@polar-sh/sdk/sdk/refunds.js';
|
|
4
4
|
import { validateEvent } from '@polar-sh/sdk/webhooks';
|
|
@@ -137,9 +137,6 @@ var PolarProvider = class extends AbstractPayKitProvider {
|
|
|
137
137
|
this.providerName = providerName;
|
|
138
138
|
this.productionURL = ServerList["production"];
|
|
139
139
|
this.sandboxURL = ServerList["sandbox"];
|
|
140
|
-
/**
|
|
141
|
-
* Checkout management
|
|
142
|
-
*/
|
|
143
140
|
this.createCheckout = async (params) => {
|
|
144
141
|
const { error, data } = createCheckoutSchema.safeParse(params);
|
|
145
142
|
if (error) {
|
|
@@ -157,11 +154,7 @@ var PolarProvider = class extends AbstractPayKitProvider {
|
|
|
157
154
|
products: [item_id],
|
|
158
155
|
successUrl: data.success_url
|
|
159
156
|
};
|
|
160
|
-
|
|
161
|
-
checkoutCreateOptions.customerEmail = data.customer.email;
|
|
162
|
-
} else if (typeof data.customer === "string") {
|
|
163
|
-
checkoutCreateOptions.customerId = data.customer;
|
|
164
|
-
}
|
|
157
|
+
this.applyCustomer(checkoutCreateOptions, data.customer);
|
|
165
158
|
if (data.billing) {
|
|
166
159
|
checkoutCreateOptions.customerBillingAddress = {
|
|
167
160
|
line1: data.billing.address.line1,
|
|
@@ -381,11 +374,7 @@ var PolarProvider = class extends AbstractPayKitProvider {
|
|
|
381
374
|
metadata: paymentMetadata,
|
|
382
375
|
products: data.item_id ? [data.item_id] : []
|
|
383
376
|
};
|
|
384
|
-
|
|
385
|
-
checkoutCreateOptions.customerId = String(data.customer.id);
|
|
386
|
-
} else if (isEmailCustomer(data.customer)) {
|
|
387
|
-
checkoutCreateOptions.customerEmail = data.customer.email;
|
|
388
|
-
}
|
|
377
|
+
this.applyCustomer(checkoutCreateOptions, data.customer);
|
|
389
378
|
if (data.billing) {
|
|
390
379
|
checkoutCreateOptions.customerBillingAddress = {
|
|
391
380
|
line1: data.billing.address.line1,
|
|
@@ -667,6 +656,21 @@ var PolarProvider = class extends AbstractPayKitProvider {
|
|
|
667
656
|
get _native() {
|
|
668
657
|
return this.polar;
|
|
669
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* Checkout management
|
|
661
|
+
*/
|
|
662
|
+
/**
|
|
663
|
+
* Polar's checkoutCreateOptions accepts the customer as either
|
|
664
|
+
* customerId or customerEmail, regardless of whether the checkout
|
|
665
|
+
* originates from createCheckout or createPayment.
|
|
666
|
+
*/
|
|
667
|
+
applyCustomer(options, customer) {
|
|
668
|
+
if (isIdCustomer(customer)) {
|
|
669
|
+
options.customerId = String(customer.id);
|
|
670
|
+
} else if (isEmailCustomer(customer)) {
|
|
671
|
+
options.customerEmail = customer.email;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
670
674
|
};
|
|
671
675
|
|
|
672
676
|
// src/index.ts
|
|
@@ -25,6 +25,12 @@ declare class PolarProvider extends AbstractPayKitProvider implements PayKitProv
|
|
|
25
25
|
/**
|
|
26
26
|
* Checkout management
|
|
27
27
|
*/
|
|
28
|
+
/**
|
|
29
|
+
* Polar's checkoutCreateOptions accepts the customer as either
|
|
30
|
+
* customerId or customerEmail, regardless of whether the checkout
|
|
31
|
+
* originates from createCheckout or createPayment.
|
|
32
|
+
*/
|
|
33
|
+
private applyCustomer;
|
|
28
34
|
createCheckout: (params: CreateCheckoutSchema) => Promise<Checkout>;
|
|
29
35
|
updateCheckout: (id: string, params: UpdateCheckoutSchema) => Promise<Checkout>;
|
|
30
36
|
retrieveCheckout: (id: string) => Promise<Checkout>;
|
package/dist/polar-provider.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ declare class PolarProvider extends AbstractPayKitProvider implements PayKitProv
|
|
|
25
25
|
/**
|
|
26
26
|
* Checkout management
|
|
27
27
|
*/
|
|
28
|
+
/**
|
|
29
|
+
* Polar's checkoutCreateOptions accepts the customer as either
|
|
30
|
+
* customerId or customerEmail, regardless of whether the checkout
|
|
31
|
+
* originates from createCheckout or createPayment.
|
|
32
|
+
*/
|
|
33
|
+
private applyCustomer;
|
|
28
34
|
createCheckout: (params: CreateCheckoutSchema) => Promise<Checkout>;
|
|
29
35
|
updateCheckout: (id: string, params: UpdateCheckoutSchema) => Promise<Checkout>;
|
|
30
36
|
retrieveCheckout: (id: string) => Promise<Checkout>;
|
package/dist/polar-provider.js
CHANGED
|
@@ -139,9 +139,6 @@ var PolarProvider = class extends core.AbstractPayKitProvider {
|
|
|
139
139
|
this.providerName = providerName;
|
|
140
140
|
this.productionURL = sdk.ServerList["production"];
|
|
141
141
|
this.sandboxURL = sdk.ServerList["sandbox"];
|
|
142
|
-
/**
|
|
143
|
-
* Checkout management
|
|
144
|
-
*/
|
|
145
142
|
this.createCheckout = async (params) => {
|
|
146
143
|
const { error, data } = core.createCheckoutSchema.safeParse(params);
|
|
147
144
|
if (error) {
|
|
@@ -159,11 +156,7 @@ var PolarProvider = class extends core.AbstractPayKitProvider {
|
|
|
159
156
|
products: [item_id],
|
|
160
157
|
successUrl: data.success_url
|
|
161
158
|
};
|
|
162
|
-
|
|
163
|
-
checkoutCreateOptions.customerEmail = data.customer.email;
|
|
164
|
-
} else if (typeof data.customer === "string") {
|
|
165
|
-
checkoutCreateOptions.customerId = data.customer;
|
|
166
|
-
}
|
|
159
|
+
this.applyCustomer(checkoutCreateOptions, data.customer);
|
|
167
160
|
if (data.billing) {
|
|
168
161
|
checkoutCreateOptions.customerBillingAddress = {
|
|
169
162
|
line1: data.billing.address.line1,
|
|
@@ -383,11 +376,7 @@ var PolarProvider = class extends core.AbstractPayKitProvider {
|
|
|
383
376
|
metadata: paymentMetadata,
|
|
384
377
|
products: data.item_id ? [data.item_id] : []
|
|
385
378
|
};
|
|
386
|
-
|
|
387
|
-
checkoutCreateOptions.customerId = String(data.customer.id);
|
|
388
|
-
} else if (core.isEmailCustomer(data.customer)) {
|
|
389
|
-
checkoutCreateOptions.customerEmail = data.customer.email;
|
|
390
|
-
}
|
|
379
|
+
this.applyCustomer(checkoutCreateOptions, data.customer);
|
|
391
380
|
if (data.billing) {
|
|
392
381
|
checkoutCreateOptions.customerBillingAddress = {
|
|
393
382
|
line1: data.billing.address.line1,
|
|
@@ -669,6 +658,21 @@ var PolarProvider = class extends core.AbstractPayKitProvider {
|
|
|
669
658
|
get _native() {
|
|
670
659
|
return this.polar;
|
|
671
660
|
}
|
|
661
|
+
/**
|
|
662
|
+
* Checkout management
|
|
663
|
+
*/
|
|
664
|
+
/**
|
|
665
|
+
* Polar's checkoutCreateOptions accepts the customer as either
|
|
666
|
+
* customerId or customerEmail, regardless of whether the checkout
|
|
667
|
+
* originates from createCheckout or createPayment.
|
|
668
|
+
*/
|
|
669
|
+
applyCustomer(options, customer) {
|
|
670
|
+
if (core.isIdCustomer(customer)) {
|
|
671
|
+
options.customerId = String(customer.id);
|
|
672
|
+
} else if (core.isEmailCustomer(customer)) {
|
|
673
|
+
options.customerEmail = customer.email;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
672
676
|
};
|
|
673
677
|
|
|
674
678
|
exports.PolarProvider = PolarProvider;
|
package/dist/polar-provider.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { schema, Schema, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, updateCheckoutSchema, retrieveCheckoutSchema, ProviderNotSupportedError, createCustomerSchema, parseCustomerName, PAYKIT_METADATA_KEY, updateCustomerSchema, retrieveCustomerSchema, retrieveSubscriptionSchema, updateSubscriptionSchema, createPaymentSchema,
|
|
1
|
+
import { schema, Schema, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, updateCheckoutSchema, retrieveCheckoutSchema, ProviderNotSupportedError, createCustomerSchema, parseCustomerName, PAYKIT_METADATA_KEY, updateCustomerSchema, retrieveCustomerSchema, retrieveSubscriptionSchema, updateSubscriptionSchema, createPaymentSchema, updatePaymentSchema, capturePaymentSchema, createRefundSchema, ResourceNotFoundError, refundReasonMatcher, OperationFailedError, WebhookError, isIdCustomer, isEmailCustomer, paykitEvent$InboundSchema, billingModeSchema, omitInternalMetadata } from '@paykit-sdk/core';
|
|
2
2
|
import { ServerList, Polar } from '@polar-sh/sdk';
|
|
3
3
|
import { Refunds } from '@polar-sh/sdk/sdk/refunds.js';
|
|
4
4
|
import { validateEvent } from '@polar-sh/sdk/webhooks';
|
|
@@ -137,9 +137,6 @@ var PolarProvider = class extends AbstractPayKitProvider {
|
|
|
137
137
|
this.providerName = providerName;
|
|
138
138
|
this.productionURL = ServerList["production"];
|
|
139
139
|
this.sandboxURL = ServerList["sandbox"];
|
|
140
|
-
/**
|
|
141
|
-
* Checkout management
|
|
142
|
-
*/
|
|
143
140
|
this.createCheckout = async (params) => {
|
|
144
141
|
const { error, data } = createCheckoutSchema.safeParse(params);
|
|
145
142
|
if (error) {
|
|
@@ -157,11 +154,7 @@ var PolarProvider = class extends AbstractPayKitProvider {
|
|
|
157
154
|
products: [item_id],
|
|
158
155
|
successUrl: data.success_url
|
|
159
156
|
};
|
|
160
|
-
|
|
161
|
-
checkoutCreateOptions.customerEmail = data.customer.email;
|
|
162
|
-
} else if (typeof data.customer === "string") {
|
|
163
|
-
checkoutCreateOptions.customerId = data.customer;
|
|
164
|
-
}
|
|
157
|
+
this.applyCustomer(checkoutCreateOptions, data.customer);
|
|
165
158
|
if (data.billing) {
|
|
166
159
|
checkoutCreateOptions.customerBillingAddress = {
|
|
167
160
|
line1: data.billing.address.line1,
|
|
@@ -381,11 +374,7 @@ var PolarProvider = class extends AbstractPayKitProvider {
|
|
|
381
374
|
metadata: paymentMetadata,
|
|
382
375
|
products: data.item_id ? [data.item_id] : []
|
|
383
376
|
};
|
|
384
|
-
|
|
385
|
-
checkoutCreateOptions.customerId = String(data.customer.id);
|
|
386
|
-
} else if (isEmailCustomer(data.customer)) {
|
|
387
|
-
checkoutCreateOptions.customerEmail = data.customer.email;
|
|
388
|
-
}
|
|
377
|
+
this.applyCustomer(checkoutCreateOptions, data.customer);
|
|
389
378
|
if (data.billing) {
|
|
390
379
|
checkoutCreateOptions.customerBillingAddress = {
|
|
391
380
|
line1: data.billing.address.line1,
|
|
@@ -667,6 +656,21 @@ var PolarProvider = class extends AbstractPayKitProvider {
|
|
|
667
656
|
get _native() {
|
|
668
657
|
return this.polar;
|
|
669
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* Checkout management
|
|
661
|
+
*/
|
|
662
|
+
/**
|
|
663
|
+
* Polar's checkoutCreateOptions accepts the customer as either
|
|
664
|
+
* customerId or customerEmail, regardless of whether the checkout
|
|
665
|
+
* originates from createCheckout or createPayment.
|
|
666
|
+
*/
|
|
667
|
+
applyCustomer(options, customer) {
|
|
668
|
+
if (isIdCustomer(customer)) {
|
|
669
|
+
options.customerId = String(customer.id);
|
|
670
|
+
} else if (isEmailCustomer(customer)) {
|
|
671
|
+
options.customerEmail = customer.email;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
670
674
|
};
|
|
671
675
|
|
|
672
676
|
export { PolarProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paykit-sdk/polar",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Polar provider for PayKit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"tsup": "^8.0.0",
|
|
30
30
|
"typescript": "^5.0.0",
|
|
31
|
-
"@paykit-sdk/core": "1.3.
|
|
31
|
+
"@paykit-sdk/core": "1.3.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|