Merge pull request #5959 from turbo124/wepay

Wepay
This commit is contained in:
David Bomba 2021-06-08 18:19:39 +10:00 committed by GitHub
commit e3da3c35be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 163 additions and 75 deletions

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class AccountCreated
use Turbo124\Beacon\ExampleMetric\GenericCounter;
class AccountCreated extends GenericCounter
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class AccountDeleted
use Turbo124\Beacon\ExampleMetric\GenericCounter;
class AccountDeleted extends GenericCounter
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class DbQuery
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class DbQuery extends GenericMixedMetric
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class EmailFailure
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class EmailFailure extends GenericMixedMetric
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class EmailInvoiceFailure
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class EmailInvoiceFailure extends GenericMixedMetric
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class EmailSuccess
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class EmailSuccess extends GenericMixedMetric
{
/**

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class LoginFailure
use Turbo124\Beacon\ExampleMetric\GenericCounter;
class LoginFailure extends GenericCounter
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class LoginSuccess
use Turbo124\Beacon\ExampleMetric\GenericCounter;
class LoginSuccess extends GenericCounter
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics\Mail;
class EmailBounce
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class EmailBounce extends GenericMixedMetric
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics\Mail;
class EmailSpam
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class EmailSpam extends GenericMixedMetric
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class MigrationFailure
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class MigrationFailure extends GenericMixedMetric
{
/**
* The type of Sample.

View File

@ -11,7 +11,9 @@
namespace App\DataMapper\Analytics;
class SendRecurringFailure
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class SendRecurringFailure extends GenericMixedMetric
{
/**
* The type of Sample.

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire;
use App\Factory\CompanyGatewayFactory;
use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\User;
@ -48,6 +49,7 @@ class WepaySignup extends Component
'country' => ['required'],
'ach' => ['sometimes'],
'wepay_payment_tos_agree' => ['accepted'],
'debit_cards' => ['sometimes'],
];
public function mount()
@ -77,22 +79,29 @@ class WepaySignup extends Component
public function submit()
{
$data = $this->validate($this->rules);
//need to create or get a new WePay CompanyGateway
$cg = CompanyGateway::where('id', 49)
$cg = CompanyGateway::where('gateway_key', '8fdeed552015b3c7b44ed6c8ebd9e992')
->where('company_id', $this->company->id)
->firstOrNew();
if(!$cg->id) {
$cg = CompanyGatewayFactory::create($this->company->id, $this->user->id);
$cg->gateway_key = '8fdeed552015b3c7b44ed6c8ebd9e992';
$cg->require_cvv = false;
$cg->require_billing_address = false;
$cg->require_shipping_address = false;
$cg->update_details = false;
$cg->config = encrypt(config('ninja.testvars.checkout'));
$cg->save();
}
$data = $this->validate($this->rules);
$this->saved = ctrans('texts.processing');
$wepay_driver = new WePayPaymentDriver(new CompanyGateway, null, null);
$wepay_driver = new WePayPaymentDriver($cg, null, null);
$wepay_driver->init();
$wepay = $wepay_driver->init()->wepay;
$user_details = [
'client_id' => config('ninja.wepay.client_id'),
@ -107,7 +116,7 @@ class WepaySignup extends Component
'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money',
];
$wepay_user = $wepay_driver->request('user/register/', $user_details);
$wepay_user = $wepay->request('user/register/', $user_details);
$access_token = $wepay_user->access_token;
@ -120,7 +129,7 @@ class WepaySignup extends Component
'description' => ctrans('texts.wepay_account_description'),
'theme_object' => json_decode('{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}'),
'callback_uri' => route('payment_webhook', ['company_key' => $this->company->company_key, 'company_gateway_id' => $cg->hashed_id]),
'rbits' => $this->company->present()->rBits,
'rbits' => $this->company->rBits(),
'country' => $data['country'],
];
@ -144,5 +153,19 @@ class WepaySignup extends Component
}
}
$config = [
'userId' => $wepay_user->user_id,
'accessToken' => $access_token,
'tokenType' => $wepay_user->token_type,
'tokenExpires' => $access_token_expires,
'accountId' => $wepay_account->account_id,
'state' => $wepay_account->state,
'testMode' => config('ninja.wepay.environment') == 'staging',
'country' => $data['country'],
];
$cg->setConfig($config);
$cg->save();
}
}

View File

@ -445,21 +445,36 @@ class Company extends BaseModel
public function rBits()
{
$account = $this->account;
$user = $this->owner();
$data = [];
$data[] = $this->createRBit('business_name', 'user', ['business_name' => $this->present()->name()]);
$data[] = $this->createRBit('industry_code', 'user', ['industry_detail' => $this->industry->name]);
$data[] = $this->createRBit('industry_code', 'user', ['industry_detail' => $this->industry ? $this->industry->name : '']);
$data[] = $this->createRBit('comment', 'partner_database', ['comment_text' => 'Logo image not present']);
$data[] = $this->createRBit('business_description', 'user', ['business_description' => $company->present()->size()]);
$data[] = $this->createRBit('business_description', 'user', ['business_description' => $this->present()->size()]);
$data[] = $this->createRBit('person', 'user', ['name' => $user->present()->getFullName()]);
$data[] = $this->createRBit('email', 'user', ['email' => $user->email]);
$data[] = $this->createRBit('phone', 'user', ['phone' => $user->phone]);
$data[] = $this->createRBit('website_uri', 'user', ['uri' => $this->entity->settings->website]);
$data[] = $this->createRBit('website_uri', 'user', ['uri' => $this->settings->website]);
$data[] = $this->createRBit('external_account', 'partner_database', ['is_partner_account' => 'yes', 'account_type' => 'Invoice Ninja', 'create_time' => time()]);
return $data;
}
private function createRBit($type, $source, $properties)
{
$data = new \stdClass;
$data->receive_time = time();
$data->type = $type;
$data->source = $source;
$data->properties = new \stdClass;
foreach ($properties as $key => $val) {
$data->properties->$key = $val;
}
return $data;
}
}

View File

@ -48,14 +48,14 @@ class WePayPaymentDriver extends BaseDriver
if (WePay::getEnvironment() == 'none') {
if(config('ninja.wepay.environment') == 'staging')
WePay::useStaing(config('ninja.wepay.client_id'), config('ninja.wepay.client_secret'));
WePay::useStaging(config('ninja.wepay.client_id'), config('ninja.wepay.client_secret'));
else
WePay::useProduction(config('ninja.wepay.client_id'), config('ninja.wepay.client_secret'));
}
if ($this->company_gateway)
$this->wepay = new WePay($this->company_gateway->getConfig()->accessToken);
$this->wepay = new WePay($this->company_gateway->getConfigField('accessToken'));
$this->wepay = new WePay(null);

View File

@ -12,6 +12,7 @@
namespace App\Utils;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
/**
@ -69,6 +70,28 @@ class Statics
$data = [];
foreach (config('ninja.cached_tables') as $name => $class) {
if (!Cache::has($name)) {
// check that the table exists in case the migration is pending
if (!Schema::hasTable((new $class())->getTable())) {
continue;
}
if ($name == 'payment_terms') {
$orderBy = 'num_days';
} elseif ($name == 'fonts') {
$orderBy = 'sort_order';
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
$orderBy = 'name';
} else {
$orderBy = 'id';
}
$tableData = $class::orderBy($orderBy)->get();
if ($tableData->count()) {
Cache::forever($name, $tableData);
}
}
$data[$name] = Cache::get($name);
}

84
composer.lock generated
View File

@ -103,16 +103,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.180.1",
"version": "3.180.5",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "7801112fd8be227954a6ecfbfd85b01ee4a7cae4"
"reference": "948a4defbe2a571cc4460725015b8e98b7060f2d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/7801112fd8be227954a6ecfbfd85b01ee4a7cae4",
"reference": "7801112fd8be227954a6ecfbfd85b01ee4a7cae4",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/948a4defbe2a571cc4460725015b8e98b7060f2d",
"reference": "948a4defbe2a571cc4460725015b8e98b7060f2d",
"shasum": ""
},
"require": {
@ -187,9 +187,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.180.1"
"source": "https://github.com/aws/aws-sdk-php/tree/3.180.5"
},
"time": "2021-05-04T18:14:38+00:00"
"time": "2021-05-07T18:12:43+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -6811,16 +6811,16 @@
},
{
"name": "sentry/sentry",
"version": "3.2.1",
"version": "3.2.2",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-php.git",
"reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f"
"reference": "02237728bdc5b82b0a14c37417644e3f3606db9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f",
"reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/02237728bdc5b82b0a14c37417644e3f3606db9b",
"reference": "02237728bdc5b82b0a14c37417644e3f3606db9b",
"shasum": ""
},
"require": {
@ -6899,7 +6899,7 @@
],
"support": {
"issues": "https://github.com/getsentry/sentry-php/issues",
"source": "https://github.com/getsentry/sentry-php/tree/3.2.1"
"source": "https://github.com/getsentry/sentry-php/tree/3.2.2"
},
"funding": [
{
@ -6911,20 +6911,20 @@
"type": "custom"
}
],
"time": "2021-04-06T07:55:41+00:00"
"time": "2021-05-06T10:15:01+00:00"
},
{
"name": "sentry/sentry-laravel",
"version": "2.5.1",
"version": "2.5.2",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-laravel.git",
"reference": "2af8a531f202f0ac014f5fad532815ed34f730a9"
"reference": "368a2701b3bd370a2892f1f67bfbf0cbecbaca17"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/2af8a531f202f0ac014f5fad532815ed34f730a9",
"reference": "2af8a531f202f0ac014f5fad532815ed34f730a9",
"url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/368a2701b3bd370a2892f1f67bfbf0cbecbaca17",
"reference": "368a2701b3bd370a2892f1f67bfbf0cbecbaca17",
"shasum": ""
},
"require": {
@ -6987,7 +6987,7 @@
],
"support": {
"issues": "https://github.com/getsentry/sentry-laravel/issues",
"source": "https://github.com/getsentry/sentry-laravel/tree/2.5.1"
"source": "https://github.com/getsentry/sentry-laravel/tree/2.5.2"
},
"funding": [
{
@ -6999,20 +6999,20 @@
"type": "custom"
}
],
"time": "2021-04-29T11:10:22+00:00"
"time": "2021-05-06T07:49:08+00:00"
},
{
"name": "stripe/stripe-php",
"version": "v7.77.0",
"version": "v7.78.0",
"source": {
"type": "git",
"url": "https://github.com/stripe/stripe-php.git",
"reference": "f6724447481f6fb8c2e714165e092adad9ca470a"
"reference": "6ec33fa8e9de2322be93d28dfd685661c67ca549"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/f6724447481f6fb8c2e714165e092adad9ca470a",
"reference": "f6724447481f6fb8c2e714165e092adad9ca470a",
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/6ec33fa8e9de2322be93d28dfd685661c67ca549",
"reference": "6ec33fa8e9de2322be93d28dfd685661c67ca549",
"shasum": ""
},
"require": {
@ -7058,9 +7058,9 @@
],
"support": {
"issues": "https://github.com/stripe/stripe-php/issues",
"source": "https://github.com/stripe/stripe-php/tree/v7.77.0"
"source": "https://github.com/stripe/stripe-php/tree/v7.78.0"
},
"time": "2021-04-12T17:19:16+00:00"
"time": "2021-05-05T23:55:32+00:00"
},
{
"name": "swiftmailer/swiftmailer",
@ -9809,16 +9809,16 @@
},
{
"name": "turbo124/laravel-gmail",
"version": "v5.0.1",
"version": "v5.0.2",
"source": {
"type": "git",
"url": "https://github.com/turbo124/laravel-gmail.git",
"reference": "55ca0271a54a568ebaa26febbe0790b2ce5ac966"
"reference": "f8b8806d0b37ab5b2d4c3f402f8094d9021bd342"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/turbo124/laravel-gmail/zipball/55ca0271a54a568ebaa26febbe0790b2ce5ac966",
"reference": "55ca0271a54a568ebaa26febbe0790b2ce5ac966",
"url": "https://api.github.com/repos/turbo124/laravel-gmail/zipball/f8b8806d0b37ab5b2d4c3f402f8094d9021bd342",
"reference": "f8b8806d0b37ab5b2d4c3f402f8094d9021bd342",
"shasum": ""
},
"require": {
@ -9872,9 +9872,9 @@
"laravel"
],
"support": {
"source": "https://github.com/turbo124/laravel-gmail/tree/v5.0.1"
"source": "https://github.com/turbo124/laravel-gmail/tree/v5.0.2"
},
"time": "2021-04-06T00:53:48+00:00"
"time": "2021-05-08T00:17:52+00:00"
},
{
"name": "vlucas/phpdotenv",
@ -10792,21 +10792,21 @@
},
{
"name": "darkaonline/l5-swagger",
"version": "8.0.4",
"version": "8.0.5",
"source": {
"type": "git",
"url": "https://github.com/DarkaOnLine/L5-Swagger.git",
"reference": "3477e7013daf8b6fc142c45fdcb9fe6c74d7398d"
"reference": "238e5d318b3d48a77c76b6950c51146578563853"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/DarkaOnLine/L5-Swagger/zipball/3477e7013daf8b6fc142c45fdcb9fe6c74d7398d",
"reference": "3477e7013daf8b6fc142c45fdcb9fe6c74d7398d",
"url": "https://api.github.com/repos/DarkaOnLine/L5-Swagger/zipball/238e5d318b3d48a77c76b6950c51146578563853",
"reference": "238e5d318b3d48a77c76b6950c51146578563853",
"shasum": ""
},
"require": {
"ext-json": "*",
"laravel/framework": "^8.0 || ^7.0",
"laravel/framework": ">=8.40.0 || ^7.0",
"php": "^7.2 || ^8.0",
"swagger-api/swagger-ui": "^3.0",
"symfony/yaml": "^5.0",
@ -10859,7 +10859,7 @@
],
"support": {
"issues": "https://github.com/DarkaOnLine/L5-Swagger/issues",
"source": "https://github.com/DarkaOnLine/L5-Swagger/tree/8.0.4"
"source": "https://github.com/DarkaOnLine/L5-Swagger/tree/8.0.5"
},
"funding": [
{
@ -10867,7 +10867,7 @@
"type": "github"
}
],
"time": "2020-12-08T13:29:20+00:00"
"time": "2021-05-07T09:57:00+00:00"
},
{
"name": "dnoegel/php-xdg-base-dir",
@ -11112,16 +11112,16 @@
},
{
"name": "facade/ignition",
"version": "2.8.4",
"version": "2.9.0",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "87fb348dab0ae1a7c206c3e902a5a44ba541742f"
"reference": "e7db3b601ce742568b92648818ef903904d20164"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/87fb348dab0ae1a7c206c3e902a5a44ba541742f",
"reference": "87fb348dab0ae1a7c206c3e902a5a44ba541742f",
"url": "https://api.github.com/repos/facade/ignition/zipball/e7db3b601ce742568b92648818ef903904d20164",
"reference": "e7db3b601ce742568b92648818ef903904d20164",
"shasum": ""
},
"require": {
@ -11185,7 +11185,7 @@
"issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition"
},
"time": "2021-04-29T13:55:26+00:00"
"time": "2021-05-05T06:45:12+00:00"
},
{
"name": "facade/ignition-contracts",

View File

@ -76,25 +76,26 @@
<label for="country" class="input-label">@lang('texts.debit_cards')</label>
<div class="checkbox">
<input class="form-checkbox cursor-pointer mr-2" type="checkbox">
<input class="form-checkbox cursor-pointer mr-2" type="checkbox" name="debit_cards" value="1" wire:model="debit_cards">
<span>{{ ctrans('texts.accept_debit_cards') }}</span>
</div>
</div>
@endif
<!--
<div class="col-span-6 sm:col-span-4">
<label for="country" class="input-label">@lang('texts.ach')</label>
<div class="checkbox">
<input class="switch-input" type="checkbox" name="ach" value="1" wire:model="ach">
<input class="form-checkbox cursor-pointer mr-2" type="checkbox" name="ach" value="1" wire:model="ach">
<span>{{ ctrans('texts.enable_ach')}}</span>
</div>
</div>
-->
<div class="col-span-6 sm:col-span-4">
<label for="country" class="input-label"></label>
<div class="checkbox">
<input type="checkbox" name="wepay_payment_tos_agree" value="1"
wire:model="wepay_payment_tos_agree">
<input class="form-checkbox cursor-pointer mr-2" type="checkbox" name="wepay_payment_tos_agree" value="1" wire:model="wepay_payment_tos_agree">
<span>{!! ctrans('texts.wepay_payment_tos_agree', ['terms' => $terms, 'privacy_policy' => $privacy_policy]) !!}</span>
</div>
@error('wepay_payment_tos_agree')
@ -104,6 +105,10 @@
@enderror
</div>
<div class="col-span-6 sm:col-span-4">
<span><i>{{ ctrans('texts.standard_fees_apply')}}</i></span>
</div>
<div class="col-span-6 {{ $country != 'CA' ? 'hidden' : 'block' }}">
<table id="canadaFees" width="100%" class="min-w-full"
style="border: 1px solid black; margin-bottom: 40px; display: table;">
@ -267,9 +272,7 @@
</table>
</div>
<div class="col-span-6 sm:col-span-4">
<span><i>{{ ctrans('texts.standard_fees_apply')}}</i></span>
</div>
</div>
</div>