diff --git a/api/__tests__/paypal.test.ts b/api/__tests__/paypal.test.ts index 4facda59..36ee2f07 100644 --- a/api/__tests__/paypal.test.ts +++ b/api/__tests__/paypal.test.ts @@ -26,7 +26,7 @@ afterAll(async () => { describe('POST /api/create-paypal-order', () => { it('should create paypal order', async () => { - // test success (create checkout session whith non existant user) + // test success (create paypal order whith non existant user) const payload: bookcarsTypes.CreatePayPalOrderPayload = { amount: 234, currency: 'USD', @@ -39,7 +39,7 @@ describe('POST /api/create-paypal-order', () => { expect(res.statusCode).toBe(200) expect(res.body.length).toBeGreaterThan(0) - // test failure (create checkout sessions failure) + // test failure (create paypal order failure) payload.currency = 'xxxxxxxxxxxxxxx' res = await request(app) .post('/api/create-paypal-order') diff --git a/api/src/common/helper.ts b/api/src/common/helper.ts index 5afd1882..6fb9afef 100644 --- a/api/src/common/helper.ts +++ b/api/src/common/helper.ts @@ -271,9 +271,10 @@ export const validateAccessToken = async (socialSignInType: bookcarsTypes.Social * 1 1.00 * 1.2 1.20 * 1.341 1.34 - * 1.345 1.35 + * 1.345 1.34 + * 1.378 1.37 * * @param {number} price * @returns {string} */ -export const formatPayPalPrice = (price: number) => (Math.round(price * 100) / 100).toFixed(2) +export const formatPayPalPrice = (price: number) => (Math.floor(price * 100) / 100).toFixed(2) diff --git a/api/src/config/env.config.ts b/api/src/config/env.config.ts index 88130680..7d488154 100644 --- a/api/src/config/env.config.ts +++ b/api/src/config/env.config.ts @@ -36,11 +36,11 @@ export const LANGUAGES = [ ] /** - * Website Name + * Website Name. * * @type {string} */ -export const WEBSITE_NAME = __env__('BC_WEBSITE_NAME', false, 'bookcars') +export const WEBSITE_NAME = __env__('BC_WEBSITE_NAME', false, 'BookCars') /** * Server Port. Default is 4002. diff --git a/api/src/controllers/paypalController.ts b/api/src/controllers/paypalController.ts index 2fcff18e..a0eb1d8f 100644 --- a/api/src/controllers/paypalController.ts +++ b/api/src/controllers/paypalController.ts @@ -40,7 +40,7 @@ export const checkPayPalOrder = async (req: Request, res: Response) => { const booking = await Booking.findOne({ _id: bookingId, expireAt: { $ne: null } }) if (!booking) { const msg = `Booking with id ${bookingId} not found` - logger.info(`[paypal.checkPaypalOrder] ${msg}`) + logger.info(`[paypal.checkPayPalOrder] ${msg}`) return res.status(204).send(msg) } @@ -48,12 +48,12 @@ export const checkPayPalOrder = async (req: Request, res: Response) => { try { order = await paypal.getOrder(orderId) } catch (err) { - logger.error(`[paypal.checkPaypalOrder] retrieve paypal order error: ${orderId}`, err) + logger.error(`[paypal.checkPayPalOrder] retrieve paypal order error: ${orderId}`, err) } if (!order) { const msg = `Order ${order} not found` - logger.info(`[paypal.checkPaypalOrder] ${msg}`) + logger.info(`[paypal.checkPayPalOrder] ${msg}`) return res.status(204).send(msg) } @@ -116,7 +116,7 @@ export const checkPayPalOrder = async (req: Request, res: Response) => { await booking.deleteOne() return res.status(400).send(order.status) } catch (err) { - logger.error(`[paypal.checkPaypalOrder] ${i18n.t('ERROR')}`, err) + logger.error(`[paypal.checkPayPalOrder] ${i18n.t('ERROR')}`, err) return res.status(400).send(i18n.t('ERROR') + err) } } diff --git a/api/src/paypal.ts b/api/src/paypal.ts index 09ef3376..582a72c0 100644 --- a/api/src/paypal.ts +++ b/api/src/paypal.ts @@ -91,6 +91,7 @@ export const getOrder = async (orderId: string) => { `https://api-m.sandbox.paypal.com/v2/checkout/orders/${orderId}`, { headers: { + 'Content-Type': 'application/json', Authorization: `Bearer ${token}`, }, },