mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-17 00:22:51 +01:00
commit
6961c514e2
@ -1 +1 @@
|
|||||||
5.1.63
|
5.1.64
|
@ -21,6 +21,7 @@ use App\Models\Country;
|
|||||||
use App\Models\Currency;
|
use App\Models\Currency;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
use App\PaymentDrivers\StripePaymentDriver;
|
use App\PaymentDrivers\StripePaymentDriver;
|
||||||
|
use App\PaymentDrivers\Stripe\UpdatePaymentMethods;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Stripe\Customer;
|
use Stripe\Customer;
|
||||||
use Stripe\PaymentMethod;
|
use Stripe\PaymentMethod;
|
||||||
@ -32,9 +33,12 @@ class ImportCustomers
|
|||||||
/** @var StripePaymentDriver */
|
/** @var StripePaymentDriver */
|
||||||
public $stripe;
|
public $stripe;
|
||||||
|
|
||||||
|
public $update_payment_methods;
|
||||||
|
|
||||||
public function __construct(StripePaymentDriver $stripe)
|
public function __construct(StripePaymentDriver $stripe)
|
||||||
{
|
{
|
||||||
$this->stripe = $stripe;
|
$this->stripe = $stripe;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
@ -42,6 +46,8 @@ class ImportCustomers
|
|||||||
|
|
||||||
$this->stripe->init();
|
$this->stripe->init();
|
||||||
|
|
||||||
|
$this->update_payment_methods = new UpdatePaymentMethods($this->stripe);
|
||||||
|
|
||||||
$customers = Customer::all([], $this->stripe->stripe_connect_auth);
|
$customers = Customer::all([], $this->stripe->stripe_connect_auth);
|
||||||
|
|
||||||
foreach($customers as $customer)
|
foreach($customers as $customer)
|
||||||
@ -123,5 +129,6 @@ class ImportCustomers
|
|||||||
$contact->email = $customer->email ?: '';
|
$contact->email = $customer->email ?: '';
|
||||||
$contact->save();
|
$contact->save();
|
||||||
|
|
||||||
|
$this->update_payment_methods->updateMethods($customer, $client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
namespace App\PaymentDrivers\Stripe;
|
namespace App\PaymentDrivers\Stripe;
|
||||||
|
|
||||||
use App\Factory\ClientGatewayTokenFactory;
|
use App\Factory\ClientGatewayTokenFactory;
|
||||||
|
use App\Models\Client;
|
||||||
use App\Models\ClientGatewayToken;
|
use App\Models\ClientGatewayToken;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
use App\PaymentDrivers\StripePaymentDriver;
|
use App\PaymentDrivers\StripePaymentDriver;
|
||||||
@ -32,90 +33,96 @@ class UpdatePaymentMethods
|
|||||||
$this->stripe = $stripe;
|
$this->stripe = $stripe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run()
|
// public function run()
|
||||||
|
// {
|
||||||
|
// $this->stripe->init();
|
||||||
|
|
||||||
|
// $this->stripe
|
||||||
|
// ->company_gateway
|
||||||
|
// ->client_gateway_tokens
|
||||||
|
// ->each(function ($token){
|
||||||
|
|
||||||
|
|
||||||
|
// // $bank_accounts = Customer::allSources(
|
||||||
|
// // $token->gateway_customer_reference,
|
||||||
|
// // ['object' => 'bank_account', 'limit' => 300]
|
||||||
|
// // );
|
||||||
|
|
||||||
|
// // foreach($bank_accounts as $bank_account)
|
||||||
|
// // {
|
||||||
|
// // $this->addOrUpdateBankAccount($bank_account, $token);
|
||||||
|
// // }
|
||||||
|
// // $this->processCustomer($token->gateway_customer_reference);
|
||||||
|
|
||||||
|
// });
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
private function updateMethods(Customer $customer, Client $client)
|
||||||
{
|
{
|
||||||
$this->stripe->init();
|
|
||||||
|
|
||||||
$this->stripe
|
|
||||||
->company_gateway
|
|
||||||
->client_gateway_tokens
|
|
||||||
->each(function ($token){
|
|
||||||
|
|
||||||
$card_methods = PaymentMethod::all([
|
$card_methods = PaymentMethod::all([
|
||||||
'customer' => $token->gateway_customer_reference,
|
'customer' => $customer->id,
|
||||||
'type' => 'card',
|
'type' => 'card',
|
||||||
],
|
],
|
||||||
$this->stripe->stripe_connect_auth);
|
$this->stripe->stripe_connect_auth);
|
||||||
|
|
||||||
foreach($card_methods as $method)
|
foreach($card_methods as $method)
|
||||||
{
|
{
|
||||||
$this->addOrUpdateCard($method, $token, GatewayType::CREDIT_CARD);
|
$this->addOrUpdateCard($method, $customer->id, $client,GatewayType::CREDIT_CARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
$alipay_methods = PaymentMethod::all([
|
$alipay_methods = PaymentMethod::all([
|
||||||
'customer' => $token->gateway_customer_reference,
|
'customer' => $customer->id,
|
||||||
'type' => 'alipay',
|
'type' => 'alipay',
|
||||||
],
|
],
|
||||||
$this->stripe->stripe_connect_auth);
|
$this->stripe->stripe_connect_auth);
|
||||||
|
|
||||||
foreach($alipay_methods as $method)
|
foreach($alipay_methods as $method)
|
||||||
{
|
{
|
||||||
$this->addOrUpdateCard($method, $token, GatewayType::ALIPAY);
|
$this->addOrUpdateCard($method, $customer->id, $client,GatewayType::ALIPAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sofort_methods = PaymentMethod::all([
|
$sofort_methods = PaymentMethod::all([
|
||||||
'customer' => $token->gateway_customer_reference,
|
'customer' => $customer->id,
|
||||||
'type' => 'sofort',
|
'type' => 'sofort',
|
||||||
],
|
],
|
||||||
$this->stripe->stripe_connect_auth);
|
$this->stripe->stripe_connect_auth);
|
||||||
|
|
||||||
foreach($alipay_methods as $method)
|
foreach($alipay_methods as $method)
|
||||||
{
|
{
|
||||||
$this->addOrUpdateCard($method, $token, GatewayType::SOFORT);
|
$this->addOrUpdateCard($method, $customer->id, $client, GatewayType::SOFORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $bank_accounts = Customer::allSources(
|
}
|
||||||
// $token->gateway_customer_reference,
|
|
||||||
// ['object' => 'bank_account', 'limit' => 300]
|
|
||||||
// );
|
|
||||||
|
|
||||||
// foreach($bank_accounts as $bank_account)
|
// private function addOrUpdateBankAccount($bank_account, $customer_reference, Client $client)
|
||||||
// {
|
// {
|
||||||
// $this->addOrUpdateBankAccount($bank_account, $token);
|
// $token_exists = ClientGatewayToken::where([
|
||||||
|
// 'gateway_customer_reference' => $customer_reference,
|
||||||
|
// 'token' => $bank_account->id,
|
||||||
|
// ])->exists();
|
||||||
|
|
||||||
|
// /* Already exists return */
|
||||||
|
// if($token_exists)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// $cgt = ClientGatewayTokenFactory::create($client->company_id);
|
||||||
|
// $cgt->client_id = $client->id;
|
||||||
|
// $cgt->token = $bank_account->id;
|
||||||
|
// $cgt->gateway_customer_reference = $customer_reference;
|
||||||
|
// $cgt->company_gateway_id = $this->stripe->company_gateway->id;
|
||||||
|
// $cgt->gateway_type_id = GatewayType::BANK_TRANSFER;
|
||||||
|
// $cgt->meta = new \stdClass;
|
||||||
|
// $cgt->routing_number = $bank_account->routing_number;
|
||||||
|
// $cgt->save();
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
});
|
private function addOrUpdateCard(PaymentMethod $method, $customer_reference, Client $client, $type_id)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addOrUpdateBankAccount($bank_account, ClientGatewayToken $token)
|
|
||||||
{
|
|
||||||
$token_exists = ClientGatewayToken::where([
|
|
||||||
'gateway_customer_reference' => $token->gateway_customer_reference,
|
|
||||||
'token' => $bank_account->id,
|
|
||||||
])->exists();
|
|
||||||
|
|
||||||
/* Already exists return */
|
|
||||||
if($token_exists)
|
|
||||||
return;
|
|
||||||
|
|
||||||
$cgt = ClientGatewayTokenFactory::create($token->company_id);
|
|
||||||
$cgt->client_id = $token->client_id;
|
|
||||||
$cgt->token = $bank_account->id;
|
|
||||||
$cgt->gateway_customer_reference = $token->gateway_customer_reference;
|
|
||||||
$cgt->company_gateway_id = $token->company_gateway_id;
|
|
||||||
$cgt->gateway_type_id = GatewayType::BANK_TRANSFER;
|
|
||||||
$cgt->meta = new \stdClass;
|
|
||||||
$cgt->routing_number = $bank_account->routing_number;
|
|
||||||
$cgt->save();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addOrUpdateCard(PaymentMethod $method, ClientGatewayToken $token, $type_id)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$token_exists = ClientGatewayToken::where([
|
$token_exists = ClientGatewayToken::where([
|
||||||
'gateway_customer_reference' => $token->gateway_customer_reference,
|
'gateway_customer_reference' => $customer_reference,
|
||||||
'token' => $method->id,
|
'token' => $method->id,
|
||||||
])->exists();
|
])->exists();
|
||||||
|
|
||||||
@ -127,11 +134,11 @@ class UpdatePaymentMethods
|
|||||||
if($method->card->exp_year <= date('Y') && $method->card->exp_month < date('m'))
|
if($method->card->exp_year <= date('Y') && $method->card->exp_month < date('m'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$cgt = ClientGatewayTokenFactory::create($token->company_id);
|
$cgt = ClientGatewayTokenFactory::create($client->company_id);
|
||||||
$cgt->client_id = $token->client_id;
|
$cgt->client_id = $client->id;
|
||||||
$cgt->token = $method->id;
|
$cgt->token = $method->id;
|
||||||
$cgt->gateway_customer_reference = $token->gateway_customer_reference;
|
$cgt->gateway_customer_reference = $customer_reference;
|
||||||
$cgt->company_gateway_id = $token->company_gateway_id;
|
$cgt->company_gateway_id = $this->stripe->company_gateway->id;
|
||||||
$cgt->gateway_type_id = $type_id;
|
$cgt->gateway_type_id = $type_id;
|
||||||
$cgt->meta = $this->buildPaymentMethodMeta($method, $type_id);
|
$cgt->meta = $this->buildPaymentMethodMeta($method, $type_id);
|
||||||
$cgt->save();
|
$cgt->save();
|
||||||
|
@ -501,10 +501,10 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
* the respective tokens in the system.
|
* the respective tokens in the system.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function updateAllPaymentMethods()
|
// public function updateAllPaymentMethods()
|
||||||
{
|
// {
|
||||||
return (new UpdatePaymentMethods($this))->run();
|
// return (new UpdatePaymentMethods($this))->run();
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports stripe customers and their payment methods
|
* Imports stripe customers and their payment methods
|
||||||
|
@ -14,8 +14,8 @@ return [
|
|||||||
'require_https' => env('REQUIRE_HTTPS', true),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||||
'app_version' => '5.1.63',
|
'app_version' => '5.1.64',
|
||||||
'app_tag' => '5.1.63-release',
|
'app_tag' => '5.1.64-release',
|
||||||
'minimum_client_version' => '5.0.16',
|
'minimum_client_version' => '5.0.16',
|
||||||
'terms_version' => '1.0.1',
|
'terms_version' => '1.0.1',
|
||||||
'api_secret' => env('API_SECRET', ''),
|
'api_secret' => env('API_SECRET', ''),
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class AddShowTaskEndDateToCompaniesTables extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('companies', function (Blueprint $table) {
|
|
||||||
$table->boolean('show_task_end_date')->default(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('companies', function (Blueprint $table) {
|
|
||||||
//
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,6 +16,15 @@ class AddRecurringInvoiceIdToActivitiesTable extends Migration
|
|||||||
Schema::table('activities', function (Blueprint $table) {
|
Schema::table('activities', function (Blueprint $table) {
|
||||||
$table->unsignedInteger('recurring_invoice_id')->nullable();
|
$table->unsignedInteger('recurring_invoice_id')->nullable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (!Schema::hasColumn('companies', 'show_task_end_date'))
|
||||||
|
{
|
||||||
|
Schema::table('companies', function (Blueprint $table) {
|
||||||
|
$table->boolean('show_task_end_date')->default(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user