Skip to content

Commit

Permalink
fix(Stripe): improve handling of invoice error (#2117)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelpeixe authored Nov 7, 2022
1 parent 6b3919e commit 609bf7d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion includes/reader-revenue/class-stripe-connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ private static function get_customer_by_email( $email_address ) {
* @param string $invoice_id Invoice ID.
*/
public static function get_invoice( $invoice_id ) {
if ( empty( $invoice_id ) ) {
return new \WP_Error( 'stripe_newspack', __( 'Invoice ID is missing.', 'newspack' ) );
}
if ( isset( self::$cache['invoices'][ $invoice_id ] ) ) {
return self::$cache['invoices'][ $invoice_id ];
}
Expand Down Expand Up @@ -1375,7 +1378,7 @@ public static function create_wc_transaction_payload( $customer, $payment ) {
$subscription_id = $invoice['subscription'];
}
} elseif ( \is_wp_error( $invoice ) ) {
Logger::error( 'Invoice error: ' . $invoice->get_error_message() );
Logger::log( 'Invoice error: ' . $invoice->get_error_message() );
}
return [
'email' => $customer['email'],
Expand Down

0 comments on commit 609bf7d

Please sign in to comment.