mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fix for adding new cards with Braintree
This commit is contained in:
parent
a87a0bc24d
commit
d77b6794f2
@ -5,6 +5,7 @@ namespace App\Ninja\PaymentDrivers;
|
|||||||
use Braintree\Customer;
|
use Braintree\Customer;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Session;
|
use Session;
|
||||||
|
use Utils;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
|
|
||||||
class BraintreePaymentDriver extends BasePaymentDriver
|
class BraintreePaymentDriver extends BasePaymentDriver
|
||||||
@ -98,14 +99,16 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
|||||||
|
|
||||||
public function createToken()
|
public function createToken()
|
||||||
{
|
{
|
||||||
|
$data = $this->paymentDetails();
|
||||||
|
|
||||||
if ($customer = $this->customer()) {
|
if ($customer = $this->customer()) {
|
||||||
$customerReference = $customer->token;
|
$customerReference = $customer->token;
|
||||||
} else {
|
} else {
|
||||||
$data = $this->paymentDetails();
|
|
||||||
$tokenResponse = $this->gateway()->createCustomer(['customerData' => $this->customerData()])->send();
|
$tokenResponse = $this->gateway()->createCustomer(['customerData' => $this->customerData()])->send();
|
||||||
if ($tokenResponse->isSuccessful()) {
|
if ($tokenResponse->isSuccessful()) {
|
||||||
$customerReference = $tokenResponse->getCustomerData()->id;
|
$customerReference = $tokenResponse->getCustomerData()->id;
|
||||||
} else {
|
} else {
|
||||||
|
Utils::logError($tokenResponse->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,6 +124,7 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
|||||||
if ($tokenResponse->isSuccessful()) {
|
if ($tokenResponse->isSuccessful()) {
|
||||||
$this->tokenResponse = $tokenResponse->getData()->paymentMethod;
|
$this->tokenResponse = $tokenResponse->getData()->paymentMethod;
|
||||||
} else {
|
} else {
|
||||||
|
Utils::logError($tokenResponse->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user