Skip to content

Commit

Permalink
BP-3190-Add-getActiveSubscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinor12010 committed Nov 27, 2023
1 parent 9841693 commit 887874b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 59 deletions.
57 changes: 25 additions & 32 deletions example/additional_services/subscription.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
import buckaroo from '../buckarooClient';

const subscription = buckaroo.method('CreditManagement3');
const subscription = buckaroo.method('subscriptions');

subscription.createCombined({
address: undefined,
allowedServices: '',
b2b: '',
bankAccount: { accountName: '', bic: '', iban: '' },
billingTiming: 0,
company: undefined,
configuration: undefined,
configurationCode: '',
customerAccountName: '',
customerBIC: '',
customerIBAN: '',
debtor: { code: '' },
email: '345345345',
includeTransaction: false,
mandateReference: '',
subscriptionGuid: '',
termStartDay: 0,
termStartMonth: 0,
termStartWeek: '',
transactionVatPercentage: 0,
});

buckaroo
.method('ideal')
.combine(subscription)
.pay({
amountDebit: 1,
currency: 'EUR',
description: 'test',
subscription
.create({
additionalParameters: {
signature: 'XXXXXXXX'
},
ratePlans: {
add: {
startDate: '2024-07-23',
ratePlanCode: 'XXXXXXXX'
}
},
ratePlanCharges: {
add: {
ratePlanChargeCode: 'XXXXXXXX'
}
},
configurationCode: 'XXXXXXXX',
configuration: {
name: 'XXXXXXXX'
},
debtor: {
code: 'XXXXXXXX'
}
})
.request();
const getActiveSubscriptions = subscription.getActiveSubscriptions()
4 changes: 4 additions & 0 deletions src/PaymentMethods/Subscriptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ export default class Subscriptions extends PaymentMethod {
this.setServiceList('ResumeSubscription', new ResumeSubscription(payload));
return this.dataRequest();
}
getActiveSubscriptions() {
this.setServiceList('GetActiveSubscriptions',[],'GetActiveSubscriptions')
return this.dataRequest();
}
}
2 changes: 1 addition & 1 deletion src/Services/PaymentMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default abstract class PaymentMethod {
this._serviceVersion = value;
}

get serviceCode(): ServiceCode {
get serviceCode(): ServiceCode | string {
return this._serviceCode ?? 'noservice';
}

Expand Down
58 changes: 32 additions & 26 deletions tests/PaymentMethods/Subscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,37 @@ import buckarooClientTest from '../BuckarooClient.test';
const subscription = buckarooClientTest.method('subscriptions');

describe('Subscription methods', () => {
test('Create', () => {
test('Create', async () => {
return subscription
.create({
additionalParameters: {
signature: 'XXXXXXXX',
signature: 'XXXXXXXX'
},
ratePlans: {
add: {
startDate: '2024-07-23',
ratePlanCode: 'XXXXXXXX',
},
ratePlanCode: 'XXXXXXXX'
}
},
ratePlanCharges: {
add: {
ratePlanChargeCode: 'XXXXXXXX',
},
ratePlanChargeCode: 'XXXXXXXX'
}
},
configurationCode: 'XXXXXXXX',
configuration: {
name: 'XXXXXXXX',
name: 'XXXXXXXX'
},
debtor: {
code: 'XXXXXXXX',
},
code: 'XXXXXXXX'
}
})
.request()
.then((data) => {
.request().then((data) => {
expect(data.hasError()).toBeTruthy();
});
});
test('Update', async () => {
subscription
return subscription
.update({
email: '[email protected]',
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
Expand Down Expand Up @@ -86,7 +85,7 @@ describe('Subscription methods', () => {
country: 'NL',
},
});
subscription
return subscription
.combine('ideal')
.pay({
issuer: 'ABNANL2A',
Expand All @@ -98,12 +97,11 @@ describe('Subscription methods', () => {
expect(data).toBeDefined();
});
});

test('Update Combined Subscription', async () => {
subscription.updateCombined({
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
});
subscription
return subscription
.combine('ideal')
.pay({
issuer: 'ABNANL2A',
Expand All @@ -114,21 +112,22 @@ describe('Subscription methods', () => {
expect(data).toBeDefined();
});
});

test('Stop Subscription', async () => {
const stop = await subscription.stop({
return subscription.stop({
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
}).request().then((res) => {
expect(res.httpResponse.status === 200).toBeTruthy();
});
expect(stop).toBeDefined();
});
test('Subscription Info', async () => {
const info = await subscription.info({
return await subscription.info({
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
}).request().then((res) => {
expect(res.httpResponse.status === 200).toBeTruthy();
});
expect(info).toBeDefined();
});
test('Delete Subscription Config', async () => {
await subscription
return subscription
.deletePaymentConfig({
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
Expand All @@ -138,17 +137,24 @@ describe('Subscription methods', () => {
});
});
test('Subscription Pause', async () => {
const pause = await subscription.pause({
return subscription.pause({
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
resumeDate: '2030-01-01',
});
expect(pause).toBeDefined();
}).request().then((res) => {
expect(res.httpResponse.status === 200).toBeTruthy();
})
});
test('Subscription Resume', async () => {
const resume = await subscription.resume({
return subscription.resume({
resumeDate: '2030-01-01',
subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
}).request().then((res) => {
expect(res.httpResponse.status === 200).toBeTruthy();
});
});
test('Get All Active Subscriptions', async () => {
return subscription.getActiveSubscriptions().request().then((res) => {
expect(res.httpResponse.status === 200).toBeTruthy();
});
expect(resume).toBeDefined();
});
});

0 comments on commit 887874b

Please sign in to comment.