1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fix for adding new cards with Braintree

This commit is contained in:
Hillel Coren 2017-08-11 10:55:54 +03:00
parent 24997c9382
commit ed09cb3c78

View File

@ -5,6 +5,7 @@ namespace App\Ninja\PaymentDrivers;
use Braintree\Customer;
use Exception;
use Session;
use Utils;
use App\Models\GatewayType;
class BraintreePaymentDriver extends BasePaymentDriver
@ -98,14 +99,16 @@ class BraintreePaymentDriver extends BasePaymentDriver
public function createToken()
{
$data = $this->paymentDetails();
if ($customer = $this->customer()) {
$customerReference = $customer->token;
} else {
$data = $this->paymentDetails();
$tokenResponse = $this->gateway()->createCustomer(['customerData' => $this->customerData()])->send();
if ($tokenResponse->isSuccessful()) {
$customerReference = $tokenResponse->getCustomerData()->id;
} else {
Utils::logError($tokenResponse->getMessage());
return false;
}
}
@ -121,6 +124,7 @@ class BraintreePaymentDriver extends BasePaymentDriver
if ($tokenResponse->isSuccessful()) {
$this->tokenResponse = $tokenResponse->getData()->paymentMethod;
} else {
Utils::logError($tokenResponse->getMessage());
return false;
}
}