mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Ensure correct transaction url by saving payment mode meta
This commit is contained in:
parent
78ef57145c
commit
6aedb51707
2 changed files with 29 additions and 13 deletions
|
@ -127,9 +127,10 @@ return array(
|
||||||
$state,
|
$state,
|
||||||
$transaction_url_provider,
|
$transaction_url_provider,
|
||||||
$subscription_helper,
|
$subscription_helper,
|
||||||
$logger,
|
|
||||||
$payments_endpoint,
|
$payments_endpoint,
|
||||||
$vaulted_credit_card_handler
|
$vaulted_credit_card_handler,
|
||||||
|
$container->get( 'onboarding.environment' ),
|
||||||
|
$logger
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'wcgateway.card-button-gateway' => static function ( ContainerInterface $container ): CardButtonGateway {
|
'wcgateway.card-button-gateway' => static function ( ContainerInterface $container ): CardButtonGateway {
|
||||||
|
|
|
@ -16,6 +16,7 @@ use WC_Payment_Tokens;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||||
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
|
||||||
|
@ -114,13 +115,6 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
*/
|
*/
|
||||||
protected $subscription_helper;
|
protected $subscription_helper;
|
||||||
|
|
||||||
/**
|
|
||||||
* The logger.
|
|
||||||
*
|
|
||||||
* @var LoggerInterface
|
|
||||||
*/
|
|
||||||
protected $logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The payments endpoint
|
* The payments endpoint
|
||||||
*
|
*
|
||||||
|
@ -128,6 +122,20 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
*/
|
*/
|
||||||
protected $payments_endpoint;
|
protected $payments_endpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The environment.
|
||||||
|
*
|
||||||
|
* @var Environment
|
||||||
|
*/
|
||||||
|
private $environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The logger.
|
||||||
|
*
|
||||||
|
* @var LoggerInterface
|
||||||
|
*/
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreditCardGateway constructor.
|
* CreditCardGateway constructor.
|
||||||
*
|
*
|
||||||
|
@ -140,9 +148,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
* @param State $state The state.
|
* @param State $state The state.
|
||||||
* @param TransactionUrlProvider $transaction_url_provider Service able to provide view transaction url base.
|
* @param TransactionUrlProvider $transaction_url_provider Service able to provide view transaction url base.
|
||||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||||
* @param LoggerInterface $logger The logger.
|
|
||||||
* @param PaymentsEndpoint $payments_endpoint The payments endpoint.
|
* @param PaymentsEndpoint $payments_endpoint The payments endpoint.
|
||||||
* @param VaultedCreditCardHandler $vaulted_credit_card_handler The vaulted credit card handler.
|
* @param VaultedCreditCardHandler $vaulted_credit_card_handler The vaulted credit card handler.
|
||||||
|
* @param Environment $environment The environment.
|
||||||
|
* @param LoggerInterface $logger The logger.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SettingsRenderer $settings_renderer,
|
SettingsRenderer $settings_renderer,
|
||||||
|
@ -154,9 +163,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
State $state,
|
State $state,
|
||||||
TransactionUrlProvider $transaction_url_provider,
|
TransactionUrlProvider $transaction_url_provider,
|
||||||
SubscriptionHelper $subscription_helper,
|
SubscriptionHelper $subscription_helper,
|
||||||
LoggerInterface $logger,
|
|
||||||
PaymentsEndpoint $payments_endpoint,
|
PaymentsEndpoint $payments_endpoint,
|
||||||
VaultedCreditCardHandler $vaulted_credit_card_handler
|
VaultedCreditCardHandler $vaulted_credit_card_handler,
|
||||||
|
Environment $environment,
|
||||||
|
LoggerInterface $logger
|
||||||
) {
|
) {
|
||||||
$this->id = self::ID;
|
$this->id = self::ID;
|
||||||
$this->settings_renderer = $settings_renderer;
|
$this->settings_renderer = $settings_renderer;
|
||||||
|
@ -168,9 +178,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
$this->state = $state;
|
$this->state = $state;
|
||||||
$this->transaction_url_provider = $transaction_url_provider;
|
$this->transaction_url_provider = $transaction_url_provider;
|
||||||
$this->subscription_helper = $subscription_helper;
|
$this->subscription_helper = $subscription_helper;
|
||||||
$this->logger = $logger;
|
|
||||||
$this->payments_endpoint = $payments_endpoint;
|
$this->payments_endpoint = $payments_endpoint;
|
||||||
$this->vaulted_credit_card_handler = $vaulted_credit_card_handler;
|
$this->vaulted_credit_card_handler = $vaulted_credit_card_handler;
|
||||||
|
$this->environment = $environment;
|
||||||
|
$this->logger = $logger;
|
||||||
|
|
||||||
if ( $state->current_state() === State::STATE_ONBOARDED ) {
|
if ( $state->current_state() === State::STATE_ONBOARDED ) {
|
||||||
$this->supports = array( 'refunds' );
|
$this->supports = array( 'refunds' );
|
||||||
|
@ -370,6 +381,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
if ( $saved_payment_card ) {
|
if ( $saved_payment_card ) {
|
||||||
if ( $saved_payment_card['payment_source'] === 'card' && $saved_payment_card['status'] === 'COMPLETED' ) {
|
if ( $saved_payment_card['payment_source'] === 'card' && $saved_payment_card['status'] === 'COMPLETED' ) {
|
||||||
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $saved_payment_card['order_id'] );
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $saved_payment_card['order_id'] );
|
||||||
|
$wc_order->update_meta_data(
|
||||||
|
PayPalGateway::ORDER_PAYMENT_MODE_META_KEY,
|
||||||
|
$this->environment->current_environment_is( Environment::SANDBOX ) ? 'sandbox' : 'live'
|
||||||
|
);
|
||||||
$wc_order->save_meta_data();
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
$this->update_transaction_id( $saved_payment_card['order_id'], $wc_order );
|
$this->update_transaction_id( $saved_payment_card['order_id'], $wc_order );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue