Skip to content

Commit

Permalink
feat(payment-mapper): map referrer id to payment if available
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldelcore committed Sep 25, 2017
1 parent a6e8a5e commit b434b67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/payment/v1/payment-mappers/payment-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export default class PaymentMapper {
return_url: paymentMethod.returnUrl || (order.payment ? order.payment.returnUrl : null),
};

const method = payment.method;

if (method) {
objectAssign(payload, { method });
}

const nonce = payment.nonce || paymentMethod.nonce;

if (nonce) {
Expand Down
14 changes: 14 additions & 0 deletions test/payment/v1/payment-mappers/payment-mapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ describe('PaymentMapper', () => {
});
});

it('maps the input object into a payment object with method', () => {
data = merge({}, data, {
payment: {
method: 'paypal',
},
});

const output = paymentMapper.mapToPayment(data);

expect(output).toEqual(jasmine.objectContaining({
method: data.payment.method,
}));
});

it('uses the return URL contained in the order object as a fallback', () => {
data = merge({}, data, {
order: {
Expand Down

0 comments on commit b434b67

Please sign in to comment.