Skip to content

Commit

Permalink
Merge pull request #294 from buckaroo-it/develop
Browse files Browse the repository at this point in the history
BP-3634-Update-test-release-3.14.0
  • Loading branch information
vegimcarkaxhija authored Oct 29, 2024
2 parents 3ba976c + dc3c113 commit 6ee68f0
Show file tree
Hide file tree
Showing 100 changed files with 11,669 additions and 7,256 deletions.
9 changes: 4 additions & 5 deletions Buckaroo_Load_Gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class Buckaroo_Load_Gateways {
'filename' => 'gateway-buckaroo-transfer.php',
'classname' => 'WC_Gateway_Buckaroo_Transfer',
),
'Blik' => array(
'filename' => 'gateway-buckaroo-blik.php',
'classname' => 'WC_Gateway_Buckaroo_Blik',
),
'Belfius' => array(
'filename' => 'gateway-buckaroo-belfius.php',
'classname' => 'WC_Gateway_Buckaroo_Belfius',
Expand All @@ -60,11 +64,6 @@ class Buckaroo_Load_Gateways {
'gateway-buckaroo-giftcard.php',
'classname' => 'WC_Gateway_Buckaroo_Giftcard',
),
'Giropay' => array(
'filename' =>
'gateway-buckaroo-giropay.php',
'classname' => 'WC_Gateway_Buckaroo_Giropay',
),
'iDeal' => array(
'filename' =>
'gateway-buckaroo-ideal.php',
Expand Down
4 changes: 2 additions & 2 deletions assets/js/blocks/gateways/buckaroo_afterpay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useFormData from '../hooks/useFormData';
import CoCField from '../partials/buckaroo_coc_field';

function AfterPayView({
onStateChange, methodName, gateway: { type, b2b }, billing,
onStateChange, methodName, title, gateway: { type, b2b }, billing,
}) {
const initialState = {
[`${methodName}-phone`]: billing?.phone || '',
Expand Down Expand Up @@ -74,7 +74,7 @@ function AfterPayView({
billingData={billing}
b2b={b2b}
/>
<FinancialWarning paymentMethod={methodName} />
<FinancialWarning title={title} />
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions assets/js/blocks/gateways/buckaroo_afterpaynew.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useFormData from '../hooks/useFormData';
import CoCField from '../partials/buckaroo_coc_field';

function AfterPayNew({
onStateChange, methodName, gateway: { customer_type, b2b }, billing,
onStateChange, methodName, title, gateway: { customer_type, b2b }, billing,
}) {
const initialState = {
[`${methodName}-phone`]: billing?.phone || '',
Expand Down Expand Up @@ -76,7 +76,7 @@ function AfterPayNew({
b2b={b2b}
/>

<FinancialWarning paymentMethod={methodName} />
<FinancialWarning title={title} />
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions assets/js/blocks/gateways/buckaroo_billink.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useFormData from '../hooks/useFormData';
import CoCField from '../partials/buckaroo_coc_field';

function Billink({
onStateChange, methodName, gateway: { genders, b2b }, billing,
onStateChange, methodName, title, gateway: { genders, b2b }, billing,
}) {
const initialState = {
[`${methodName}-company-coc-registration`]: '',
Expand Down Expand Up @@ -65,7 +65,7 @@ function Billink({
billingData={billing}
b2b={b2b}
/>
<FinancialWarning paymentMethod={methodName} />
<FinancialWarning title={title} />
</div>
);
}
Expand Down
289 changes: 144 additions & 145 deletions assets/js/blocks/gateways/buckaroo_creditcard.js
Original file line number Diff line number Diff line change
@@ -1,165 +1,164 @@
import React, { useEffect } from 'react';
import { __ } from '@wordpress/i18n';
import React, {useEffect} from 'react';
import {__} from '@wordpress/i18n';
import DefaultDropdown from '../partials/buckaroo_creditcard_dropdown';
import encryptCardData from '../services/BuckarooClientSideEncryption';
import useFormData from '../hooks/useFormData';

function CreditCard({
onStateChange,
methodName,
gateway: {
paymentMethodId, creditCardIssuers, creditCardMethod, creditCardIsSecure,
},
}) {
const initialState = {
[`${paymentMethodId}-creditcard-issuer`]: '',
[`${paymentMethodId}-cardname`]: '',
[`${paymentMethodId}-cardnumber`]: '',
[`${paymentMethodId}-cardmonth`]: '',
[`${paymentMethodId}-cardyear`]: '',
[`${paymentMethodId}-cardcvc`]: '',
[`${paymentMethodId}-encrypted-data`]: '',
};
onStateChange,
methodName,
gateway: {paymentMethodId, creditCardIssuers, creditCardMethod, creditCardIsSecure,}
}) {

const { formState, handleChange, updateFormState } = useFormData(initialState, onStateChange);
const initialState = {
[`${paymentMethodId}-creditcard-issuer`]: '',
[`${paymentMethodId}-cardname`]: '',
[`${paymentMethodId}-cardnumber`]: '',
[`${paymentMethodId}-cardmonth`]: '',
[`${paymentMethodId}-cardyear`]: '',
[`${paymentMethodId}-cardcvc`]: '',
[`${paymentMethodId}-encrypted-data`]: '',
};

const handleEncryption = async () => {
try {
const cardData = {
cardName: formState[`${paymentMethodId}-cardname`],
cardNumber: formState[`${paymentMethodId}-cardnumber`],
cardMonth: formState[`${paymentMethodId}-cardmonth`],
cardYear: formState[`${paymentMethodId}-cardyear`],
cardCVC: formState[`${paymentMethodId}-cardcvc`],
};
const encryptedData = await encryptCardData(cardData);
const {formState, handleChange, updateFormState} = useFormData(initialState, onStateChange);

updateFormState(`${paymentMethodId}-encrypted-data`, encryptedData);
} catch (error) {
console.error('Encryption error:', error);
}
};
const handleEncryption = async () => {
try {
const cardData = {
cardName: formState[`${paymentMethodId}-cardname`],
cardNumber: formState[`${paymentMethodId}-cardnumber`],
cardMonth: formState[`${paymentMethodId}-cardmonth`],
cardYear: formState[`${paymentMethodId}-cardyear`],
cardCVC: formState[`${paymentMethodId}-cardcvc`],
};
const encryptedData = await encryptCardData(cardData);

useEffect(() => {
if (creditCardMethod === 'encrypt' && creditCardIsSecure === true) {
handleEncryption();
}
}, [
formState[`${paymentMethodId}-cardname`],
formState[`${paymentMethodId}-cardnumber`],
formState[`${paymentMethodId}-cardmonth`],
formState[`${paymentMethodId}-cardyear`],
formState[`${paymentMethodId}-cardcvc`],
creditCardMethod,
creditCardIsSecure,
]);
updateFormState(`${paymentMethodId}-encrypted-data`, encryptedData);
} catch (error) {
console.error('Encryption error:', error);
}
};

return (
<div>
<p className="form-row form-row-wide">
<DefaultDropdown
paymentMethodId={paymentMethodId}
creditCardIssuers={creditCardIssuers}
handleChange={handleChange}
/>
</p>
useEffect(() => {
if (creditCardMethod === 'encrypt' && creditCardIsSecure === true) {
handleEncryption();
}
}, [
formState[`${paymentMethodId}-cardname`],
formState[`${paymentMethodId}-cardnumber`],
formState[`${paymentMethodId}-cardmonth`],
formState[`${paymentMethodId}-cardyear`],
formState[`${paymentMethodId}-cardcvc`],
creditCardMethod,
creditCardIsSecure,
]);

{creditCardMethod === 'encrypt' && creditCardIsSecure === true && (
<div className="method--bankdata">
<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardname`}>
{__('Cardholder Name:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="text"
name={`${paymentMethodId}-cardname`}
id={`${paymentMethodId}-cardname`}
placeholder={__('Cardholder Name:', 'wc-buckaroo-bpe-gateway')}
className="cardHolderName input-text"
maxLength="250"
autoComplete="off"
onChange={handleChange}
/>
</div>
return (
<div>
<p className="form-row form-row-wide">
<DefaultDropdown
paymentMethodId={paymentMethodId}
creditCardIssuers={creditCardIssuers}
handleChange={handleChange}
/>
</p>

<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardnumber`}>
{__('Card Number:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="text"
name={`${paymentMethodId}-cardnumber`}
id={`${paymentMethodId}-cardnumber`}
placeholder={__('Card Number:', 'wc-buckaroo-bpe-gateway')}
className="cardNumber input-text"
maxLength="250"
autoComplete="off"
onChange={handleChange}
/>
</div>
{creditCardMethod === 'encrypt' && creditCardIsSecure === true && (
<div className="method--bankdata">
<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardname`}>
{__('Cardholder Name:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="text"
name={`${paymentMethodId}-cardname`}
id={`${paymentMethodId}-cardname`}
placeholder={__('Cardholder Name:', 'wc-buckaroo-bpe-gateway')}
className="cardHolderName input-text"
maxLength="250"
autoComplete="off"
onChange={handleChange}
/>
</div>

<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardmonth`}>
{__('Expiration Month:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="text"
maxLength="2"
name={`${paymentMethodId}-cardmonth`}
id={`${paymentMethodId}-cardmonth`}
placeholder={__('Expiration Month:', 'wc-buckaroo-bpe-gateway')}
className="expirationMonth input-text"
autoComplete="off"
onChange={handleChange}
/>
</div>
<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardnumber`}>
{__('Card Number:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="text"
name={`${paymentMethodId}-cardnumber`}
id={`${paymentMethodId}-cardnumber`}
placeholder={__('Card Number:', 'wc-buckaroo-bpe-gateway')}
className="cardNumber input-text"
maxLength="250"
autoComplete="off"
onChange={handleChange}
/>
</div>

<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardyear`}>
{__('Expiration Year:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="text"
maxLength="4"
name={`${paymentMethodId}-cardyear`}
id={`${paymentMethodId}-cardyear`}
placeholder={__('Expiration Year:', 'wc-buckaroo-bpe-gateway')}
className="expirationYear input-text"
autoComplete="off"
onChange={handleChange}
/>
</div>
<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardmonth`}>
{__('Expiration Month:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="text"
maxLength="2"
name={`${paymentMethodId}-cardmonth`}
id={`${paymentMethodId}-cardmonth`}
placeholder={__('Expiration Month:', 'wc-buckaroo-bpe-gateway')}
className="expirationMonth input-text"
autoComplete="off"
onChange={handleChange}
/>
</div>

<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardcvc`}>
{__('CVC:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="password"
maxLength="4"
name={`${paymentMethodId}-cardcvc`}
id={`${paymentMethodId}-cardcvc`}
placeholder={__('CVC:', 'wc-buckaroo-bpe-gateway')}
className="cvc input-text"
autoComplete="off"
onChange={handleChange}
/>
</div>
<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardyear`}>
{__('Expiration Year:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="text"
maxLength="4"
name={`${paymentMethodId}-cardyear`}
id={`${paymentMethodId}-cardyear`}
placeholder={__('Expiration Year:', 'wc-buckaroo-bpe-gateway')}
className="expirationYear input-text"
autoComplete="off"
onChange={handleChange}
/>
</div>

<div className="form-row">
<label className="buckaroo-label" htmlFor={`${paymentMethodId}-cardcvc`}>
{__('CVC:', 'wc-buckaroo-bpe-gateway')}
<span className="required">*</span>
</label>
<input
type="password"
maxLength="4"
name={`${paymentMethodId}-cardcvc`}
id={`${paymentMethodId}-cardcvc`}
placeholder={__('CVC:', 'wc-buckaroo-bpe-gateway')}
className="cvc input-text"
autoComplete="off"
onChange={handleChange}
/>
</div>

<div className="form-row form-row-wide validate-required" />
<div className="required" style={{ float: 'right' }}>
*
{__('Required', 'wc-buckaroo-bpe-gateway')}
<div className="form-row form-row-wide validate-required"/>
<div className="required" style={{float: 'right'}}>
*
{__('Required', 'wc-buckaroo-bpe-gateway')}
</div>
</div>
)}
</div>
</div>
)}
</div>
);
);
}

export default CreditCard;
Loading

0 comments on commit 6ee68f0

Please sign in to comment.