mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Save funding source for block orders
This commit is contained in:
parent
8f3e9c4554
commit
98f6d0de45
3 changed files with 20 additions and 9 deletions
|
@ -5,6 +5,8 @@ import {loadPaypalScript} from '../../../ppcp-button/resources/js/modules/Helper
|
|||
|
||||
const config = wc.wcSettings.getSetting('ppcp-gateway_data');
|
||||
|
||||
window.ppcpFundingSource = config.fundingSource;
|
||||
|
||||
const PayPalComponent = ({
|
||||
onClick,
|
||||
onClose,
|
||||
|
@ -39,7 +41,6 @@ const PayPalComponent = ({
|
|||
context: 'express',
|
||||
order_id: config.scriptData.order_id,
|
||||
payment_method: 'ppcp-gateway',
|
||||
funding_source: 'paypal',
|
||||
createaccount: false
|
||||
}),
|
||||
});
|
||||
|
@ -75,7 +76,7 @@ const PayPalComponent = ({
|
|||
body: JSON.stringify({
|
||||
nonce: config.scriptData.ajax.approve_order.nonce,
|
||||
order_id: data.orderID,
|
||||
//funding_source: ,
|
||||
funding_source: window.ppcpFundingSource ?? 'paypal',
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -125,7 +126,9 @@ const PayPalComponent = ({
|
|||
}
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
const handleClick = (data, actions) => {
|
||||
window.ppcpFundingSource = data.fundingSource;
|
||||
|
||||
onClick();
|
||||
};
|
||||
|
||||
|
@ -141,6 +144,7 @@ const PayPalComponent = ({
|
|||
meta: {
|
||||
paymentMethodData: {
|
||||
'paypal_order_id': config.scriptData.continuation.order_id,
|
||||
'funding_source': window.ppcpFundingSource ?? 'paypal',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -158,11 +158,12 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
}
|
||||
|
||||
return array(
|
||||
'id' => $this->gateway->id,
|
||||
'title' => $this->gateway->title,
|
||||
'description' => $this->gateway->description,
|
||||
'enabled' => $this->settings_status->is_smart_button_enabled_for_location( $script_data['context'] ),
|
||||
'scriptData' => $script_data,
|
||||
'id' => $this->gateway->id,
|
||||
'title' => $this->gateway->title,
|
||||
'description' => $this->gateway->description,
|
||||
'enabled' => $this->settings_status->is_smart_button_enabled_for_location( $script_data['context'] ),
|
||||
'fundingSource' => $this->session_handler->funding_source(),
|
||||
'scriptData' => $script_data,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -424,7 +424,13 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||
$funding_source = wc_clean( wp_unslash( $_POST['ppcp-funding-source'] ?? '' ) );
|
||||
$funding_source = wc_clean( wp_unslash( $_POST['ppcp-funding-source'] ?? ( $_POST['funding_source'] ?? '' ) ) );
|
||||
|
||||
if ( $funding_source ) {
|
||||
$wc_order->set_payment_method_title( $this->funding_source_renderer->render_name( $funding_source ) );
|
||||
$wc_order->save();
|
||||
}
|
||||
|
||||
if ( 'card' !== $funding_source && $this->is_free_trial_order( $wc_order ) ) {
|
||||
$user_id = (int) $wc_order->get_customer_id();
|
||||
$tokens = $this->payment_token_repository->all_for_user_id( $user_id );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue