Skip to content

Commit

Permalink
reason and description fields are added to refund and cancel requests (
Browse files Browse the repository at this point in the history
…#46)

* reason and description fields are added to refund and cancel requests

* refundReason is added as enum

* values become same in cancel and refund samples
  • Loading branch information
ktoprakucar authored Dec 20, 2017
1 parent caa0851 commit 73839a6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/Iyzipay.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,11 @@ Iyzipay.APM_TYPE = {
GIROPAY: 'GIROPAY'
};

Iyzipay.REFUND_REASON = {
DOUBLE_PAYMENT : 'double_payment',
BUYER_REQUEST : 'buyer_request',
FRAUD : 'fraud',
OTHER : 'other'
};

module.exports = Iyzipay;
4 changes: 3 additions & 1 deletion lib/requests/CreateCancelRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ function CreateCancelRequest(request) {
locale: request['locale'],
conversationId: request['conversationId'],
paymentId: request['paymentId'],
ip: request['ip']
ip: request['ip'],
reason: request['reason'],
description: request["description"]
});
}

Expand Down
4 changes: 3 additions & 1 deletion lib/requests/CreateRefundRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function CreateRefundRequest(request) {
paymentTransactionId: request['paymentTransactionId'],
price: utils.formatPrice(request['price']),
ip: request['ip'],
currency: request["currency"]
currency: request["currency"],
reason: request['reason'],
description: request["description"]
});
}

Expand Down
30 changes: 30 additions & 0 deletions samples/IyzipaySamples.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ describe('Iyzipay API Test', function () {
done();
});
});

it('should cancel payment with reason and description', function (done) {
iyzipay.cancel.create({
locale: Iyzipay.LOCALE.TR,
conversationId: '123456789',
paymentId: '1',
ip: '85.34.78.112',
reason: Iyzipay.REFUND_REASON.OTHER,
description: 'customer requested for default sample'
}, function (err, result) {
console.log(err, result);
done();
});
});
});

describe('Card', function () {
Expand Down Expand Up @@ -720,6 +734,22 @@ describe('Iyzipay API Test', function () {
done();
});
});

it('should refund with reason and description', function (done) {
iyzipay.refund.create({
locale: Iyzipay.LOCALE.TR,
conversationId: '123456789',
paymentTransactionId: '1',
price: '0.5',
currency: Iyzipay.CURRENCY.TRY,
ip: '85.34.78.112',
reason: Iyzipay.REFUND_REASON.OTHER,
description: 'customer requested for default sample'
}, function (err, result) {
console.log(err, result);
done();
});
});
});

describe('Retrieve Transactions Sample', function () {
Expand Down

0 comments on commit 73839a6

Please sign in to comment.