Skip to content

Commit

Permalink
Dint 1312 - Removing Payment code mappings to support all payment cod…
Browse files Browse the repository at this point in the history
…es (#154)
  • Loading branch information
benjaminkalk authored May 30, 2024
1 parent 662deb1 commit 388ca81
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
}
20 changes: 2 additions & 18 deletions packages/storefront-events-collector/src/utils/aep/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@ import * as sdkSchemas from "@adobe/magento-storefront-events-sdk/src/types/sche

import { Order, Payment } from "../../types/aep";

const getAepPaymentCode = (paymentMethodCode: string) => {
switch (paymentMethodCode) {
case "checkmo":
return "check";
case "banktransfer":
return "wire_transfer";
case "cashondelivery":
return "cash";
case "purchaseorder":
case "free":
case "companycredit":
default:
return "other";
}
};

const createOrder = (
orderFromCustomContext: Order | undefined,
orderContext: sdkSchemas.Order,
Expand All @@ -34,7 +18,7 @@ const createOrder = (
payments = orderContext.payments.map((payment) => {
return {
paymentAmount: Number(payment.total || 0),
paymentType: getAepPaymentCode(payment.paymentMethodCode),
paymentType: payment.paymentMethodCode,
transactionID: payment?.orderId ? String(payment.orderId) : String(orderContext?.orderId),
currencyCode: storefrontInstanceContext?.storeViewCurrencyCode,
};
Expand All @@ -44,7 +28,7 @@ const createOrder = (
payments = [
{
paymentAmount: Number(orderContext?.grandTotal || 0),
paymentType: getAepPaymentCode(orderContext?.paymentMethodCode),
paymentType: orderContext?.paymentMethodCode,
transactionID: String(orderContext?.orderId),
currencyCode: storefrontInstanceContext?.storeViewCurrencyCode,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ test("correctly structures AEP event and calls alloy.sendEvent", () => {
{
currencyCode: "USD",
paymentAmount: 30,
paymentType: "other",
paymentType: "credit card",
transactionID: "111111",
},
{
currencyCode: "USD",
paymentAmount: 39.98,
paymentType: "other",
paymentType: "cash",
transactionID: "111111",
},
],
Expand Down

0 comments on commit 388ca81

Please # to comment.