mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Add final review for blocks
This commit is contained in:
parent
b444c1ef55
commit
211c57b938
4 changed files with 35 additions and 29 deletions
|
@ -92,9 +92,23 @@ const PayPalComponent = ({
|
|||
throw new Error(config.scriptData.labels.error.generic)
|
||||
}
|
||||
|
||||
setPaypalOrder(json.data);
|
||||
const order = json.data;
|
||||
|
||||
onSubmit();
|
||||
setPaypalOrder(order);
|
||||
|
||||
const shippingAddress = paypalOrderToWcShippingAddress(order);
|
||||
let billingAddress = paypalPayerToWc(order.payer);
|
||||
// no billing address, such as if billing address retrieval is not allowed in the merchant account
|
||||
if (!billingAddress.address_line_1) {
|
||||
billingAddress = {...shippingAddress, ...paypalPayerToWc(order.payer)};
|
||||
}
|
||||
|
||||
await wp.data.dispatch('wc/store/cart').updateCustomerData({
|
||||
billing_address: billingAddress,
|
||||
shipping_address: shippingAddress,
|
||||
});
|
||||
|
||||
location.href = config.scriptData.redirect;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
|
@ -126,24 +140,6 @@ const PayPalComponent = ({
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
const shippingAddress = paypalOrderToWcShippingAddress(paypalOrder);
|
||||
let billingAddress = paypalPayerToWc(paypalOrder.payer);
|
||||
// no billing address, such as if billing address retrieval is not allowed in the merchant account
|
||||
if (!billingAddress.address_line_1) {
|
||||
billingAddress = {...shippingAddress, ...paypalPayerToWc(paypalOrder.payer)};
|
||||
}
|
||||
|
||||
return {
|
||||
type: responseTypes.SUCCESS,
|
||||
meta: {
|
||||
paymentMethodData: {
|
||||
'paypal_order_id': paypalOrder.id,
|
||||
},
|
||||
shippingAddress,
|
||||
billingAddress,
|
||||
},
|
||||
};
|
||||
});
|
||||
return () => {
|
||||
unsubscribeProcessing();
|
||||
|
|
|
@ -960,6 +960,7 @@ class SmartButton implements SmartButtonInterface {
|
|||
* @return array
|
||||
*/
|
||||
private function url_params(): array {
|
||||
$context = $this->context();
|
||||
$intent = ( $this->settings->has( 'intent' ) ) ? $this->settings->get( 'intent' ) : 'capture';
|
||||
$product_intent = $this->subscription_helper->current_product_is_subscription() ? 'authorize' : $intent;
|
||||
$other_context_intent = $this->subscription_helper->cart_contains_subscription() ? 'authorize' : $intent;
|
||||
|
@ -970,8 +971,8 @@ class SmartButton implements SmartButtonInterface {
|
|||
'integration-date' => PAYPAL_INTEGRATION_DATE,
|
||||
'components' => implode( ',', $this->components() ),
|
||||
'vault' => $this->can_save_vault_token() ? 'true' : 'false',
|
||||
'commit' => is_checkout() ? 'true' : 'false',
|
||||
'intent' => $this->context() === 'product' ? $product_intent : $other_context_intent,
|
||||
'commit' => in_array( $context, array( 'checkout', 'pay-now' ), true ) ? 'true' : 'false',
|
||||
'intent' => $context === 'product' ? $product_intent : $other_context_intent,
|
||||
);
|
||||
if (
|
||||
$this->environment->current_environment_is( Environment::SANDBOX )
|
||||
|
@ -1012,8 +1013,8 @@ class SmartButton implements SmartButtonInterface {
|
|||
|
||||
$enable_funding = array( 'venmo' );
|
||||
|
||||
if ( $this->settings_status->is_pay_later_button_enabled_for_location( $this->context() ) ||
|
||||
$this->settings_status->is_pay_later_messaging_enabled_for_location( $this->context() )
|
||||
if ( $this->settings_status->is_pay_later_button_enabled_for_location( $context ) ||
|
||||
$this->settings_status->is_pay_later_messaging_enabled_for_location( $context )
|
||||
) {
|
||||
$enable_funding[] = 'paylater';
|
||||
} else {
|
||||
|
|
|
@ -382,7 +382,7 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
$funding_source
|
||||
);
|
||||
|
||||
$action = in_array( $this->parsed_request_data['context'], array( 'checkout', 'express' ), true ) ?
|
||||
$action = in_array( $this->parsed_request_data['context'], array( 'checkout' ), true ) ?
|
||||
ApplicationContext::USER_ACTION_PAY_NOW : ApplicationContext::USER_ACTION_CONTINUE;
|
||||
|
||||
if ( 'card' === $funding_source ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue