Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/ Handled partial refund #378

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) *******
Expand Down
17 changes: 17 additions & 0 deletions test/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
8 changes: 8 additions & 0 deletions typings/mangopay2-nodejs-sdk-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
});
Expand Down
Loading