2024-07-12 12:58:34 +02:00
|
|
|
import Spinner from '../../../../ppcp-button/resources/js/modules/Helper/Spinner';
|
|
|
|
import BaseHandler from './BaseHandler';
|
|
|
|
import CheckoutActionHandler from '../../../../ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler';
|
2024-08-13 18:41:42 +02:00
|
|
|
import TransactionInfo from '../Helper/TransactionInfo';
|
2023-10-13 17:57:03 +01:00
|
|
|
|
|
|
|
class PayNowHandler extends BaseHandler {
|
2024-07-12 12:58:34 +02:00
|
|
|
validateContext() {
|
|
|
|
if ( this.ppcpConfig?.locations_with_subscription_product?.payorder ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2023-10-13 17:57:03 +01:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
transactionInfo() {
|
|
|
|
return new Promise( async ( resolve, reject ) => {
|
|
|
|
const data = this.ppcpConfig.pay_now;
|
2023-11-13 17:36:18 +00:00
|
|
|
|
2024-08-13 18:53:39 +02:00
|
|
|
const transaction = new TransactionInfo(
|
|
|
|
data.total,
|
2024-08-13 19:31:51 +02:00
|
|
|
data.shipping_fee,
|
2024-08-13 18:53:39 +02:00
|
|
|
data.currency_code,
|
2024-08-13 20:23:51 +02:00
|
|
|
data.country_code
|
2024-08-13 18:41:42 +02:00
|
|
|
);
|
2024-08-13 18:53:39 +02:00
|
|
|
|
|
|
|
resolve( transaction );
|
2024-07-12 12:58:34 +02:00
|
|
|
} );
|
|
|
|
}
|
2023-10-13 17:57:03 +01:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
actionHandler() {
|
|
|
|
return new CheckoutActionHandler(
|
|
|
|
this.ppcpConfig,
|
|
|
|
this.errorHandler(),
|
|
|
|
new Spinner()
|
|
|
|
);
|
|
|
|
}
|
2023-10-13 17:57:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default PayNowHandler;
|