Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add installments simulator #19

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions _dev/.babelrc

This file was deleted.

4 changes: 0 additions & 4 deletions _dev/.eslintignore

This file was deleted.

50 changes: 0 additions & 50 deletions _dev/.eslintrc.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
let settings = window.wc.wcSettings.getPaymentMethodData('tpayblik', {});
let label = window.wp.htmlEntities.decodeEntities(settings.title || 'tpayblik') || window.wp.i18n.__('Tpay', 'tpay');
const react = window.React;
import {getSetting} from '@woocommerce/settings';
import {registerPaymentMethod} from '@woocommerce/blocks-registry';
import {useEffect} from '@wordpress/element';
import {decodeEntities} from '@wordpress/html-entities';

const {decodeEntities} = wp.htmlEntities;
const {getSetting} = wc.wcSettings;
const {registerPaymentMethod} = wc.wcBlocksRegistry;
const {useEffect} = wp.element;

let settings = getSetting('tpayblik_data');

function validateBlikZero(code: string): boolean {
let match: RegExpExecArray | null = /[0-9]{6}/.exec(code);

return !!match;
}

const Content = (props: { eventRegistration: any; emitResponse: any; }) => {
const Content = (props) => {
const {eventRegistration, emitResponse} = props;
const {onPaymentSetup} = eventRegistration;

Expand All @@ -34,7 +33,7 @@ const Content = (props: { eventRegistration: any; emitResponse: any; }) => {
return blikError();
}

if (settings.blikZero && blikCode) {
if (settings.blikZero && blikCode !== false) {
if (!validateBlikZero(blikCode)) {
return blikError();
}
Expand All @@ -55,13 +54,27 @@ const Content = (props: { eventRegistration: any; emitResponse: any; }) => {
})
}, [onPaymentSetup]);

return react.createElement('div', {dangerouslySetInnerHTML: {__html: settings.fields}});
return (
<>
<div dangerouslySetInnerHTML={{__html: settings.fields}}></div>
</>
)
};

let Label = () => {
return (
<>
<label>
{decodeEntities(settings.title || 'tpayblik')} <img src={settings.icon} />
</label>
</>
)
};

const TpayBlikOptions = {
name: 'tpayblik',
label: react.createElement('label', null, `${settings.title} `, react.createElement('img', {src: settings.icon})),
content: react.createElement(Content),
label: <Label />,
content: <Content />,
edit: null,
canMakePayment: () => true,
ariaLabel: settings.title ?? ''
Expand Down
21 changes: 0 additions & 21 deletions _dev/js/blocks/checkout-cc.ts

This file was deleted.

38 changes: 38 additions & 0 deletions _dev/js/blocks/checkout-cc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {getSetting} from '@woocommerce/settings';
import {registerPaymentMethod} from '@woocommerce/blocks-registry';

let settings = getSetting('tpaycc_data');

let Label = () => {
return (
<>
<label>
{settings.title} <img src={settings.icon}/>
</label>
</>
);
};

let Content = () => {
return (
<>
<div dangerouslySetInnerHTML={{__html: settings.fields}}></div>
</>
)
};

let Block_Gateway = {
name: 'tpaycc',
label: <Label/>,
content: <Content/>,
edit: null,
canMakePayment: () => true,
ariaLabel: settings.title ?? '',
supports: {
features: settings.supports,
},
};

registerPaymentMethod(Block_Gateway);


18 changes: 0 additions & 18 deletions _dev/js/blocks/checkout-gpay.ts

This file was deleted.

36 changes: 36 additions & 0 deletions _dev/js/blocks/checkout-gpay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {getSetting} from '@woocommerce/settings';
import {registerPaymentMethod} from '@woocommerce/blocks-registry';

let settings = getSetting('tpaygpay_data');

let Label = () => {
return (
<>
<label>
{settings.title} <img src={settings.icon}/>
</label>
</>
);
};

let Content = () => {
return (
<>
<div dangerouslySetInnerHTML={{__html: settings.fields}}></div>
</>
)
};

let Block_Gateway = {
name: 'tpaygpay',
label: <Label />,
content: <Content />,
edit: null,
canMakePayment: () => true,
ariaLabel: settings.title ?? '',
supports: {
features: settings.supports,
},
};

registerPaymentMethod(Block_Gateway);
18 changes: 0 additions & 18 deletions _dev/js/blocks/checkout-installments.ts

This file was deleted.

38 changes: 38 additions & 0 deletions _dev/js/blocks/checkout-installments.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {getSetting} from '@woocommerce/settings';
import {registerPaymentMethod} from '@woocommerce/blocks-registry';

let settings = getSetting('tpayinstallments_data');

let Label = () => {
return (
<>
<label>
{settings.title} <img src={settings.icon}/>
</label>
</>
);
};

let Content = () => {
return (
<>
<div dangerouslySetInnerHTML={{__html: settings.fields}}></div>
</>
)
};

let Block_Gateway = {
name: 'tpayinstallments',
label: <Label/>,
content: <Content/>,
edit: null,
canMakePayment: () => true,
ariaLabel: settings.title ?? '',
supports: {
features: settings.supports,
},
};

registerPaymentMethod(Block_Gateway);


Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
let settings = wc.wcSettings.getPaymentMethodData('pekaoinstallments', {});
const react = window.React;
import {getSetting} from '@woocommerce/settings';
import {registerPaymentMethod} from '@woocommerce/blocks-registry';
import {useEffect} from '@wordpress/element';

const {registerPaymentMethod} = wc.wcBlocksRegistry;
const {useEffect} = wp.element;
let settings = getSetting('pekaoinstallments_data');

const Content = (props: { eventRegistration: any; emitResponse: any; }) => {
const Content = (props) => {
const {eventRegistration, emitResponse} = props;
const {onPaymentSetup} = eventRegistration;
useEffect(() => {
Expand Down Expand Up @@ -34,13 +34,27 @@ const Content = (props: { eventRegistration: any; emitResponse: any; }) => {
emitResponse.responseTypes.SUCCESS,
onPaymentSetup,
]);
return react.createElement('div', {dangerouslySetInnerHTML: {__html: settings.fields}});
return (
<>
<div dangerouslySetInnerHTML={{__html: settings.fields}}></div>
</>
)
};

let Label = () => {
return (
<>
<label>
{settings.title} <img src={settings.icon} />
</label>
</>
)
};

let Block_Gateway = {
name: 'pekaoinstallments',
label: react.createElement('label', null, `${settings.title} `, react.createElement('img', {src: settings.icon})),
content: react.createElement(Content),
label: <Label />,
content: <Content />,
edit: null,
canMakePayment: () => true,
ariaLabel: settings.title ?? '',
Expand Down
Loading
Loading