@vindhq/sloud-payment-sdk 1.0.1 → 1.0.3

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
@@ -55,31 +55,68 @@ interface ExternalPaymentWidgetOptions extends BasePaymentWidgetOptions {
55
55
  customer: Customer;
56
56
  }
57
57
  /**
58
- * Options for storefront payment type
59
- * Used for e-commerce orders with products and delivery
58
+ * Base options for storefront payment type (shared fields)
60
59
  */
61
- interface StorefrontPaymentWidgetOptions extends BasePaymentWidgetOptions {
60
+ interface BaseStorefrontPaymentWidgetOptions extends BasePaymentWidgetOptions {
62
61
  type: "storefront";
63
62
  slug: string;
64
63
  amount: number;
65
64
  discount?: number;
66
- channel: ChannelType;
67
65
  customer: Customer;
68
- delivery_details: DeliveryDetails;
69
66
  products: Product[];
70
67
  }
71
- interface SloudfrontPaymentWidgetOptions extends BasePaymentWidgetOptions {
68
+ /**
69
+ * Storefront options when channel is 'pickup' - delivery_details is optional
70
+ */
71
+ interface StorefrontPickupOptions extends BaseStorefrontPaymentWidgetOptions {
72
+ channel: "pickup";
73
+ delivery_details?: DeliveryDetails;
74
+ }
75
+ /**
76
+ * Storefront options when channel is 'delivery' - delivery_details is required
77
+ */
78
+ interface StorefrontDeliveryOptions extends BaseStorefrontPaymentWidgetOptions {
79
+ channel: "delivery";
80
+ delivery_details: DeliveryDetails;
81
+ }
82
+ /**
83
+ * Options for storefront payment type
84
+ * Used for e-commerce orders with products and delivery
85
+ * delivery_details is required only when channel is 'delivery'
86
+ */
87
+ type StorefrontPaymentWidgetOptions = StorefrontPickupOptions | StorefrontDeliveryOptions;
88
+ /**
89
+ * Base options for sloudfront payment type (shared fields)
90
+ */
91
+ interface BaseSloudfrontPaymentWidgetOptions extends BasePaymentWidgetOptions {
72
92
  type: "sloudfront";
73
93
  amount: number;
74
94
  discount?: number;
75
- channel: ChannelType;
76
95
  customer: Customer;
77
- delivery_details: DeliveryDetails;
78
96
  products: Product[];
79
- transaction_id: string;
97
+ transaction_id?: string;
80
98
  customer_id: string;
81
99
  business_id: string;
82
100
  }
101
+ /**
102
+ * Sloudfront options when channel is 'pickup' - delivery_details is optional
103
+ */
104
+ interface SloudfrontPickupOptions extends BaseSloudfrontPaymentWidgetOptions {
105
+ channel: "pickup";
106
+ delivery_details?: DeliveryDetails;
107
+ }
108
+ /**
109
+ * Sloudfront options when channel is 'delivery' - delivery_details is required
110
+ */
111
+ interface SloudfrontDeliveryOptions extends BaseSloudfrontPaymentWidgetOptions {
112
+ channel: "delivery";
113
+ delivery_details: DeliveryDetails;
114
+ }
115
+ /**
116
+ * Options for sloudfront payment type
117
+ * delivery_details is required only when channel is 'delivery'
118
+ */
119
+ type SloudfrontPaymentWidgetOptions = SloudfrontPickupOptions | SloudfrontDeliveryOptions;
83
120
  /**
84
121
  * Discriminated union of all payment widget option types
85
122
  * TypeScript will enforce that the correct fields are provided based on the type
@@ -143,7 +180,7 @@ interface IStorefrontPaymentPayload {
143
180
  email: string;
144
181
  phone_number: string;
145
182
  };
146
- delivery_details: {
183
+ delivery_details?: {
147
184
  street: string;
148
185
  city: string;
149
186
  state: string;
@@ -164,20 +201,20 @@ interface ISloudfrontPaymentPayload {
164
201
  }>;
165
202
  payment_method?: string;
166
203
  channel?: string;
167
- buyer_details: {
204
+ buyer_details?: {
168
205
  first_name: string;
169
206
  last_name: string;
170
207
  email: string;
171
208
  phone_number: string;
172
209
  };
173
- delivery_details: {
210
+ delivery_details?: {
174
211
  street: string;
175
212
  city: string;
176
213
  state: string;
177
214
  country: string;
178
215
  note?: string;
179
216
  };
180
- transaction_id: string;
217
+ transaction_id?: string;
181
218
  customer_id: string;
182
219
  business_id: string;
183
220
  };