mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Merge pull request #1958 from woocommerce/PCP-2522-venmo-vaulting-integration
Venmo Vaulting integration (2522)
This commit is contained in:
commit
2bd7d2bf0d
3 changed files with 64 additions and 8 deletions
|
@ -1256,6 +1256,16 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
|
|||
'commit' => in_array( $context, $this->pay_now_contexts, true ) ? 'true' : 'false',
|
||||
'intent' => $intent,
|
||||
);
|
||||
|
||||
if (
|
||||
$this->settings->has( 'subscriptions_mode' )
|
||||
&& $this->settings->get( 'subscriptions_mode' ) === 'vaulting_api'
|
||||
&& apply_filters( 'woocommerce_paypal_payments_save_payment_methods_eligible', false )
|
||||
) {
|
||||
// Remove vault parameter to allow for Venmo with Save Payment Methods (Vault V3).
|
||||
unset( $params['vault'] );
|
||||
}
|
||||
|
||||
if (
|
||||
$this->environment->current_environment_is( Environment::SANDBOX )
|
||||
&& defined( 'WP_DEBUG' ) && \WP_DEBUG
|
||||
|
|
|
@ -106,16 +106,30 @@ class SavePaymentMethodsModule implements ModuleInterface {
|
|||
}
|
||||
|
||||
if ( $payment_method === PayPalGateway::ID ) {
|
||||
$data['payment_source'] = array(
|
||||
'paypal' => array(
|
||||
'attributes' => array(
|
||||
'vault' => array(
|
||||
'store_in_vault' => 'ON_SUCCESS',
|
||||
'usage_type' => 'MERCHANT',
|
||||
|
||||
if ( $request_data['funding_source'] === 'venmo' ) {
|
||||
$data['payment_source'] = array(
|
||||
'venmo' => array(
|
||||
'attributes' => array(
|
||||
'vault' => array(
|
||||
'store_in_vault' => 'ON_SUCCESS',
|
||||
'usage_type' => 'MERCHANT',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
} else {
|
||||
$data['payment_source'] = array(
|
||||
'paypal' => array(
|
||||
'attributes' => array(
|
||||
'vault' => array(
|
||||
'store_in_vault' => 'ON_SUCCESS',
|
||||
'usage_type' => 'MERCHANT',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -329,6 +343,13 @@ class SavePaymentMethodsModule implements ModuleInterface {
|
|||
$endpoint->handle_request();
|
||||
}
|
||||
);
|
||||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_save_payment_methods_eligible',
|
||||
function() {
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -181,6 +181,31 @@ class WcSubscriptionsModule implements ModuleInterface {
|
|||
}
|
||||
);
|
||||
|
||||
add_filter(
|
||||
'woocommerce_subscription_payment_method_to_display',
|
||||
/**
|
||||
* Corrects the payment method name for subscriptions.
|
||||
*
|
||||
* @param string $payment_method_to_display The payment method string.
|
||||
* @param \WC_Subscription $subscription The subscription instance.
|
||||
* @param string $context The context, ex: view.
|
||||
* @return string
|
||||
*
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
function ( $payment_method_to_display, $subscription, $context ) {
|
||||
$payment_gateway = wc_get_payment_gateway_by_order( $subscription );
|
||||
|
||||
if ( $payment_gateway instanceof \WC_Payment_Gateway && $payment_gateway->id === PayPalGateway::ID ) {
|
||||
return $subscription->get_payment_method_title( $context );
|
||||
}
|
||||
|
||||
return $payment_method_to_display;
|
||||
},
|
||||
10,
|
||||
3
|
||||
);
|
||||
|
||||
add_action(
|
||||
'wc_ajax_' . SubscriptionChangePaymentMethod::ENDPOINT,
|
||||
static function () use ( $c ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue