1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 00:41:34 +02:00

Merge pull request #3880 from turbo124/v2

V2
This commit is contained in:
David Bomba 2020-07-03 18:27:06 +10:00 committed by GitHub
commit b3c2953e19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 97 additions and 56 deletions

View File

@ -23,6 +23,6 @@ class PingController extends BaseController
*/ */
public function index() public function index()
{ {
return response()->json(['company_name' => auth()->user()->getCompany()->present()->name()], 200); return response()->json(['company_name' => auth()->user()->getCompany()->present()->name() - auth()->user()->present()->name()], 200);
} }
} }

View File

@ -377,6 +377,29 @@ class Client extends BaseModel implements HasLocalePreference
return null; return null;
} }
public function getBankTransferGateway() :?CompanyGateway
{
$company_gateways = $this->getSetting('company_gateway_ids');
if (strlen($company_gateways)>=1) {
$gateways = $this->company->company_gateways->whereIn('id', $company_gateways);
} else {
$gateways = $this->company->company_gateways;
}
foreach ($gateways as $gateway) {
if ($this->currency()->code == 'USD' && in_array(GatewayType::BANK_TRANSFER, $gateway->driver($this)->gatewayTypes())) {
return $gateway;
}
if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, $gateway->driver($this)->gatewayTypes())) {
return $gateway;
}
}
return null;
}
public function getCurrencyCode() public function getCurrencyCode()
{ {
if ($this->currency()) { if ($this->currency()) {
@ -385,6 +408,7 @@ class Client extends BaseModel implements HasLocalePreference
return 'USD'; return 'USD';
} }
/** /**
* Generates an array of payment urls per client * Generates an array of payment urls per client
* for a given amount. * for a given amount.
@ -404,14 +428,14 @@ class Client extends BaseModel implements HasLocalePreference
//this method will get all the possible gateways a client can pay with //this method will get all the possible gateways a client can pay with
//but we also need to consider payment methods that are already stored //but we also need to consider payment methods that are already stored
//so we MUST filter the company gateways and remove duplicates. //so we MUST filter the company gateways and remove duplicates.
//
//Also need to harvest the list of client gateway tokens and present these //Also need to harvest the list of client gateway tokens and present these
//for instant payment //for instant payment
$company_gateways = $this->getSetting('company_gateway_ids'); $company_gateways = $this->getSetting('company_gateway_ids');
if ($company_gateways) { if ($company_gateways) {
$gateways = $this->company->company_gateways->whereIn('id', $payment_gateways); $gateways = $this->company->company_gateways->whereIn('id', $payment_gateways); //this will never hit
} else { } else {
$gateways = $this->company->company_gateways; $gateways = $this->company->company_gateways;
} }
@ -434,7 +458,6 @@ class Client extends BaseModel implements HasLocalePreference
} }
} }
$payment_methods_collections = collect($payment_methods); $payment_methods_collections = collect($payment_methods);
//** Plucks the remaining keys into its own collection //** Plucks the remaining keys into its own collection

View File

@ -50,6 +50,10 @@ class CheckoutComPaymentDriver extends BasePaymentDriver
/** Instance of \Checkout\CheckoutApi */ /** Instance of \Checkout\CheckoutApi */
public $gateway; public $gateway;
public static $methods = [
GatewayType::CREDIT_CARD => '',
];
/** Since with Checkout.com we handle only credit cards, this method should be empty. */ /** Since with Checkout.com we handle only credit cards, this method should be empty. */
public function setPaymentMethod($string = null) public function setPaymentMethod($string = null)
{ {

46
composer.lock generated
View File

@ -107,16 +107,16 @@
}, },
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.144.2", "version": "3.145.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "0a0b9e4d485fe0cd53db2a4075eba9a416d8331c" "reference": "df5406b49f4f5774045e51e8fecc75717c4d6454"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/0a0b9e4d485fe0cd53db2a4075eba9a416d8331c", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/df5406b49f4f5774045e51e8fecc75717c4d6454",
"reference": "0a0b9e4d485fe0cd53db2a4075eba9a416d8331c", "reference": "df5406b49f4f5774045e51e8fecc75717c4d6454",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -188,7 +188,7 @@
"s3", "s3",
"sdk" "sdk"
], ],
"time": "2020-07-01T18:18:54+00:00" "time": "2020-07-02T18:12:35+00:00"
}, },
{ {
"name": "checkout/checkout-sdk-php", "name": "checkout/checkout-sdk-php",
@ -1089,6 +1089,20 @@
"sqlserver", "sqlserver",
"sqlsrv" "sqlsrv"
], ],
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal",
"type": "tidelift"
}
],
"time": "2020-04-20T17:19:26+00:00" "time": "2020-04-20T17:19:26+00:00"
}, },
{ {
@ -3776,16 +3790,16 @@
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v4.5.0", "version": "v4.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "53c2753d756f5adb586dca79c2ec0e2654dd9463" "reference": "c346bbfafe2ff60680258b631afb730d186ed864"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/53c2753d756f5adb586dca79c2ec0e2654dd9463", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c346bbfafe2ff60680258b631afb730d186ed864",
"reference": "53c2753d756f5adb586dca79c2ec0e2654dd9463", "reference": "c346bbfafe2ff60680258b631afb730d186ed864",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3824,7 +3838,7 @@
"parser", "parser",
"php" "php"
], ],
"time": "2020-06-03T07:24:19+00:00" "time": "2020-07-02T17:12:47+00:00"
}, },
{ {
"name": "nwidart/laravel-modules", "name": "nwidart/laravel-modules",
@ -4278,16 +4292,16 @@
}, },
{ {
"name": "php-http/discovery", "name": "php-http/discovery",
"version": "1.8.0", "version": "1.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-http/discovery.git", "url": "https://github.com/php-http/discovery.git",
"reference": "10d9019f393773345aedc0dc79e7fd678da874ee" "reference": "9ab7668fee74a5ad61996095e50917bd50ee8bfe"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-http/discovery/zipball/10d9019f393773345aedc0dc79e7fd678da874ee", "url": "https://api.github.com/repos/php-http/discovery/zipball/9ab7668fee74a5ad61996095e50917bd50ee8bfe",
"reference": "10d9019f393773345aedc0dc79e7fd678da874ee", "reference": "9ab7668fee74a5ad61996095e50917bd50ee8bfe",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4310,7 +4324,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.7-dev" "dev-master": "1.9-dev"
} }
}, },
"autoload": { "autoload": {
@ -4339,7 +4353,7 @@
"message", "message",
"psr7" "psr7"
], ],
"time": "2020-06-14T10:44:12+00:00" "time": "2020-07-02T11:43:45+00:00"
}, },
{ {
"name": "php-http/guzzle6-adapter", "name": "php-http/guzzle6-adapter",

View File

@ -319,44 +319,44 @@ class RandomDataSeeder extends Seeder
$cg->save(); $cg->save();
} }
// if (config('ninja.testvars.paypal')) { if (config('ninja.testvars.paypal')) {
// $cg = new CompanyGateway; $cg = new CompanyGateway;
// $cg->company_id = $company->id; $cg->company_id = $company->id;
// $cg->user_id = $user->id; $cg->user_id = $user->id;
// $cg->gateway_key = '38f2c48af60c7dd69e04248cbb24c36e'; $cg->gateway_key = '38f2c48af60c7dd69e04248cbb24c36e';
// $cg->require_cvv = true; $cg->require_cvv = true;
// $cg->show_billing_address = true; $cg->show_billing_address = true;
// $cg->show_shipping_address = true; $cg->show_shipping_address = true;
// $cg->update_details = true; $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.paypal')); $cg->config = encrypt(config('ninja.testvars.paypal'));
// $cg->save(); $cg->save();
// } }
// if(config('ninja.testvars.checkout')) { if(config('ninja.testvars.checkout')) {
// $cg = new CompanyGateway; $cg = new CompanyGateway;
// $cg->company_id = $company->id; $cg->company_id = $company->id;
// $cg->user_id = $user->id; $cg->user_id = $user->id;
// $cg->gateway_key = '3758e7f7c6f4cecf0f4f348b9a00f456'; $cg->gateway_key = '3758e7f7c6f4cecf0f4f348b9a00f456';
// $cg->require_cvv = true; $cg->require_cvv = true;
// $cg->show_billing_address = true; $cg->show_billing_address = true;
// $cg->show_shipping_address = true; $cg->show_shipping_address = true;
// $cg->update_details = true; $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.checkout')); $cg->config = encrypt(config('ninja.testvars.checkout'));
// $cg->save(); $cg->save();
// } }
// if(config('ninja.testvars.authorize')) { if(config('ninja.testvars.authorize')) {
// $cg = new CompanyGateway; $cg = new CompanyGateway;
// $cg->company_id = $company->id; $cg->company_id = $company->id;
// $cg->user_id = $user->id; $cg->user_id = $user->id;
// $cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb'; $cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
// $cg->require_cvv = true; $cg->require_cvv = true;
// $cg->show_billing_address = true; $cg->show_billing_address = true;
// $cg->show_shipping_address = true; $cg->show_shipping_address = true;
// $cg->update_details = true; $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.authorize')); $cg->config = encrypt(config('ninja.testvars.authorize'));
// $cg->save(); $cg->save();
// } }
} }
} }