1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

More bug fixes

This commit is contained in:
Joshua Dwire 2016-05-11 14:12:52 -04:00
parent 0d41d8aeb6
commit 573c17431f

View File

@ -112,9 +112,9 @@ class PaymentService extends BaseService
public function convertInputForOmnipay($input) public function convertInputForOmnipay($input)
{ {
$data = [ $data = [
'firstName' => $input['first_name'], 'firstName' => isset($input['first_name']) ? $input['first_name'] : null,
'lastName' => $input['last_name'], 'lastName' =>isset($input['last_name']) ? $input['last_name'] : null,
'email' => $input['email'], 'email' => isset($input['email']) ? $input['email'] : null,
'number' => isset($input['card_number']) ? $input['card_number'] : null, 'number' => isset($input['card_number']) ? $input['card_number'] : null,
'expiryMonth' => isset($input['expiration_month']) ? $input['expiration_month'] : null, 'expiryMonth' => isset($input['expiration_month']) ? $input['expiration_month'] : null,
'expiryYear' => isset($input['expiration_year']) ? $input['expiration_year'] : null, 'expiryYear' => isset($input['expiration_year']) ? $input['expiration_year'] : null,
@ -380,19 +380,19 @@ class PaymentService extends BaseService
} }
if ($customerReference) { if ($customerReference) {
$token = AccountGatewayToken::where('client_id', '=', $client->id) $accountGatewayToken = AccountGatewayToken::where('client_id', '=', $client->id)
->where('account_gateway_id', '=', $accountGateway->id)->first(); ->where('account_gateway_id', '=', $accountGateway->id)->first();
if (!$token) { if (!$accountGatewayToken) {
$token = new AccountGatewayToken(); $accountGatewayToken = new AccountGatewayToken();
$token->account_id = $client->account->id; $accountGatewayToken->account_id = $client->account->id;
$token->contact_id = $contactId; $accountGatewayToken->contact_id = $contactId;
$token->account_gateway_id = $accountGateway->id; $accountGatewayToken->account_gateway_id = $accountGateway->id;
$token->client_id = $client->id; $accountGatewayToken->client_id = $client->id;
} }
$token->token = $customerReference; $accountGatewayToken->token = $customerReference;
$token->save(); $accountGatewayToken->save();
$paymentMethod = $this->createPaymentMethodFromGatewayResponse($tokenResponse, $accountGateway, $accountGatewayToken, $contactId); $paymentMethod = $this->createPaymentMethodFromGatewayResponse($tokenResponse, $accountGateway, $accountGatewayToken, $contactId);
@ -464,7 +464,7 @@ class PaymentService extends BaseService
$source = $data; $source = $data;
} elseif (!empty($data['object']) && $data['object'] == 'customer') { } elseif (!empty($data['object']) && $data['object'] == 'customer') {
$sources = !empty($data['sources']) ? $data['sources'] : $data['cards']; $sources = !empty($data['sources']) ? $data['sources'] : $data['cards'];
$source = reset($sources); $source = reset($sources['data']);
} else { } else {
$source = !empty($data['source']) ? $data['source'] : $data['card']; $source = !empty($data['source']) ? $data['source'] : $data['card'];
} }