UNPKG

sain-apigw-selcom

Version:
97 lines (95 loc) 2.68 kB
async function mockResponse(path, method, data) { console.log("mock response", path, path.includes("create-order")); if (path.includes("checkout/create-order")) { return { reference: Math.floor(Math.random() * 90000000) + 10000000, resultcode: "000", result: "SUCCESS", message: "Payment notification logged", data: [ { gateway_buyer_uuid: Math.floor(Math.random() * 90000000) + 10000000, payment_token: Math.floor(Math.random() * 90000000) + 10000000, qr: "QR", payment_gateway_url: "http:example.com/Ahesmey", }, ], }; } if (path.includes("checkout/cancel-order")) { return { reference: Math.floor(Math.random() * 90000000) + 10000000, resultcode: "000", result: "SUCCESS", message: "Order cancelled successfully", data: [], }; } if (path.includes("checkout/order-status")) { return { reference: "0289999288", resultcode: "000", result: "SUCCESS", message: "Order fetch successful", data: [ { order_id: "123", creation_date: "2019-06-06 22:00:00", amount: "1000", payment_status: "PENDING", transid: null, channel: null, reference: null, phone: null, }, ], }; } if (path.includes("checkout/list-orders")) { return { reference: "0289999288", resultcode: "000", result: "SUCCESS", message: "Order fetch successful", data: [ { order_id: "123", creation_date: "2019-06-06 22:00:00", amount: "1000", payment_status: "PENDING", }, { order_id: "124", creation_date: "2019-06-06 22:10:00", amount: "2000", payment_status: "CANCEL", }, ], }; } if (path.includes("checkout/stored-cards")) { return { reference: "0289999288", resultcode: "000", result: "SUCCESS", message: "Order fetch successful", data: [ { masked_card: data.masked_card, creation_date: new Date().toISOString().replace("T", " "), card_token: "ABC123423232", name: data.name, card_type: data.card_type, }, { masked_card: "5555-12XX-XXXX-4321", creation_date: "2019-06-06 23:00:00", card_token: "ABC123423244", name: "JOE JOHN", card_type: "001", }, ], }; } } module.exports = { mockResponse };