mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Wrap getting token in the try-catch block
This commit is contained in:
parent
831fbade7b
commit
67f00214fa
@ -134,17 +134,32 @@ class CreditCard
|
|||||||
return $data['token'];
|
return $data['token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$gateway_response = json_decode($data['gateway_response']);
|
$gateway_response = \json_decode($data['gateway_response']);
|
||||||
|
|
||||||
$payment_method = $this->braintree->gateway->paymentMethod()->create([
|
try {
|
||||||
'customerId' => $customerId,
|
$payment_method = $this->braintree->gateway->paymentMethod()->create([
|
||||||
'paymentMethodNonce' => $gateway_response->nonce,
|
'customerId' => $customerId,
|
||||||
'options' => [
|
'paymentMethodNonce' => $gateway_response->nonce,
|
||||||
'verifyCard' => true,
|
'options' => [
|
||||||
],
|
'verifyCard' => true,
|
||||||
]);
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $payment_method->paymentMethod->token;
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
SystemLogger::dispatch(
|
||||||
|
$e->getMessage(),
|
||||||
|
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||||
|
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||||
|
SystemLog::TYPE_BRAINTREE,
|
||||||
|
$this->braintree->client,
|
||||||
|
$this->braintree->client->company,
|
||||||
|
);
|
||||||
|
|
||||||
return $payment_method->paymentMethod->token;
|
nlog(['e' => $e->getMessage(), 'class' => \get_class($e)]);
|
||||||
|
|
||||||
|
throw new PaymentFailed($e->getMessage(), $e->getCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processSuccessfulPayment($response)
|
private function processSuccessfulPayment($response)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user