mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add sca indicators and card update to card subscription renewals
This commit is contained in:
parent
36e3d261f6
commit
9948b648e0
5 changed files with 62 additions and 56 deletions
|
@ -158,8 +158,14 @@ class CaptureCardPayment implements EndpointInterface {
|
|||
$id = $order->id ?? '';
|
||||
$status = $order->status ?? '';
|
||||
$payment_source = isset( $order->payment_source->card ) ? 'card' : '';
|
||||
if ( $id && $status && $payment_source ) {
|
||||
$this->real_time_account_updater_helper->update_wc_token_from_paypal_response( $order, $token );
|
||||
$expiry = $order->payment_source->card->expiry ?? '';
|
||||
$last_digits = $order->payment_source->card->last_digits ?? '';
|
||||
if ( $id && $status && $payment_source && $expiry && $last_digits ) {
|
||||
$this->real_time_account_updater_helper->update_wc_card_token(
|
||||
$expiry,
|
||||
$last_digits,
|
||||
$token
|
||||
);
|
||||
|
||||
WC()->session->set(
|
||||
'ppcp_saved_payment_card',
|
||||
|
|
|
@ -18,13 +18,12 @@ use WC_Payment_Token;
|
|||
class RealTimeAccountUpdaterHelper {
|
||||
|
||||
/**
|
||||
* Updates WC Payment Token from PayPal response.
|
||||
*
|
||||
* @param stdClass $order PayPal order response data.
|
||||
* @param string $expiry Card expìry.
|
||||
* @param string $last_digits Card last 4 digits.
|
||||
* @param WC_Payment_Token $token WC Payment Token.
|
||||
* @return void
|
||||
*/
|
||||
public function update_wc_token_from_paypal_response( stdClass $order, WC_Payment_Token $token ): void {
|
||||
public function update_wc_card_token( string $expiry, string $last_digits, WC_Payment_Token $token ): void {
|
||||
if (
|
||||
$token->get_type() !== 'CC'
|
||||
|| ! in_array( $token->get_card_type(), array( 'VISA', 'MASTERCARD' ), true )
|
||||
|
@ -32,9 +31,7 @@ class RealTimeAccountUpdaterHelper {
|
|||
return;
|
||||
}
|
||||
|
||||
$expiry = $order->payment_source->card->expiry ?? '';
|
||||
$wc_expiry = $token->get_expiry_month() . '-' . $token->get_expiry_year();
|
||||
|
||||
if ( $expiry !== $wc_expiry ) {
|
||||
$expiry_split = explode( '-', $expiry );
|
||||
$token->set_expiry_year( $expiry_split[0] );
|
||||
|
@ -42,7 +39,6 @@ class RealTimeAccountUpdaterHelper {
|
|||
$token->save();
|
||||
}
|
||||
|
||||
$last_digits = $order->payment_source->card->last_digits ?? '';
|
||||
$wc_last_digits = $token->get_last4();
|
||||
if ( $last_digits !== $wc_last_digits ) {
|
||||
$token->set_last4( $last_digits );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue