Skip to content

Commit

Permalink
Editing paypalsdkconfig object
Browse files Browse the repository at this point in the history
  • Loading branch information
btafforeau committed Dec 21, 2023
1 parent 7675404 commit c2e7440
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import { PayPalSdkComponent } from './paypal-sdk.component';
import * as PrestashopSite1_7 from '../../../test/mocks/html-templates/prestashop-site-1_7';

function buildDIContainerMock() {
PrestashopSite1_7.mockCheckoutVars();
const payPalSdkConfig = new PayPalSdkConfig();
return {
container: {
PayPalSdkConfig: {
...PayPalSdkConfig,
...payPalSdkConfig,
id: 'foo',
src: 'url',
namespace: 'fooNamespace'
Expand Down Expand Up @@ -132,7 +134,6 @@ describe('src/components/common/paypal-sdk.component.spec.js', () => {
});

test('::render() with new Sdk', () => {
PrestashopSite1_7.mockCheckoutVars();
const diContainer = buildDIContainerMock();
const payPalSdkComponent = new PayPalSdkComponent(diContainer);

Expand Down
38 changes: 20 additions & 18 deletions _dev/js/front/src/config/paypal-sdk.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
export const PayPalSdkConfig = {
sdkConfig: {
dataNamespace: 'ps_checkoutPayPalSdkInstance',
orderId: window.ps_checkoutPayPalOrderId,
dataClientToken: window.ps_checkoutPayPalClientToken,
...window.ps_checkoutPayPalSdkConfig
},
buttonCustomization: window.ps_checkoutPayPalButtonConfiguration,
paymentFieldsCustomization: window.ps_checkout.paymentFieldsCustomization,
expressCheckoutButtonCustomization:
window.ps_checkoutExpressCheckoutButtonCustomization,
hostedFieldsCustomization:
window.ps_checkoutHostedFieldsCustomizationConfiguration,
payLaterOfferMessageCustomization:
window.ps_checkoutPayLaterOfferMessageCustomization,
payLaterOfferBannerCustomization:
window.ps_checkoutPayLaterOfferBannerCustomization,
partnerAttributionId: window.ps_checkoutPartnerAttributionId
export const PayPalSdkConfig = () => {
return {
sdkConfig: {
dataNamespace: 'ps_checkoutPayPalSdkInstance',
orderId: window.ps_checkoutPayPalOrderId,
dataClientToken: window.ps_checkoutPayPalClientToken,
...window.ps_checkoutPayPalSdkConfig
},
buttonCustomization: window.ps_checkoutPayPalButtonConfiguration,
paymentFieldsCustomization: window.ps_checkout.paymentFieldsCustomization,
expressCheckoutButtonCustomization:
window.ps_checkoutExpressCheckoutButtonCustomization,
hostedFieldsCustomization:
window.ps_checkoutHostedFieldsCustomizationConfiguration,
payLaterOfferMessageCustomization:
window.ps_checkoutPayLaterOfferMessageCustomization,
payLaterOfferBannerCustomization:
window.ps_checkoutPayLaterOfferBannerCustomization,
partnerAttributionId: window.ps_checkoutPartnerAttributionId
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ export function mockProductPage() {
export function mockCheckoutVars() {
window.ps_checkoutPayPalOrderId = '';
window.ps_checkoutPayPalClientToken = '';
window.ps_checkoutPayPalSdkConfig = {};
window.ps_checkoutPayPalSdkConfig = {
clientId: 'test',
currency: 'EUR',
intent: 'capture',
integrationDate: '2022-14-06',
components: 'marks,funding-eligibility,buttons'
};
}

0 comments on commit c2e7440

Please sign in to comment.