softycomp-node 1.0.2 → 1.0.4

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
@@ -6,7 +6,7 @@
6
6
  * @see https://softycompdistribution.co.za
7
7
  * @see https://webapps.softycomp.co.za (API documentation)
8
8
  */
9
- export type BillFrequency = 'once-off' | 'monthly' | 'yearly';
9
+ export type BillFrequency = 'once-off' | 'monthly' | 'weekly' | 'yearly' | 'subscription';
10
10
  export type PaymentStatus = 'pending' | 'completed' | 'failed' | 'cancelled';
11
11
  export type WebhookType = 'pending' | 'successful' | 'failed' | 'cancelled';
12
12
  export interface SoftyCompConfig {
@@ -32,7 +32,7 @@ export interface CreateBillParams {
32
32
  reference: string;
33
33
  /** Bill description */
34
34
  description?: string;
35
- /** Payment frequency: 'once-off', 'monthly', or 'yearly' */
35
+ /** Payment frequency: 'once-off', 'weekly', 'monthly', 'yearly', or 'subscription' */
36
36
  frequency: BillFrequency;
37
37
  /** Commencement date for recurring bills (YYYY-MM-DD). Must be future date (min tomorrow). Ignored for once-off. */
38
38
  commencementDate?: string;
package/dist/index.js CHANGED
@@ -113,8 +113,12 @@ class SoftyComp {
113
113
  */
114
114
  async createBill(params) {
115
115
  const isRecurring = params.frequency !== 'once-off';
116
- // Frequency type mapping: 1=once-off, 2=monthly, 6=yearly (valid range is 1-6)
117
- const frequencyTypeID = params.frequency === 'yearly' ? 6 : params.frequency === 'monthly' ? 2 : 1;
116
+ // Frequency type mapping from SoftyComp docs:
117
+ // 1=Once Off, 2=Monthly, 3=Weekly, 4=Yearly, 5=To Collect Amount, 6=Subscription
118
+ const frequencyMap = {
119
+ 'once-off': 1, 'monthly': 2, 'weekly': 3, 'yearly': 4, 'subscription': 6
120
+ };
121
+ const frequencyTypeID = frequencyMap[params.frequency] ?? 1;
118
122
  // Build the bill item
119
123
  const item = {
120
124
  Description: params.description || 'Payment',
@@ -149,7 +153,13 @@ class SoftyComp {
149
153
  else {
150
154
  item.RecurringMonth = null;
151
155
  }
152
- item.DayOfWeek = null;
156
+ // DayOfWeek required for weekly frequency (1=Monday...7=Sunday)
157
+ if (params.frequency === 'weekly') {
158
+ item.DayOfWeek = params.recurringDay || commencementDate.getDay() || 7; // JS Sunday=0 → 7
159
+ }
160
+ else {
161
+ item.DayOfWeek = null;
162
+ }
153
163
  item.ExpiryDate = null;
154
164
  item.InitialAmount = null;
155
165
  item.ToCollectAmount = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "softycomp-node",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Node.js SDK for SoftyComp — South African bill presentment and debit order platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",