Skip to content

Commit

Permalink
feat(common): PAYMENTS-4616 Allow a passthrough for payment data
Browse files Browse the repository at this point in the history
  • Loading branch information
icatalina committed Aug 21, 2019
1 parent 64eb349 commit ab24e7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/payment/v1/payment-mappers/payment-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export default class PaymentMapper {

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

if (payment.instrumentId) {
if (payment.formattedPayload) {
objectAssign(payload, payment.formattedPayload);
} else if (payment.instrumentId) {
objectAssign(payload, {
bigpay_token: this.mapToBigPayToken(data),
});
Expand Down
16 changes: 16 additions & 0 deletions test/payment/v1/payment-mappers/payment-mapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,20 @@ describe('PaymentMapper', () => {

expect(paymentMapper.mapToPayment({})).toEqual({ credit_card: {} });
});

it('uses formattedPayload when provided', () => {
data = merge({}, data, {
payment: { formattedPayload: { credit_card_token: { token: '12356aaa' } } },
});

const output = paymentMapper.mapToPayment(data);

expect(output).toEqual(
jasmine.objectContaining({
credit_card_token: {
token: '12356aaa',
},
})
);
});
});

0 comments on commit ab24e7a

Please sign in to comment.