-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from mollie/MOL-591/PICT-266
PICT-266: CR - Update billingAddress.email parameter
- Loading branch information
Showing
6 changed files
with
83 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import { | |
parseStringToJsonObject, | ||
removeEmptyProperties, | ||
roundSurchargeAmountToCent, | ||
validateEmail, | ||
} from '../../src/utils/app.utils'; | ||
import { logger } from '../../src/utils/logger.utils'; | ||
import CustomError from '../../src/errors/custom.error'; | ||
|
@@ -91,16 +90,6 @@ describe('Test removeEmptyProperties', () => { | |
}); | ||
}); | ||
|
||
describe('Test validateEmail', () => { | ||
it('should return false when the targeted string is an invalid email', () => { | ||
expect(validateEmail('123123')).toBe(false); | ||
}); | ||
|
||
it('should return true when the targeted string is a valid email', () => { | ||
expect(validateEmail('[email protected]')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('Test convertCentToEUR', () => { | ||
it('should return correct result', () => { | ||
expect(convertCentToEUR(100, 2)).toBe(1); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -842,6 +842,74 @@ describe('createMollieCreatePaymentParams', () => { | |
// }); | ||
// }); | ||
|
||
it('should be able to create mollie payment params including billing email address with payment przelewy24', async () => { | ||
const cart = { | ||
id: 'cart-test-id', | ||
shippingInfo: {}, | ||
} as Cart; | ||
|
||
const customFieldObject = { | ||
description: 'Test payment', | ||
locale: 'en_GB', | ||
redirectUrl: 'https://example.com/success', | ||
webhookUrl: 'https://example.com/webhook', | ||
billingEmail: '[email protected]', | ||
}; | ||
|
||
const CTPayment: Payment = { | ||
id: '5c8b0375-305a-4f19-ae8e-07806b101999', | ||
version: 1, | ||
createdAt: '2024-07-04T14:07:35.625Z', | ||
lastModifiedAt: '2024-07-04T14:07:35.625Z', | ||
amountPlanned: { | ||
type: 'centPrecision', | ||
currencyCode: 'EUR', | ||
centAmount: 2000, | ||
fractionDigits: 2, | ||
}, | ||
paymentStatus: {}, | ||
transactions: [], | ||
interfaceInteractions: [], | ||
paymentMethodInfo: { | ||
method: PaymentMethod.przelewy24, | ||
}, | ||
custom: { | ||
type: { | ||
typeId: 'type', | ||
id: 'sctm_payment', | ||
}, | ||
fields: { | ||
sctm_create_payment_request: JSON.stringify(customFieldObject), | ||
}, | ||
}, | ||
}; | ||
|
||
const extensionUrl = 'https://example.com/webhook'; | ||
|
||
const mollieCreatePaymentParams: PaymentCreateParams = createMollieCreatePaymentParams( | ||
CTPayment, | ||
extensionUrl, | ||
0, | ||
cart, | ||
); | ||
|
||
expect(mollieCreatePaymentParams).toEqual({ | ||
method: PaymentMethod.przelewy24, | ||
amount: { | ||
currency: 'EUR', | ||
value: '20.00', | ||
}, | ||
locale: customFieldObject.locale, | ||
redirectUrl: customFieldObject.redirectUrl, | ||
webhookUrl: extensionUrl, | ||
description: customFieldObject.description, | ||
billingAddress: { | ||
email: customFieldObject.billingEmail, | ||
}, | ||
lines: [], | ||
}); | ||
}); | ||
|
||
it('should able to create a mollie payment params from CommerceTools payment object including a line item for shipping amount', async () => { | ||
const cart = { | ||
id: 'cart-test-id', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters