paybridge 0.1.1 → 0.1.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/providers/softycomp.js +12 -12
- package/package.json +1 -1
|
@@ -120,16 +120,14 @@ class SoftyCompProvider extends base_1.PaymentProvider {
|
|
|
120
120
|
}
|
|
121
121
|
async createSubscription(params) {
|
|
122
122
|
this.validateCurrency(params.currency);
|
|
123
|
-
// Map interval to SoftyComp frequency
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
else {
|
|
132
|
-
throw new Error(`SoftyComp does not support ${params.interval} subscriptions. Use monthly or yearly.`);
|
|
123
|
+
// Map interval to SoftyComp frequency from official docs:
|
|
124
|
+
// 1=Once Off, 2=Monthly, 3=Weekly, 4=Yearly, 5=To Collect Amount, 6=Subscription
|
|
125
|
+
const frequencyMap = {
|
|
126
|
+
'weekly': 3, 'monthly': 2, 'yearly': 4
|
|
127
|
+
};
|
|
128
|
+
const frequencyTypeID = frequencyMap[params.interval];
|
|
129
|
+
if (!frequencyTypeID) {
|
|
130
|
+
throw new Error(`SoftyComp does not support ${params.interval} subscriptions. Use weekly, monthly, or yearly.`);
|
|
133
131
|
}
|
|
134
132
|
// Parse and validate start date
|
|
135
133
|
let startDate;
|
|
@@ -230,10 +228,12 @@ class SoftyCompProvider extends base_1.PaymentProvider {
|
|
|
230
228
|
// ==================== Webhooks ====================
|
|
231
229
|
parseWebhook(body, _headers) {
|
|
232
230
|
const event = typeof body === 'string' ? JSON.parse(body) : body;
|
|
233
|
-
//
|
|
231
|
+
// Handle both field names: activityTypeID (docs) and WebhookTypeID (observed)
|
|
232
|
+
// Mapping: 1=Pending, 2=Successful, 3=Failed, 4=Cancelled
|
|
233
|
+
const typeId = event.activityTypeID || event.WebhookTypeID || 1;
|
|
234
234
|
let eventType = 'payment.pending';
|
|
235
235
|
let status = 'pending';
|
|
236
|
-
switch (
|
|
236
|
+
switch (typeId) {
|
|
237
237
|
case 2:
|
|
238
238
|
eventType = 'payment.completed';
|
|
239
239
|
status = 'completed';
|
package/package.json
CHANGED