Stripe Customer Email Not Passed Through #1569

This commit is contained in:
Hillel Coren 2017-07-28 16:04:05 +03:00
parent e05b04485d
commit fda0eeaf5e

View File

@ -119,6 +119,18 @@ class StripePaymentDriver extends BasePaymentDriver
$data = $this->paymentDetails();
$data['description'] = $client->getDisplayName();
// if a customer already exists link the token to it
if ($customer = $this->customer()) {
$data['customerReference'] = $customer->token;
// otherwise create a new customer
} else {
$response = $this->gateway()->createCustomer([
'description' => $client->getDisplayName(),
'email' => $this->contact()->email,
])->send();
$data['customerReference'] = $response->getCustomerReference();
}
if (! empty($data['plaidPublicToken'])) {
$plaidResult = $this->getPlaidToken($data['plaidPublicToken'], $data['plaidAccountId']);
unset($data['plaidPublicToken']);
@ -126,11 +138,6 @@ class StripePaymentDriver extends BasePaymentDriver
$data['token'] = $plaidResult['stripe_bank_account_token'];
}
// if a customer already exists link the token to it
if ($customer = $this->customer()) {
$data['customerReference'] = $customer->token;
}
$tokenResponse = $this->gateway()
->createCard($data)
->send();
@ -146,7 +153,11 @@ class StripePaymentDriver extends BasePaymentDriver
public function creatingCustomer($customer)
{
$customer->token = $this->tokenResponse['id'];
if (isset($this->tokenResponse['customer'])) {
$customer->token = $this->tokenResponse['customer'];
} else {
$customer->token = $this->tokenResponse['id'];
}
return $customer;
}