diff --git a/test/helpers.js b/test/helpers.js index ebee03f..3b1b5a0 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -486,6 +486,22 @@ module.exports = { api.PayIns.createRefund(payIn.Id, refund, callback); }, + getPartialRefundForPayIn: function(api, user, payIn, callback) { + var refund = { + AuthorId: user.Id, + DebitedFunds: new api.models.Money({ + Amount: 100, + Currency: payIn.DebitedFunds.Currency + }), + Fees: new api.models.Money({ + Amount: 10, + Currency: payIn.Fees.Currency + }), + }; + + api.PayIns.createRefund(payIn.Id, refund, callback); + }, + getPaylineCorrectRegistartionData: function(cardRegistration, callback) { /* ****** DO NOT use this code in a production environment - it is just for unit tests. In production you are not allowed to have the user's card details pass via your server (which is what is required to use this code here) ******* diff --git a/test/services/PayIns.js b/test/services/PayIns.js index cf59d49..4341edb 100644 --- a/test/services/PayIns.js +++ b/test/services/PayIns.js @@ -111,6 +111,23 @@ describe('PayIns', function () { expect(refund.Nature).to.equal('REFUND'); }); }); + + describe('Create Partial Refund', function () { + var refund; + + before(function (done) { + helpers.getPartialRefundForPayIn(api, john, payIn, function (data, response) { + refund = data; + done(); + }); + }); + + it('should succeed', function () { + expect(refund.Id).to.not.be.null; + expect(refund.Type).to.equal('PAYOUT'); + expect(refund.Nature).to.equal('REFUND'); + }); + }); }); describe('PreAuthorizedDirect', function () { diff --git a/typings/mangopay2-nodejs-sdk-tests.ts b/typings/mangopay2-nodejs-sdk-tests.ts index 7467686..a8d6b1f 100644 --- a/typings/mangopay2-nodejs-sdk-tests.ts +++ b/typings/mangopay2-nodejs-sdk-tests.ts @@ -841,6 +841,14 @@ api.PayIns.createRefund("payin-id", {AuthorId: "user-id"}).then(data => { const d = data; // $ExpectType RefundData }); +api.PayIns.createRefund("payin-id", { + AuthorId: "user-id", + DebitedFunds: {Amount: 100, Currency: "EUR"}, + Fees: {Amount: 15, Currency: "EUR"} +}).then(data => { + const d = data; // $ExpectType RefundData +}); + api.PayIns.getRefunds("payin-id").then(data => { const d = data; // $ExpectType RefundData[] });