mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
make sure a order has captures before trying to refund them
This commit is contained in:
parent
f236ad67ae
commit
14e31e3a0d
1 changed files with 11 additions and 1 deletions
|
@ -68,7 +68,17 @@ class RefundProcessor {
|
|||
return false;
|
||||
}
|
||||
|
||||
$capture = $order->purchase_units()[0]->payments()->captures()[0];
|
||||
$purchase_units = $order->purchase_units();
|
||||
if ( ! $purchase_units ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$captures = $purchase_units[0]->payments()->captures();
|
||||
if ( ! $captures ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$capture = $captures[0];
|
||||
$refund = new Refund(
|
||||
$capture,
|
||||
$capture->invoice_id(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue