mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Merge pull request #1832 from woocommerce/PCP-2158-apple-pay-use-checkout-form-data-to-update-shipping-and-billing
ApplePay use checkout form data to update shipping and billing (2158)
This commit is contained in:
commit
aec5e6431c
10 changed files with 421 additions and 212 deletions
|
@ -22,12 +22,14 @@ class BaseHandler {
|
|||
|
||||
transactionInfo() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const endpoint = this.ppcpConfig.ajax.cart_script_params.endpoint;
|
||||
const separator = (endpoint.indexOf('?') !== -1) ? '&' : '?';
|
||||
|
||||
fetch(
|
||||
this.ppcpConfig.ajax.cart_script_params.endpoint,
|
||||
endpoint + separator + 'shipping=1',
|
||||
{
|
||||
method: 'GET',
|
||||
credentials: 'same-origin',
|
||||
credentials: 'same-origin'
|
||||
}
|
||||
)
|
||||
.then(result => result.json())
|
||||
|
@ -43,7 +45,9 @@ class BaseHandler {
|
|||
countryCode: data.country_code,
|
||||
currencyCode: data.currency_code,
|
||||
totalPriceStatus: 'FINAL',
|
||||
totalPrice: data.total_str
|
||||
totalPrice: data.total_str,
|
||||
chosenShippingMethods: data.chosen_shipping_methods || null,
|
||||
shippingPackages: data.shipping_packages || null,
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
import Spinner from "../../../../ppcp-button/resources/js/modules/Helper/Spinner";
|
||||
import CheckoutActionHandler
|
||||
from "../../../../ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler";
|
||||
import ErrorHandler from "../../../../ppcp-button/resources/js/modules/ErrorHandler";
|
||||
import BaseHandler from "./BaseHandler";
|
||||
|
||||
class CheckoutHandler extends BaseHandler {
|
||||
|
||||
createOrder() {
|
||||
const errorHandler = new ErrorHandler(
|
||||
this.ppcpConfig.labels.error.generic,
|
||||
document.querySelector('.woocommerce-notices-wrapper')
|
||||
);
|
||||
|
||||
const spinner = new Spinner();
|
||||
|
||||
const actionHandler = new CheckoutActionHandler(
|
||||
actionHandler() {
|
||||
return new CheckoutActionHandler(
|
||||
this.ppcpConfig,
|
||||
errorHandler,
|
||||
spinner
|
||||
this.errorHandler(),
|
||||
new Spinner()
|
||||
);
|
||||
|
||||
return actionHandler.configuration().createOrder(null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default CheckoutHandler;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue