From cf3465b5e22737577e33b4becf2c39b223310721 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 15 Jul 2016 11:23:19 +0300 Subject: [PATCH] Fix for token billing --- app/Models/PaymentMethod.php | 6 +++--- app/Ninja/PaymentDrivers/BasePaymentDriver.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Models/PaymentMethod.php b/app/Models/PaymentMethod.php index 1a0f865be141..5b9a64757c0c 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 baef52a7a34e..9cc7c405431f 100644 --- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php @@ -531,6 +531,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);