mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Return token if response is success
This commit is contained in:
parent
cc53c697bd
commit
6f30c787d1
@ -136,30 +136,19 @@ class CreditCard
|
||||
|
||||
$gateway_response = \json_decode($data['gateway_response']);
|
||||
|
||||
try {
|
||||
$payment_method = $this->braintree->gateway->paymentMethod()->create([
|
||||
'customerId' => $customerId,
|
||||
'paymentMethodNonce' => $gateway_response->nonce,
|
||||
'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,
|
||||
);
|
||||
$response = $this->braintree->gateway->paymentMethod()->create([
|
||||
'customerId' => $customerId,
|
||||
'paymentMethodNonce' => $gateway_response->nonce,
|
||||
'options' => [
|
||||
'verifyCard' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
nlog(['e' => $e->getMessage(), 'class' => \get_class($e)]);
|
||||
|
||||
throw new PaymentFailed($e->getMessage(), $e->getCode());
|
||||
if ($response->success) {
|
||||
return $response->paymentMethod->token;
|
||||
}
|
||||
|
||||
throw new PaymentFailed($response->message);
|
||||
}
|
||||
|
||||
private function processSuccessfulPayment($response)
|
||||
|
Loading…
Reference in New Issue
Block a user