Skip to content

Commit

Permalink
fix(vaulting): PAYMENTS-4820 Add currency to checkout request to dele…
Browse files Browse the repository at this point in the history
…te a stored card
  • Loading branch information
Tharaae committed Nov 21, 2019
1 parent 3816a19 commit dbdfb4b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/store/store-request-sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export default class StoreRequestSender {
const url = this.urlHelper.getInstrumentByIdUrl(
data.storeId,
data.customerId,
data.instrumentId
data.instrumentId,
data.currencyCode
);
const options = {
method: DELETE,
Expand Down
5 changes: 3 additions & 2 deletions src/store/url-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ export default class UrlHelper {
* @param {number} storeId
* @param {number} customerId
* @param {number} instrumentId
* @param {string} currencyCode
* @returns {string}
*/
getInstrumentByIdUrl(storeId, customerId, instrumentId) {
return `${this.host}/api/v2/stores/${storeId}/shoppers/${customerId}/instruments/${instrumentId}`;
getInstrumentByIdUrl(storeId, customerId, instrumentId, currencyCode) {
return `${this.host}/api/v2/stores/${storeId}/shoppers/${customerId}/instruments/${instrumentId}?currency_code=${currencyCode}`;
}
}
3 changes: 2 additions & 1 deletion test/store/store-request-sender.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ describe('StoreRequestSender', () => {
expect(urlHelperMock.getInstrumentByIdUrl).toHaveBeenCalledWith(
data.storeId,
data.customerId,
data.instrumentId
data.instrumentId,
data.currencyCode
);
expect(requestSenderMock.sendRequest).toHaveBeenCalled();
expect(mappers.mapToHeaders).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions test/store/url-helper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ describe('UrlHelper', () => {
});

it('returns a URL for generating a client token', () => {
const result = urlHelper.getInstrumentByIdUrl(storeId, shopperId, instrumentId);
const expected = `${host}/api/v2/stores/${storeId}/shoppers/${shopperId}/instruments/${instrumentId}`;
const result = urlHelper.getInstrumentByIdUrl(storeId, shopperId, instrumentId, currencyCode);
const expected = `${host}/api/v2/stores/${storeId}/shoppers/${shopperId}/instruments/${instrumentId}?currency_code=${currencyCode}`;

expect(result).toEqual(expected);
});
Expand Down

0 comments on commit dbdfb4b

Please sign in to comment.