mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Throw exception when capture payment returns false
This commit is contained in:
parent
54f84aac26
commit
0291f34309
1 changed files with 6 additions and 4 deletions
|
@ -116,8 +116,8 @@ class PaymentTokenChecker {
|
|||
if ( $tokens ) {
|
||||
try {
|
||||
$this->capture_authorized_payment( $wc_order );
|
||||
} catch ( NotFoundException $exception ) {
|
||||
$this->logger->warning( "It was not possible to capture the payment for order: #{$order_id}" );
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->error( $exception->getMessage() );
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -139,11 +139,13 @@ class PaymentTokenChecker {
|
|||
* Captures authorized payments for the given WC order.
|
||||
*
|
||||
* @param WC_Order $wc_order The WC order.
|
||||
* @throws NotFoundException When there is a problem capturing the payment.
|
||||
* @throws Exception When there is a problem capturing the payment.
|
||||
*/
|
||||
private function capture_authorized_payment( WC_Order $wc_order ): void {
|
||||
if ( $this->settings->has( 'intent' ) && strtoupper( (string) $this->settings->get( 'intent' ) ) === 'CAPTURE' ) {
|
||||
$this->authorized_payments_processor->capture_authorized_payment( $wc_order );
|
||||
if ( ! $this->authorized_payments_processor->capture_authorized_payment( $wc_order ) ) {
|
||||
throw new Exception( "Could not capture payment for order: #{$wc_order->get_id()}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue