wabe 0.5.9 → 0.5.11

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.d.ts CHANGED
@@ -1132,6 +1132,8 @@ export type CreatePaymentOptions = {
1132
1132
  cancelUrl: string;
1133
1133
  automaticTax?: boolean;
1134
1134
  recurringInterval?: "month" | "year";
1135
+ createInvoice?: boolean;
1136
+ allowPromotionCode?: boolean;
1135
1137
  };
1136
1138
  export type InitWebhookOptions = {
1137
1139
  webhookUrl: string;
@@ -1163,29 +1165,44 @@ export type ValidateWebhookOptions = {
1163
1165
  * ValidateWebhookOutput
1164
1166
  * @property valid - Whether the webhook is valid or not
1165
1167
  * @property payload - The payload of the webhook
1166
- * @property type - The type of the webhook
1167
- * @property customerId - The customer id
1168
- * @property createdAt - The created at timestamp in seconds
1169
- * @property currency - The currency
1170
- * @property amount - The amount
1171
- * @property paymentMethod - The payment method
1172
1168
  */
1173
1169
  export type ValidateWebhookOutput = {
1174
1170
  isValid: boolean;
1175
- payload: {
1176
- type: string;
1177
- customerId?: string;
1178
- createdAt?: number;
1179
- currency?: string;
1180
- amount?: number;
1181
- paymentMethod?: Array<string>;
1182
- };
1171
+ type: string;
1172
+ payload: any | null;
1183
1173
  };
1184
1174
  export type InitWebhookOutput = {
1185
1175
  webhookId: string;
1186
1176
  endpointSecret: string;
1187
1177
  };
1178
+ export type CreateCouponOptions = {
1179
+ amountOff?: number;
1180
+ currency?: Currency$1;
1181
+ duration?: "forever" | "once" | "repeating";
1182
+ durationInMonths?: number;
1183
+ name?: string;
1184
+ percentOff?: number;
1185
+ maxRedemptions?: number;
1186
+ };
1187
+ export type CreatePromotionCodeOptions = {
1188
+ couponId: string;
1189
+ code?: string;
1190
+ active?: boolean;
1191
+ maxRedemptions?: number;
1192
+ };
1188
1193
  export interface PaymentAdapter {
1194
+ /**
1195
+ * Create a coupon
1196
+ * @param options CreateCouponOptions
1197
+ * @returns id The coupon id
1198
+ */
1199
+ createCoupon: (options: CreateCouponOptions) => Promise<string>;
1200
+ /**
1201
+ * Create a promotion code from a coupon
1202
+ * @param options CreatePromotionCodeOptions
1203
+ * @returns code The promotion code
1204
+ */
1205
+ createPromotionCode: (options: CreatePromotionCodeOptions) => Promise<string>;
1189
1206
  /**
1190
1207
  * Get a customer by id
1191
1208
  * @param id The customer id
@@ -1245,6 +1262,8 @@ declare class PaymentController implements PaymentAdapter {
1245
1262
  private adapter;
1246
1263
  private config;
1247
1264
  constructor(paymentConfig: PaymentConfig);
1265
+ createCoupon(options: CreateCouponOptions): Promise<string>;
1266
+ createPromotionCode(options: CreatePromotionCodeOptions): Promise<string>;
1248
1267
  getCustomerById(options: GetCustomerByIdOptions): Promise<{
1249
1268
  email: string | null;
1250
1269
  }>;
@@ -1387,11 +1406,12 @@ export declare class PaymentDevAdapter implements PaymentAdapter {
1387
1406
  getCustomerById(): Promise<{
1388
1407
  email: string;
1389
1408
  }>;
1409
+ createCoupon(): Promise<string>;
1410
+ createPromotionCode(): Promise<string>;
1390
1411
  validateWebhook(): Promise<{
1391
1412
  isValid: boolean;
1392
- payload: {
1393
- type: string;
1394
- };
1413
+ payload: {};
1414
+ type: string;
1395
1415
  }>;
1396
1416
  createCustomer(): Promise<string>;
1397
1417
  createPayment(): Promise<string>;
package/dist/index.js CHANGED
@@ -61414,8 +61414,14 @@ class PaymentDevAdapter {
61414
61414
  email: "customer@test.com"
61415
61415
  };
61416
61416
  }
61417
+ async createCoupon() {
61418
+ return "";
61419
+ }
61420
+ async createPromotionCode() {
61421
+ return "";
61422
+ }
61417
61423
  async validateWebhook() {
61418
- return { isValid: true, payload: { type: "" } };
61424
+ return { isValid: true, payload: {}, type: "" };
61419
61425
  }
61420
61426
  async createCustomer() {
61421
61427
  return "";
@@ -75661,6 +75667,12 @@ class PaymentController {
75661
75667
  this.adapter = paymentConfig.adapter;
75662
75668
  this.config = paymentConfig;
75663
75669
  }
75670
+ createCoupon(options) {
75671
+ return this.adapter.createCoupon(options);
75672
+ }
75673
+ createPromotionCode(options) {
75674
+ return this.adapter.createPromotionCode(options);
75675
+ }
75664
75676
  getCustomerById(options) {
75665
75677
  return this.adapter.getCustomerById(options);
75666
75678
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wabe",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "description": "Your backend in minutes not days",
5
5
  "homepage": "https://wabe.dev",
6
6
  "author": {