@paddle/paddle-node-sdk 2.0.0-rc.1 → 2.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/CHANGELOG.md +8 -11
- package/dist/cjs/entities/customer/auth-token.js +10 -0
- package/dist/cjs/entities/customer/index.js +1 -0
- package/dist/cjs/entities/index.js +1 -0
- package/dist/cjs/entities/notification-settings/notification-settings.js +1 -0
- package/dist/cjs/entities/payment-method/index.js +18 -0
- package/dist/cjs/entities/payment-method/payment-method-collection.js +11 -0
- package/dist/cjs/entities/payment-method/payment-method.js +18 -0
- package/dist/cjs/entities/shared/index.js +1 -0
- package/dist/cjs/entities/shared/paypal.js +10 -0
- package/dist/cjs/enums/index.js +1 -0
- package/dist/cjs/enums/notification-settings/index.js +1 -0
- package/dist/cjs/enums/notification-settings/traffic-source.js +2 -0
- package/dist/cjs/enums/payment-method/deletion-reason.js +2 -0
- package/dist/cjs/enums/payment-method/index.js +19 -0
- package/dist/cjs/enums/payment-method/origin.js +2 -0
- package/dist/cjs/enums/payment-method/type.js +2 -0
- package/dist/cjs/internal/api/case-helpers.js +19 -32
- package/dist/cjs/notifications/entities/index.js +1 -0
- package/dist/cjs/notifications/entities/payment-method/index.js +18 -0
- package/dist/cjs/notifications/entities/payment-method/payment-method-deleted-notification.js +16 -0
- package/dist/cjs/notifications/entities/payment-method/payment-method-notification.js +15 -0
- package/dist/cjs/notifications/entities/subscription/index.js +1 -0
- package/dist/cjs/notifications/entities/subscription/subscription-created-notification.js +42 -0
- package/dist/cjs/notifications/entities/subscription/subscription-notification.js +0 -1
- package/dist/cjs/notifications/events/index.js +1 -0
- package/dist/cjs/notifications/events/payment-method/index.js +18 -0
- package/dist/cjs/notifications/events/payment-method/payment-method-deleted-event.js +14 -0
- package/dist/cjs/notifications/events/payment-method/payment-method-saved-event.js +14 -0
- package/dist/cjs/notifications/events/subscription/subscription-created-event.js +1 -1
- package/dist/cjs/notifications/helpers/types.js +2 -0
- package/dist/cjs/notifications/helpers/webhooks.js +4 -0
- package/dist/cjs/notifications/types/index.js +1 -0
- package/dist/cjs/notifications/types/payment-method/index.js +18 -0
- package/dist/cjs/notifications/types/payment-method/payment-method-deleted-notification-response.js +2 -0
- package/dist/cjs/notifications/types/payment-method/payment-method-notification-response.js +2 -0
- package/dist/cjs/notifications/types/subscription/index.js +1 -0
- package/dist/cjs/notifications/types/subscription/subscription-created-notification-response.js +2 -0
- package/dist/cjs/paddle.js +1 -0
- package/dist/cjs/resources/customers/index.js +11 -0
- package/dist/cjs/resources/index.js +1 -0
- package/dist/cjs/resources/payment-methods/index.js +67 -0
- package/dist/cjs/resources/payment-methods/operations/index.js +17 -0
- package/dist/cjs/resources/payment-methods/operations/list-customer-payment-method-query-parameters.js +2 -0
- package/dist/cjs/types/customer/auth-token-response.js +2 -0
- package/dist/cjs/types/customer/index.js +1 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/payment-method/index.js +17 -0
- package/dist/cjs/types/payment-method/payment-method.js +2 -0
- package/dist/cjs/types/shared/index.js +1 -0
- package/dist/cjs/types/shared/paypal.js +2 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/entities/customer/auth-token.js +6 -0
- package/dist/esm/entities/customer/index.js +1 -0
- package/dist/esm/entities/index.js +1 -0
- package/dist/esm/entities/notification-settings/notification-settings.js +1 -0
- package/dist/esm/entities/payment-method/index.js +2 -0
- package/dist/esm/entities/payment-method/payment-method-collection.js +7 -0
- package/dist/esm/entities/payment-method/payment-method.js +14 -0
- package/dist/esm/entities/shared/index.js +1 -0
- package/dist/esm/entities/shared/paypal.js +6 -0
- package/dist/esm/enums/index.js +1 -0
- package/dist/esm/enums/notification-settings/index.js +1 -0
- package/dist/esm/enums/notification-settings/traffic-source.js +1 -0
- package/dist/esm/enums/payment-method/deletion-reason.js +1 -0
- package/dist/esm/enums/payment-method/index.js +3 -0
- package/dist/esm/enums/payment-method/origin.js +1 -0
- package/dist/esm/enums/payment-method/type.js +1 -0
- package/dist/esm/internal/api/case-helpers.js +19 -9
- package/dist/esm/notifications/entities/index.js +1 -0
- package/dist/esm/notifications/entities/payment-method/index.js +2 -0
- package/dist/esm/notifications/entities/payment-method/payment-method-deleted-notification.js +12 -0
- package/dist/esm/notifications/entities/payment-method/payment-method-notification.js +11 -0
- package/dist/esm/notifications/entities/subscription/index.js +1 -0
- package/dist/esm/notifications/entities/subscription/subscription-created-notification.js +38 -0
- package/dist/esm/notifications/entities/subscription/subscription-notification.js +0 -1
- package/dist/esm/notifications/events/index.js +1 -0
- package/dist/esm/notifications/events/payment-method/index.js +2 -0
- package/dist/esm/notifications/events/payment-method/payment-method-deleted-event.js +10 -0
- package/dist/esm/notifications/events/payment-method/payment-method-saved-event.js +10 -0
- package/dist/esm/notifications/events/subscription/subscription-created-event.js +2 -2
- package/dist/esm/notifications/helpers/types.js +2 -0
- package/dist/esm/notifications/helpers/webhooks.js +5 -1
- package/dist/esm/notifications/types/index.js +1 -0
- package/dist/esm/notifications/types/payment-method/index.js +2 -0
- package/dist/esm/notifications/types/payment-method/payment-method-deleted-notification-response.js +1 -0
- package/dist/esm/notifications/types/payment-method/payment-method-notification-response.js +1 -0
- package/dist/esm/notifications/types/subscription/index.js +1 -0
- package/dist/esm/notifications/types/subscription/subscription-created-notification-response.js +1 -0
- package/dist/esm/paddle.js +2 -1
- package/dist/esm/resources/customers/index.js +12 -1
- package/dist/esm/resources/index.js +1 -0
- package/dist/esm/resources/payment-methods/index.js +49 -0
- package/dist/esm/resources/payment-methods/operations/index.js +1 -0
- package/dist/esm/resources/payment-methods/operations/list-customer-payment-method-query-parameters.js +1 -0
- package/dist/esm/types/customer/auth-token-response.js +1 -0
- package/dist/esm/types/customer/index.js +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/payment-method/index.js +1 -0
- package/dist/esm/types/payment-method/payment-method.js +1 -0
- package/dist/esm/types/shared/index.js +1 -0
- package/dist/esm/types/shared/paypal.js +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/entities/customer/auth-token.d.ts +6 -0
- package/dist/types/entities/customer/index.d.ts +1 -0
- package/dist/types/entities/index.d.ts +1 -0
- package/dist/types/entities/notification-settings/notification-settings.d.ts +2 -1
- package/dist/types/entities/payment-method/index.d.ts +2 -0
- package/dist/types/entities/payment-method/payment-method-collection.d.ts +6 -0
- package/dist/types/entities/payment-method/payment-method.d.ts +15 -0
- package/dist/types/entities/shared/index.d.ts +1 -0
- package/dist/types/entities/shared/paypal.d.ts +6 -0
- package/dist/types/enums/index.d.ts +1 -0
- package/dist/types/enums/notification-settings/index.d.ts +1 -0
- package/dist/types/enums/notification-settings/traffic-source.d.ts +1 -0
- package/dist/types/enums/payment-method/deletion-reason.d.ts +1 -0
- package/dist/types/enums/payment-method/index.d.ts +3 -0
- package/dist/types/enums/payment-method/origin.d.ts +1 -0
- package/dist/types/enums/payment-method/type.d.ts +1 -0
- package/dist/types/notifications/entities/index.d.ts +1 -0
- package/dist/types/notifications/entities/payment-method/index.d.ts +2 -0
- package/dist/types/notifications/entities/payment-method/payment-method-deleted-notification.d.ts +13 -0
- package/dist/types/notifications/entities/payment-method/payment-method-notification.d.ts +12 -0
- package/dist/types/notifications/entities/subscription/index.d.ts +1 -0
- package/dist/types/notifications/entities/subscription/subscription-created-notification.d.ts +34 -0
- package/dist/types/notifications/entities/subscription/subscription-notification.d.ts +0 -1
- package/dist/types/notifications/events/index.d.ts +1 -0
- package/dist/types/notifications/events/payment-method/index.d.ts +2 -0
- package/dist/types/notifications/events/payment-method/payment-method-deleted-event.d.ts +10 -0
- package/dist/types/notifications/events/payment-method/payment-method-saved-event.d.ts +10 -0
- package/dist/types/notifications/events/subscription/subscription-activated-event.d.ts +1 -1
- package/dist/types/notifications/events/subscription/subscription-canceled-event.d.ts +1 -1
- package/dist/types/notifications/events/subscription/subscription-created-event.d.ts +4 -4
- package/dist/types/notifications/events/subscription/subscription-imported-event.d.ts +1 -1
- package/dist/types/notifications/events/subscription/subscription-past-due-event.d.ts +1 -1
- package/dist/types/notifications/events/subscription/subscription-paused-event.d.ts +1 -1
- package/dist/types/notifications/events/subscription/subscription-resumed-event.d.ts +1 -1
- package/dist/types/notifications/events/subscription/subscription-trialing-event.d.ts +1 -1
- package/dist/types/notifications/events/subscription/subscription-updated-event.d.ts +1 -1
- package/dist/types/notifications/helpers/types.d.ts +5 -3
- package/dist/types/notifications/types/index.d.ts +1 -0
- package/dist/types/notifications/types/payment-method/index.d.ts +2 -0
- package/dist/types/notifications/types/payment-method/payment-method-deleted-notification-response.d.ts +11 -0
- package/dist/types/notifications/types/payment-method/payment-method-notification-response.d.ts +10 -0
- package/dist/types/notifications/types/subscription/index.d.ts +1 -0
- package/dist/types/notifications/types/subscription/subscription-created-notification-response.d.ts +28 -0
- package/dist/types/notifications/types/subscription/subscription-notification-response.d.ts +0 -1
- package/dist/types/paddle.d.ts +2 -1
- package/dist/types/resources/customers/index.d.ts +2 -1
- package/dist/types/resources/index.d.ts +1 -0
- package/dist/types/resources/notification-settings/operations/create-notification-settings-request-body.d.ts +2 -1
- package/dist/types/resources/notification-settings/operations/list-notification-settings-query-parameters.d.ts +2 -0
- package/dist/types/resources/notification-settings/operations/update-notification-settings-request-body.d.ts +2 -0
- package/dist/types/resources/payment-methods/index.d.ts +9 -0
- package/dist/types/resources/payment-methods/operations/index.d.ts +1 -0
- package/dist/types/resources/payment-methods/operations/list-customer-payment-method-query-parameters.d.ts +7 -0
- package/dist/types/types/customer/auth-token-response.d.ts +4 -0
- package/dist/types/types/customer/index.d.ts +1 -0
- package/dist/types/types/events/events-response.d.ts +9 -3
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/notification-settings/notification-settings-response.d.ts +2 -1
- package/dist/types/types/payment-method/index.d.ts +1 -0
- package/dist/types/types/payment-method/payment-method.d.ts +13 -0
- package/dist/types/types/shared/index.d.ts +1 -0
- package/dist/types/types/shared/paypal.d.ts +4 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.PaymentMethodsResource = void 0;
|
|
27
|
+
const index_js_1 = require("../../entities/index.js");
|
|
28
|
+
const index_js_2 = require("../../internal/base/index.js");
|
|
29
|
+
__exportStar(require("./operations"), exports);
|
|
30
|
+
const PaymentMethodPaths = {
|
|
31
|
+
list: '/customers/{customer_id}/payment-methods',
|
|
32
|
+
get: '/customers/{customer_id}/payment-methods/{payment_method_id}',
|
|
33
|
+
delete: '/customers/{customer_id}/payment-methods/{payment_method_id}',
|
|
34
|
+
};
|
|
35
|
+
class PaymentMethodsResource extends index_js_2.BaseResource {
|
|
36
|
+
list(customerId, queryParams) {
|
|
37
|
+
const queryParameters = new index_js_2.QueryParameters(queryParams);
|
|
38
|
+
const urlWithPathParams = new index_js_2.PathParameters(PaymentMethodPaths.list, {
|
|
39
|
+
customer_id: customerId,
|
|
40
|
+
}).deriveUrl();
|
|
41
|
+
return new index_js_1.PaymentMethodCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
|
|
42
|
+
}
|
|
43
|
+
get(customerId, paymentMethodId) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const urlWithPathParams = new index_js_2.PathParameters(PaymentMethodPaths.get, {
|
|
46
|
+
customer_id: customerId,
|
|
47
|
+
payment_method_id: paymentMethodId,
|
|
48
|
+
}).deriveUrl();
|
|
49
|
+
const response = yield this.client.get(urlWithPathParams);
|
|
50
|
+
const data = this.handleResponse(response);
|
|
51
|
+
return new index_js_1.PaymentMethod(data);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
delete(customerId, paymentMethodId) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const urlWithPathParams = new index_js_2.PathParameters(PaymentMethodPaths.delete, {
|
|
57
|
+
customer_id: customerId,
|
|
58
|
+
payment_method_id: paymentMethodId,
|
|
59
|
+
}).deriveUrl();
|
|
60
|
+
const response = yield this.client.delete(urlWithPathParams);
|
|
61
|
+
if (response) {
|
|
62
|
+
this.handleResponse(response);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.PaymentMethodsResource = PaymentMethodsResource;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./list-customer-payment-method-query-parameters.js"), exports);
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth-token-response.js"), exports);
|
|
17
18
|
__exportStar(require("./customer-response.js"), exports);
|
|
18
19
|
__exportStar(require("./credit-balance-response.js"), exports);
|
|
19
20
|
__exportStar(require("./customer-balance.js"), exports);
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./business/index.js"), exports);
|
|
|
24
24
|
__exportStar(require("./subscription/index.js"), exports);
|
|
25
25
|
__exportStar(require("./address/index.js"), exports);
|
|
26
26
|
__exportStar(require("./discount/index.js"), exports);
|
|
27
|
+
__exportStar(require("./payment-method/index.js"), exports);
|
|
27
28
|
__exportStar(require("./pricing-preview/index.js"), exports);
|
|
28
29
|
__exportStar(require("./events/index.js"), exports);
|
|
29
30
|
__exportStar(require("./payout/index.js"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./payment-method.js"), exports);
|
|
@@ -30,6 +30,7 @@ __exportStar(require("./adjustment-original-amount-response.js"), exports);
|
|
|
30
30
|
__exportStar(require("./chargeback-fee.js"), exports);
|
|
31
31
|
__exportStar(require("./transaction-payout-totals-adjusted-response.js"), exports);
|
|
32
32
|
__exportStar(require("./unit-totals.js"), exports);
|
|
33
|
+
__exportStar(require("./paypal.js"), exports);
|
|
33
34
|
__exportStar(require("./payment-card-response.js"), exports);
|
|
34
35
|
__exportStar(require("./payment-method-details.js"), exports);
|
|
35
36
|
__exportStar(require("./transaction-payment-attempt-response.js"), exports);
|
package/dist/cjs/version.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from './subscription/index.js';
|
|
|
9
9
|
export * from './address/index.js';
|
|
10
10
|
export * from './discount/index.js';
|
|
11
11
|
export * from './events/index.js';
|
|
12
|
+
export * from './payment-method/index.js';
|
|
12
13
|
export * from './payout/index.js';
|
|
13
14
|
export * from './event-types/index.js';
|
|
14
15
|
export * from './notification-settings/index.js';
|
|
@@ -8,6 +8,7 @@ export class NotificationSettings {
|
|
|
8
8
|
this.active = notificationSettings.active;
|
|
9
9
|
this.apiVersion = notificationSettings.api_version;
|
|
10
10
|
this.includeSensitiveFields = notificationSettings.include_sensitive_fields;
|
|
11
|
+
this.trafficSource = notificationSettings.traffic_source;
|
|
11
12
|
this.subscribedEvents = notificationSettings.subscribed_events.map((subscribed_event) => new EventType(subscribed_event));
|
|
12
13
|
this.endpointSecretKey = notificationSettings.endpoint_secret_key;
|
|
13
14
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PaymentCard, PayPal } from '../shared/index.js';
|
|
2
|
+
export class PaymentMethod {
|
|
3
|
+
constructor(paymentMethodResponse) {
|
|
4
|
+
this.id = paymentMethodResponse.id;
|
|
5
|
+
this.customerId = paymentMethodResponse.customer_id;
|
|
6
|
+
this.addressId = paymentMethodResponse.address_id;
|
|
7
|
+
this.type = paymentMethodResponse.type;
|
|
8
|
+
this.card = paymentMethodResponse.card ? new PaymentCard(paymentMethodResponse.card) : null;
|
|
9
|
+
this.paypal = paymentMethodResponse.paypal ? new PayPal(paymentMethodResponse.paypal) : null;
|
|
10
|
+
this.origin = paymentMethodResponse.origin;
|
|
11
|
+
this.savedAt = paymentMethodResponse.saved_at;
|
|
12
|
+
this.updatedAt = paymentMethodResponse.updated_at;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -11,6 +11,7 @@ export * from './adjustment-original-amount.js';
|
|
|
11
11
|
export * from './chargeback-fee.js';
|
|
12
12
|
export * from './transaction-payout-totals-adjusted.js';
|
|
13
13
|
export * from './unit-totals.js';
|
|
14
|
+
export * from './paypal.js';
|
|
14
15
|
export * from './payment-card.js';
|
|
15
16
|
export * from './payment-method-details.js';
|
|
16
17
|
export * from './transaction-payment-attempt.js';
|
package/dist/esm/enums/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './subscription/index.js';
|
|
|
3
3
|
export * from './discount/index.js';
|
|
4
4
|
export * from './adjustment/index.js';
|
|
5
5
|
export * from './transaction/index.js';
|
|
6
|
+
export * from './payment-method/index.js';
|
|
6
7
|
export * from './payout/index.js';
|
|
7
8
|
export * from './notification-settings/index.js';
|
|
8
9
|
export * from './notification/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,22 +9,32 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import * as lodash from 'lodash';
|
|
13
12
|
function isTopLevelCustomDataCamel(input) {
|
|
14
13
|
return 'customData' in input;
|
|
15
14
|
}
|
|
15
|
+
function isObject(input) {
|
|
16
|
+
return input != null && typeof input === 'object';
|
|
17
|
+
}
|
|
18
|
+
function snakeCase(input) {
|
|
19
|
+
return input
|
|
20
|
+
.trim()
|
|
21
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
22
|
+
.replace(/[\W]+/g, '_')
|
|
23
|
+
.replace(/^_+|_+$/g, '')
|
|
24
|
+
.toLowerCase();
|
|
25
|
+
}
|
|
16
26
|
function decamelizeKeys(obj) {
|
|
17
|
-
if (!
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
if (!isObject(obj) ||
|
|
28
|
+
obj instanceof Date ||
|
|
29
|
+
obj instanceof RegExp ||
|
|
30
|
+
typeof obj === 'boolean' ||
|
|
31
|
+
typeof obj === 'function') {
|
|
22
32
|
return obj;
|
|
23
33
|
}
|
|
24
34
|
let output;
|
|
25
35
|
let i = 0;
|
|
26
36
|
let l = 0;
|
|
27
|
-
if (
|
|
37
|
+
if (Array.isArray(obj)) {
|
|
28
38
|
output = [];
|
|
29
39
|
for (l = obj.length; i < l; i++) {
|
|
30
40
|
output.push(decamelizeKeys(obj[i]));
|
|
@@ -34,14 +44,14 @@ function decamelizeKeys(obj) {
|
|
|
34
44
|
output = {};
|
|
35
45
|
for (const key in obj) {
|
|
36
46
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
37
|
-
output[
|
|
47
|
+
output[snakeCase(key)] = decamelizeKeys(obj[key]);
|
|
38
48
|
}
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
51
|
return output;
|
|
42
52
|
}
|
|
43
53
|
export function convertToSnakeCase(input) {
|
|
44
|
-
if (!input || !
|
|
54
|
+
if (!input || !isObject(input)) {
|
|
45
55
|
return input;
|
|
46
56
|
}
|
|
47
57
|
if (isTopLevelCustomDataCamel(input)) {
|
|
@@ -7,6 +7,7 @@ export * from './business/index.js';
|
|
|
7
7
|
export * from './subscription/index.js';
|
|
8
8
|
export * from './address/index.js';
|
|
9
9
|
export * from './discount/index.js';
|
|
10
|
+
export * from './payment-method/index.js';
|
|
10
11
|
export * from './payout/index.js';
|
|
11
12
|
export * from './report/index.js';
|
|
12
13
|
export * from './shared/index.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class PaymentMethodDeletedNotification {
|
|
2
|
+
constructor(paymentMethod) {
|
|
3
|
+
this.id = paymentMethod.id;
|
|
4
|
+
this.customerId = paymentMethod.customer_id;
|
|
5
|
+
this.addressId = paymentMethod.address_id;
|
|
6
|
+
this.deletionReason = paymentMethod.deletion_reason;
|
|
7
|
+
this.type = paymentMethod.type;
|
|
8
|
+
this.origin = paymentMethod.origin;
|
|
9
|
+
this.savedAt = paymentMethod.saved_at;
|
|
10
|
+
this.updatedAt = paymentMethod.updated_at;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class PaymentMethodNotification {
|
|
2
|
+
constructor(paymentMethod) {
|
|
3
|
+
this.id = paymentMethod.id;
|
|
4
|
+
this.customerId = paymentMethod.customer_id;
|
|
5
|
+
this.addressId = paymentMethod.address_id;
|
|
6
|
+
this.type = paymentMethod.type;
|
|
7
|
+
this.origin = paymentMethod.origin;
|
|
8
|
+
this.savedAt = paymentMethod.saved_at;
|
|
9
|
+
this.updatedAt = paymentMethod.updated_at;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BillingDetailsNotification, ImportMetaNotification, TimePeriodNotification } from '../shared/index.js';
|
|
2
|
+
import { SubscriptionDiscountNotification } from './subscription-discount-notification.js';
|
|
3
|
+
import { SubscriptionItemNotification } from './subscription-item-notification.js';
|
|
4
|
+
import { SubscriptionScheduledChangeNotification } from './subscription-scheduled-change-notification.js';
|
|
5
|
+
import { SubscriptionTimePeriodNotification } from './subscription-time-period-notification.js';
|
|
6
|
+
export class SubscriptionCreatedNotification {
|
|
7
|
+
constructor(subscription) {
|
|
8
|
+
this.id = subscription.id;
|
|
9
|
+
this.status = subscription.status;
|
|
10
|
+
this.transactionId = subscription.transaction_id;
|
|
11
|
+
this.customerId = subscription.customer_id;
|
|
12
|
+
this.addressId = subscription.address_id;
|
|
13
|
+
this.businessId = subscription.business_id ? subscription.business_id : null;
|
|
14
|
+
this.currencyCode = subscription.currency_code;
|
|
15
|
+
this.createdAt = subscription.created_at;
|
|
16
|
+
this.updatedAt = subscription.updated_at;
|
|
17
|
+
this.startedAt = subscription.started_at ? subscription.started_at : null;
|
|
18
|
+
this.firstBilledAt = subscription.first_billed_at ? subscription.first_billed_at : null;
|
|
19
|
+
this.nextBilledAt = subscription.next_billed_at ? subscription.next_billed_at : null;
|
|
20
|
+
this.pausedAt = subscription.paused_at ? subscription.paused_at : null;
|
|
21
|
+
this.canceledAt = subscription.canceled_at ? subscription.canceled_at : null;
|
|
22
|
+
this.discount = subscription.discount ? new SubscriptionDiscountNotification(subscription.discount) : null;
|
|
23
|
+
this.collectionMode = subscription.collection_mode;
|
|
24
|
+
this.billingDetails = subscription.billing_details
|
|
25
|
+
? new BillingDetailsNotification(subscription.billing_details)
|
|
26
|
+
: null;
|
|
27
|
+
this.currentBillingPeriod = subscription.current_billing_period
|
|
28
|
+
? new SubscriptionTimePeriodNotification(subscription.current_billing_period)
|
|
29
|
+
: null;
|
|
30
|
+
this.billingCycle = new TimePeriodNotification(subscription.billing_cycle);
|
|
31
|
+
this.scheduledChange = subscription.scheduled_change
|
|
32
|
+
? new SubscriptionScheduledChangeNotification(subscription.scheduled_change)
|
|
33
|
+
: null;
|
|
34
|
+
this.items = subscription.items.map((item) => new SubscriptionItemNotification(item));
|
|
35
|
+
this.customData = subscription.custom_data ? subscription.custom_data : null;
|
|
36
|
+
this.importMeta = subscription.import_meta ? new ImportMetaNotification(subscription.import_meta) : null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -7,7 +7,6 @@ export class SubscriptionNotification {
|
|
|
7
7
|
constructor(subscription) {
|
|
8
8
|
this.id = subscription.id;
|
|
9
9
|
this.status = subscription.status;
|
|
10
|
-
this.transactionId = subscription.transaction_id ? subscription.transaction_id : null;
|
|
11
10
|
this.customerId = subscription.customer_id;
|
|
12
11
|
this.addressId = subscription.address_id;
|
|
13
12
|
this.businessId = subscription.business_id ? subscription.business_id : null;
|
|
@@ -3,6 +3,7 @@ export * from './adjustment/index.js';
|
|
|
3
3
|
export * from './business/index.js';
|
|
4
4
|
export * from './customer/index.js';
|
|
5
5
|
export * from './discount/index.js';
|
|
6
|
+
export * from './payment-method/index.js';
|
|
6
7
|
export * from './payout/index.js';
|
|
7
8
|
export * from './price/index.js';
|
|
8
9
|
export * from './product/index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Event } from '../../../entities/events/event.js';
|
|
2
|
+
import { PaymentMethodDeletedNotification } from '../../entities/index.js';
|
|
3
|
+
import { EventName } from '../../helpers/index.js';
|
|
4
|
+
export class PaymentMethodDeletedEvent extends Event {
|
|
5
|
+
constructor(response) {
|
|
6
|
+
super(response);
|
|
7
|
+
this.eventType = EventName.PaymentMethodDeleted;
|
|
8
|
+
this.data = new PaymentMethodDeletedNotification(response.data);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Event } from '../../../entities/events/event.js';
|
|
2
|
+
import { PaymentMethodNotification } from '../../entities/index.js';
|
|
3
|
+
import { EventName } from '../../helpers/index.js';
|
|
4
|
+
export class PaymentMethodSavedEvent extends Event {
|
|
5
|
+
constructor(response) {
|
|
6
|
+
super(response);
|
|
7
|
+
this.eventType = EventName.PaymentMethodSaved;
|
|
8
|
+
this.data = new PaymentMethodNotification(response.data);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Event } from '../../../entities/events/event.js';
|
|
2
2
|
import { EventName } from '../../helpers/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { SubscriptionCreatedNotification } from '../../entities/index.js';
|
|
4
4
|
export class SubscriptionCreatedEvent extends Event {
|
|
5
5
|
constructor(response) {
|
|
6
6
|
super(response);
|
|
7
7
|
this.eventType = EventName.SubscriptionCreated;
|
|
8
|
-
this.data = new
|
|
8
|
+
this.data = new SubscriptionCreatedNotification(response.data);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -14,6 +14,8 @@ export var EventName;
|
|
|
14
14
|
EventName["DiscountCreated"] = "discount.created";
|
|
15
15
|
EventName["DiscountUpdated"] = "discount.updated";
|
|
16
16
|
EventName["DiscountImported"] = "discount.imported";
|
|
17
|
+
EventName["PaymentMethodDeleted"] = "payment_method.deleted";
|
|
18
|
+
EventName["PaymentMethodSaved"] = "payment_method.saved";
|
|
17
19
|
EventName["PayoutCreated"] = "payout.created";
|
|
18
20
|
EventName["PayoutPaid"] = "payout.paid";
|
|
19
21
|
EventName["PriceCreated"] = "price.created";
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { WebhooksValidator } from './webhooks-validator.js';
|
|
11
11
|
import { EventName } from './types.js';
|
|
12
|
-
import { AddressCreatedEvent, AddressImportedEvent, AddressUpdatedEvent, AdjustmentCreatedEvent, AdjustmentUpdatedEvent, BusinessCreatedEvent, BusinessImportedEvent, BusinessUpdatedEvent, CustomerCreatedEvent, CustomerImportedEvent, CustomerUpdatedEvent, DiscountCreatedEvent, DiscountImportedEvent, DiscountUpdatedEvent, PayoutCreatedEvent, PayoutPaidEvent, PriceCreatedEvent, PriceImportedEvent, PriceUpdatedEvent, ProductCreatedEvent, ProductImportedEvent, ProductUpdatedEvent, ReportCreatedEvent, ReportUpdatedEvent, SubscriptionActivatedEvent, SubscriptionCanceledEvent, SubscriptionCreatedEvent, SubscriptionImportedEvent, SubscriptionPastDueEvent, SubscriptionPausedEvent, SubscriptionResumedEvent, SubscriptionTrialingEvent, SubscriptionUpdatedEvent, TransactionBilledEvent, TransactionCanceledEvent, TransactionCompletedEvent, TransactionCreatedEvent, TransactionPaidEvent, TransactionPastDueEvent, TransactionPaymentFailedEvent, TransactionReadyEvent, TransactionUpdatedEvent, } from '../events/index.js';
|
|
12
|
+
import { AddressCreatedEvent, AddressImportedEvent, AddressUpdatedEvent, AdjustmentCreatedEvent, AdjustmentUpdatedEvent, BusinessCreatedEvent, BusinessImportedEvent, BusinessUpdatedEvent, CustomerCreatedEvent, CustomerImportedEvent, CustomerUpdatedEvent, DiscountCreatedEvent, DiscountImportedEvent, DiscountUpdatedEvent, PaymentMethodDeletedEvent, PaymentMethodSavedEvent, PayoutCreatedEvent, PayoutPaidEvent, PriceCreatedEvent, PriceImportedEvent, PriceUpdatedEvent, ProductCreatedEvent, ProductImportedEvent, ProductUpdatedEvent, ReportCreatedEvent, ReportUpdatedEvent, SubscriptionActivatedEvent, SubscriptionCanceledEvent, SubscriptionCreatedEvent, SubscriptionImportedEvent, SubscriptionPastDueEvent, SubscriptionPausedEvent, SubscriptionResumedEvent, SubscriptionTrialingEvent, SubscriptionUpdatedEvent, TransactionBilledEvent, TransactionCanceledEvent, TransactionCompletedEvent, TransactionCreatedEvent, TransactionPaidEvent, TransactionPastDueEvent, TransactionPaymentFailedEvent, TransactionReadyEvent, TransactionUpdatedEvent, } from '../events/index.js';
|
|
13
13
|
import { Logger } from '../../internal/base/logger.js';
|
|
14
14
|
export class Webhooks {
|
|
15
15
|
unmarshal(requestBody, secretKey, signature) {
|
|
@@ -59,6 +59,10 @@ export class Webhooks {
|
|
|
59
59
|
return new DiscountImportedEvent(data);
|
|
60
60
|
case EventName.DiscountUpdated:
|
|
61
61
|
return new DiscountUpdatedEvent(data);
|
|
62
|
+
case EventName.PaymentMethodDeleted:
|
|
63
|
+
return new PaymentMethodDeletedEvent(data);
|
|
64
|
+
case EventName.PaymentMethodSaved:
|
|
65
|
+
return new PaymentMethodSavedEvent(data);
|
|
62
66
|
case EventName.PayoutCreated:
|
|
63
67
|
return new PayoutCreatedEvent(data);
|
|
64
68
|
case EventName.PayoutPaid:
|
|
@@ -7,6 +7,7 @@ export * from './business/index.js';
|
|
|
7
7
|
export * from './subscription/index.js';
|
|
8
8
|
export * from './address/index.js';
|
|
9
9
|
export * from './discount/index.js';
|
|
10
|
+
export * from './payment-method/index.js';
|
|
10
11
|
export * from './payout/index.js';
|
|
11
12
|
export * from './report/index.js';
|
|
12
13
|
export * from './shared/index.js';
|
package/dist/esm/notifications/types/payment-method/payment-method-deleted-notification-response.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './subscription-created-notification-response.js';
|
|
1
2
|
export * from './subscription-discount-notification-response.js';
|
|
2
3
|
export * from './subscription-time-period-notification-response.js';
|
|
3
4
|
export * from './subscription-scheduled-change-notification-response.js';
|
package/dist/esm/notifications/types/subscription/subscription-created-notification-response.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/paddle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Client } from './internal/api/client.js';
|
|
2
2
|
import { Environment, LogLevel } from './internal/index.js';
|
|
3
|
-
import { AddressesResource, AdjustmentsResource, BusinessesResource, CustomersResource, DiscountsResource, EventTypesResource, NotificationSettingsResource, NotificationsResource, PricesResource, PricingPreviewResource, ProductsResource, ReportsResource, SimulationTypesResource, SimulationsResource, SimulationRunsResource, SimulationRunEventsResource, SubscriptionsResource, TransactionsResource, } from './resources/index.js';
|
|
3
|
+
import { AddressesResource, AdjustmentsResource, BusinessesResource, CustomersResource, DiscountsResource, EventTypesResource, NotificationSettingsResource, NotificationsResource, PaymentMethodsResource, PricesResource, PricingPreviewResource, ProductsResource, ReportsResource, SimulationTypesResource, SimulationsResource, SimulationRunsResource, SimulationRunEventsResource, SubscriptionsResource, TransactionsResource, } from './resources/index.js';
|
|
4
4
|
import { EventsResource } from './resources/events/index.js';
|
|
5
5
|
import { Webhooks } from './notifications/index.js';
|
|
6
6
|
export class Paddle {
|
|
@@ -19,6 +19,7 @@ export class Paddle {
|
|
|
19
19
|
this.businesses = new BusinessesResource(this.client);
|
|
20
20
|
this.discounts = new DiscountsResource(this.client);
|
|
21
21
|
this.subscriptions = new SubscriptionsResource(this.client);
|
|
22
|
+
this.paymentMethods = new PaymentMethodsResource(this.client);
|
|
22
23
|
this.pricingPreview = new PricingPreviewResource(this.client);
|
|
23
24
|
this.events = new EventsResource(this.client);
|
|
24
25
|
this.webhooks = new Webhooks();
|
|
@@ -8,13 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { BaseResource, PathParameters, QueryParameters } from '../../internal/base/index.js';
|
|
11
|
-
import { CreditBalance, Customer, CustomerCollection } from '../../entities/index.js';
|
|
11
|
+
import { CreditBalance, Customer, CustomerCollection, AuthToken } from '../../entities/index.js';
|
|
12
12
|
const CustomerPaths = {
|
|
13
13
|
list: '/customers',
|
|
14
14
|
create: '/customers',
|
|
15
15
|
get: '/customers/{customer_id}',
|
|
16
16
|
update: '/customers/{customer_id}',
|
|
17
17
|
getCustomerBalance: '/customers/{customer_id}/credit-balances',
|
|
18
|
+
generate: '/customers/{customer_id}/auth-token',
|
|
18
19
|
};
|
|
19
20
|
export * from './operations/index.js';
|
|
20
21
|
export class CustomersResource extends BaseResource {
|
|
@@ -65,4 +66,14 @@ export class CustomersResource extends BaseResource {
|
|
|
65
66
|
return yield this.update(customerId, { status: 'archived' });
|
|
66
67
|
});
|
|
67
68
|
}
|
|
69
|
+
generateAuthToken(customerId) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const urlWithPathParams = new PathParameters(CustomerPaths.generate, {
|
|
72
|
+
customer_id: customerId,
|
|
73
|
+
}).deriveUrl();
|
|
74
|
+
const response = yield this.client.post(urlWithPathParams, undefined);
|
|
75
|
+
const data = this.handleResponse(response);
|
|
76
|
+
return new AuthToken(data);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
68
79
|
}
|
|
@@ -7,6 +7,7 @@ export * from './prices/index.js';
|
|
|
7
7
|
export * from './products/index.js';
|
|
8
8
|
export * from './subscriptions/index.js';
|
|
9
9
|
export * from './transactions/index.js';
|
|
10
|
+
export * from './payment-methods/index.js';
|
|
10
11
|
export * from './pricing-preview/index.js';
|
|
11
12
|
export * from './event-types/index.js';
|
|
12
13
|
export * from './notification-settings/index.js';
|