Commit 69a58128 authored by Michael Iseard's avatar Michael Iseard
Browse files

Wrap createSubscription in try/catch statement

parent a5783635
...@@ -380,8 +380,8 @@ class MollieVendor implements VendorInterface { ...@@ -380,8 +380,8 @@ class MollieVendor implements VendorInterface {
// Create subscription if valid mandate found // Create subscription if valid mandate found
if ( $valid_mandate ) { if ( $valid_mandate ) {
$subscription = $customer->createSubscription( $subscription_array ); try {
if ( $subscription ) { $subscription = $customer->createSubscription( $subscription_array );
$kudos_subscription = new SubscriptionEntity( $kudos_subscription = new SubscriptionEntity(
[ [
'transaction_id' => $transaction->transaction_id, 'transaction_id' => $transaction->transaction_id,
...@@ -397,11 +397,16 @@ class MollieVendor implements VendorInterface { ...@@ -397,11 +397,16 @@ class MollieVendor implements VendorInterface {
$this->mapper->save( $kudos_subscription ); $this->mapper->save( $kudos_subscription );
return $subscription; return $subscription;
} catch ( ApiException $e ) {
$this->logger->error( $e->getMessage(), [
'transaction' => $transaction,
'mandate_id' => $mandate_id,
'interval' => $interval,
'years' => $years,
] );
return false;
} }
$this->logger->error( 'Failed to create subscription', [ $transaction ] );
return false;
} }
// No valid mandates // No valid mandates
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment