Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 hours ago.
Improve this questionI am creating custom payment plugin for woocommerce. I am facing issue while getting the checkout form data in process_payment
function of woocommerce payment class.
I am using following JS code to make payment gateway compatible with woocommerce Block checkout.
const PaySettings= window.wc.wcSettings.allSettings.paymentMethodData.pay;
const Paylabel = window.wp.htmlEntities.decodeEntities( PaySettings.title );
const PayMethod = ({ id, label,value }) => {
return React.createElement('div', {className: 'pay-methods'},
React.createElement('label', {htmlFor: id}, label),
React.createElement('input', {type: 'radio', name: id, value: value, onChange: (e) => e.target.value}),
);
};
const Content = () => {
return React.createElement('div', {className: 'pay-methods-cont'}, null,
React.createElement('img', {src: PaySettings.icon}),
React.createElement('p', null, window.wp.htmlEntities.decodeEntities(PaySettings.description || '')),
React.createElement(PayMethod, {id: 'pay_method', label: 'JazzCash',value: 'jazzcash' }),
React.createElement(PayMethod, {id: 'pay_method', label: 'EasyPaisa',value: 'easypaisa' })
);
}
const Icon = () => {
return React.createElement('div', {className: 'custom-input-field'},
React.createElement('img', {src: PaySettings.icon}))
}
const AP_Gateway = {
name: 'pay',
label: Paylabel,
icon: Icon,
content: Object(window.wp.element.createElement)(Content, null),
edit: Object(window.wp.element.createElement)(Content, null),
canMakePayment: () => true,
ariaLabel: Paylabel,
supports: {
features: ['products'],//settings.supports,
},
};
window.wc.wcBlocksRegistry.registerPaymentMethod( AP_Gateway )
public function process_payment( $order_id ) {
echo "<pre>";print_r($_POST);echo "</pre>";die;
}