mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Merge pull request #1595 from woocommerce/PCP-1906-capture-on-status-change-improvements
Apply Capture On Status Change only when order contains PayPal payment method (1906)
This commit is contained in:
commit
b4f8478920
3 changed files with 20 additions and 1 deletions
|
@ -241,7 +241,7 @@ class RenewalHandler {
|
|||
* @param \WC_Customer $customer The customer.
|
||||
* @param \WC_Order $wc_order The current WooCommerce order we want to process.
|
||||
*
|
||||
* @return PaymentToken|null
|
||||
* @return PaymentToken|null|false
|
||||
*/
|
||||
private function get_token_for_customer( \WC_Customer $customer, \WC_Order $wc_order ) {
|
||||
/**
|
||||
|
|
|
@ -44,4 +44,14 @@ class GatewayRepository {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if a given gateway ID is registered.
|
||||
*
|
||||
* @param string $gateway_id The gateway ID.
|
||||
* @return bool
|
||||
*/
|
||||
public function exists( string $gateway_id ): bool {
|
||||
return in_array( $gateway_id, $this->ppcp_gateway_ids, true );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Checkout\DisableGateways;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\ReturnUrlEndpoint;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\GatewayRepository;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCProductStatus;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\PayUponInvoiceProductStatus;
|
||||
|
@ -356,6 +357,14 @@ class WCGatewayModule implements ModuleInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
$gateway_repository = $c->get( 'wcgateway.gateway-repository' );
|
||||
assert( $gateway_repository instanceof GatewayRepository );
|
||||
|
||||
// Only allow to proceed if the payment method is one of our Gateways.
|
||||
if ( ! $gateway_repository->exists( $wc_order->get_payment_method() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$intent = strtoupper( (string) $wc_order->get_meta( PayPalGateway::INTENT_META_KEY ) );
|
||||
$captured = wc_string_to_bool( $wc_order->get_meta( AuthorizedPaymentsProcessor::CAPTURED_META_KEY ) );
|
||||
if ( $intent !== 'AUTHORIZE' || $captured ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue