mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Update renewal order status to failed when renew subscription fails (WIP)
This commit is contained in:
parent
783377cddd
commit
b946386eaf
1 changed files with 23 additions and 6 deletions
|
@ -12,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\Subscription;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PayerFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ShippingPreferenceFactory;
|
||||
|
@ -142,16 +143,32 @@ class RenewalHandler {
|
|||
try {
|
||||
$this->process_order( $wc_order );
|
||||
} catch ( \Exception $error ) {
|
||||
$this->logger->error(
|
||||
sprintf(
|
||||
'An error occurred while trying to renew the subscription for order %1$d: %2$s',
|
||||
$wc_order->get_id(),
|
||||
$error->getMessage()
|
||||
)
|
||||
$error_details = $error->getMessage();
|
||||
if ( is_a( $error, PayPalApiException::class ) ) {
|
||||
$details = '';
|
||||
foreach ( $error->details() as $detail ) {
|
||||
$details .= $detail->issue . ' ' . $detail->description;
|
||||
}
|
||||
if ( $details ) {
|
||||
$error_details = $details;
|
||||
}
|
||||
}
|
||||
|
||||
$error_message = sprintf(
|
||||
'An error occurred while trying to renew the subscription for order %1$d: %2$s',
|
||||
$wc_order->get_id(),
|
||||
$error_details
|
||||
);
|
||||
|
||||
$wc_order->update_status(
|
||||
'failed',
|
||||
$error_details
|
||||
);
|
||||
$this->logger->error( $error_message );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger->info(
|
||||
sprintf(
|
||||
'Renewal for order %d is completed.',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue