From 2440070376f5a95bd01e6ae9a85f7439354f5f9b Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 15 Jul 2016 11:25:22 +0300 Subject: [PATCH] Fix for token billing --- app/Http/routes.php | 2 +- app/Models/PaymentMethod.php | 6 +++--- app/Ninja/PaymentDrivers/BasePaymentDriver.php | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index a4185e91f2..01651d3751 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -606,7 +606,7 @@ if (!defined('CONTACT_EMAIL')) { define('NINJA_WEB_URL', env('NINJA_WEB_URL', 'https://www.invoiceninja.com')); define('NINJA_APP_URL', env('NINJA_APP_URL', 'https://app.invoiceninja.com')); define('NINJA_DATE', '2000-01-01'); - define('NINJA_VERSION', '2.6.2' . env('NINJA_VERSION_SUFFIX')); + define('NINJA_VERSION', '2.6.3' . env('NINJA_VERSION_SUFFIX')); define('SOCIAL_LINK_FACEBOOK', env('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja')); define('SOCIAL_LINK_TWITTER', env('SOCIAL_LINK_TWITTER', 'https://twitter.com/invoiceninja')); diff --git a/app/Models/PaymentMethod.php b/app/Models/PaymentMethod.php index 1a0f865be1..5b9a64757c 100644 --- a/app/Models/PaymentMethod.php +++ b/app/Models/PaymentMethod.php @@ -113,9 +113,9 @@ class PaymentMethod extends EntityModel */ public function scopeClientId($query, $clientId) { - return $query->with(['contact' => function($query) use ($clientId) { - return $query->whereClientId($clientId); - }]); + $query->whereHas('contact', function($query) use ($clientId) { + $query->whereClientId($clientId); + }); } /** diff --git a/app/Ninja/PaymentDrivers/BasePaymentDriver.php b/app/Ninja/PaymentDrivers/BasePaymentDriver.php index 17ed76d3fc..800726bdc9 100644 --- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php @@ -516,6 +516,7 @@ class BasePaymentDriver public function createPaymentMethod($customer) { $paymentMethod = PaymentMethod::createNew($this->invitation); + $paymentMethod->contact_id = $this->contact()->id; $paymentMethod->ip = Request::ip(); $paymentMethod->account_gateway_token_id = $customer->id; $paymentMethod->setRelation('account_gateway_token', $customer);