mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Rollback for new payment flow
This commit is contained in:
parent
af92ce8d37
commit
036aca49a4
@ -131,7 +131,8 @@ class BaseRule implements RuleInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function shouldCalcTax(): bool {
|
||||
public function shouldCalcTax(): bool
|
||||
{
|
||||
return $this->should_calc_tax && $this->checkIfInvoiceLocked();
|
||||
}
|
||||
/**
|
||||
@ -404,8 +405,9 @@ class BaseRule implements RuleInterface
|
||||
{
|
||||
$lock_invoices = $this->client->getSetting('lock_invoices');
|
||||
|
||||
if($this->invoice instanceof RecurringInvoice)
|
||||
if($this->invoice instanceof RecurringInvoice) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ($lock_invoices) {
|
||||
case 'off':
|
||||
|
@ -251,8 +251,7 @@ class Rule extends BaseRule implements RuleInterface
|
||||
$this->reduced_tax_rate = 0;
|
||||
} elseif(!in_array($this->client_subregion, $this->eu_country_codes)) {
|
||||
$this->defaultForeign();
|
||||
} elseif(in_array($this->client_subregion, $this->eu_country_codes) && ((strlen($this->client->vat_number ?? '') == 1) || $this->client->has_valid_vat_number)) { //eu country / no valid vat
|
||||
// if(($this->client->company->tax_data->seller_subregion != $this->client_subregion) && $this->client->company->tax_data->regions->EU->has_sales_above_threshold) {
|
||||
} elseif(in_array($this->client_subregion, $this->eu_country_codes) && ((strlen($this->client->vat_number ?? '') == 1) || !$this->client->has_valid_vat_number)) { //eu country / no valid vat
|
||||
if($this->client->company->tax_data->seller_subregion != $this->client_subregion) {
|
||||
// nlog("eu zone with sales above threshold");
|
||||
$this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->tax_rate ?? 0;
|
||||
|
@ -48,8 +48,7 @@ class TaxModel
|
||||
public function migrate(): self
|
||||
{
|
||||
|
||||
if($this->version == 'alpha')
|
||||
{
|
||||
if($this->version == 'alpha') {
|
||||
$this->regions->EU->subregions->PL = new \stdClass();
|
||||
$this->regions->EU->subregions->PL->tax_rate = 23;
|
||||
$this->regions->EU->subregions->PL->tax_name = 'VAT';
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace App\DataProviders;
|
||||
|
||||
final class CAProvinces {
|
||||
final class CAProvinces
|
||||
{
|
||||
/**
|
||||
* The provinces and territories of Canada
|
||||
*
|
||||
@ -39,7 +40,8 @@ final class CAProvinces {
|
||||
* @param string $abbreviation
|
||||
* @return string
|
||||
*/
|
||||
public static function getName($abbreviation) {
|
||||
public static function getName($abbreviation)
|
||||
{
|
||||
return self::$provinces[$abbreviation];
|
||||
}
|
||||
|
||||
@ -48,7 +50,8 @@ final class CAProvinces {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get() {
|
||||
public static function get()
|
||||
{
|
||||
return self::$provinces;
|
||||
}
|
||||
|
||||
@ -58,7 +61,8 @@ final class CAProvinces {
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function getAbbreviation($name) {
|
||||
public static function getAbbreviation($name)
|
||||
{
|
||||
return array_search(ucwords($name), self::$provinces);
|
||||
}
|
||||
}
|
||||
|
@ -269,8 +269,7 @@ class ExpenseExport extends BaseExport
|
||||
|
||||
if($expense->uses_inclusive_taxes) {
|
||||
$entity['expense.net_amount'] = round($expense->amount, $precision) - $total_tax_amount;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$entity['expense.net_amount'] = round($expense->amount, $precision);
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,9 @@ class ExpenseFilters extends QueryFilters
|
||||
{
|
||||
$categories_exploded = explode(",", $categories);
|
||||
|
||||
if(empty($categories) || count(array_filter($categories_exploded)) == 0)
|
||||
if(empty($categories) || count(array_filter($categories_exploded)) == 0) {
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
$categories_keys = $this->transformKeys($categories_exploded);
|
||||
|
||||
|
@ -254,17 +254,20 @@ class ActivityController extends BaseController
|
||||
$activity->client_id = $entity->client_id;
|
||||
$activity->project_id = $entity->project_id;
|
||||
$activity->vendor_id = $entity->vendor_id;
|
||||
// no break
|
||||
case Task::class:
|
||||
$activity->task_id = $entity->id;
|
||||
$activity->expense_id = $entity->id;
|
||||
$activity->client_id = $entity->client_id;
|
||||
$activity->project_id = $entity->project_id;
|
||||
$activity->vendor_id = $entity->vendor_id;
|
||||
// no break
|
||||
case Payment::class:
|
||||
$activity->payment_id = $entity->id;
|
||||
$activity->expense_id = $entity->id;
|
||||
$activity->client_id = $entity->client_id;
|
||||
$activity->project_id = $entity->project_id;
|
||||
// no break
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
|
@ -41,8 +41,9 @@ class ContactLoginController extends Controller
|
||||
$company = false;
|
||||
$account = false;
|
||||
|
||||
if($request->query('intended'))
|
||||
if($request->query('intended')) {
|
||||
$request->session()->put('url.intended', $request->query('intended'));
|
||||
}
|
||||
|
||||
if ($request->session()->has('company_key')) {
|
||||
MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key'));
|
||||
@ -142,8 +143,9 @@ class ContactLoginController extends Controller
|
||||
|
||||
$this->setRedirectPath();
|
||||
|
||||
if($intended)
|
||||
if($intended) {
|
||||
$this->redirectTo = $intended;
|
||||
}
|
||||
|
||||
return $request->wantsJson()
|
||||
? new JsonResponse([], 204)
|
||||
|
@ -19,7 +19,6 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class BrevoController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\Quickbooks\AuthorizedQuickbooksRequest;
|
||||
use \Closure;
|
||||
use Closure;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Company;
|
||||
use App\Libraries\MultiDB;
|
||||
@ -19,7 +19,6 @@ use App\Services\Import\Quickbooks\QuickbooksService;
|
||||
|
||||
class ImportQuickbooksController extends BaseController
|
||||
{
|
||||
|
||||
private array $import_entities = [
|
||||
'client' => 'Customer',
|
||||
'invoice' => 'Invoice',
|
||||
@ -46,7 +45,6 @@ class ImportQuickbooksController extends BaseController
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorizeQuickbooks(AuthQuickbooksRequest $request, string $token)
|
||||
{
|
||||
@ -74,15 +72,17 @@ class ImportQuickbooksController extends BaseController
|
||||
$this->getData($data);
|
||||
}
|
||||
|
||||
protected function getData($data) {
|
||||
protected function getData($data)
|
||||
{
|
||||
|
||||
$entity = $this->import_entities[$data['type']];
|
||||
$cache_name = "{$data['hash']}-{$data['type']}";
|
||||
// TODO: Get or put cache or DB?
|
||||
if(! Cache::has($cache_name) )
|
||||
{
|
||||
if(! Cache::has($cache_name)) {
|
||||
$contents = call_user_func([$this->service, "fetch{$entity}s"]);
|
||||
if($contents->isEmpty()) return;
|
||||
if($contents->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cache::put($cache_name, base64_encode($contents->toJson()), 600);
|
||||
}
|
||||
@ -117,20 +117,19 @@ class ImportQuickbooksController extends BaseController
|
||||
*/
|
||||
public function import(Request $request)
|
||||
{
|
||||
$hash = Str::random(32);
|
||||
foreach($request->input('import_types') as $type)
|
||||
{
|
||||
$this->preimport($type, $hash);
|
||||
}
|
||||
/** @var \App\Models\User $user */
|
||||
// $user = auth()->user() ?? Auth::loginUsingId(60);
|
||||
$data = ['import_types' => $request->input('import_types') ] + compact('hash');
|
||||
if (Ninja::isHosted()) {
|
||||
QuickbooksIngest::dispatch( $data , $user->company() );
|
||||
} else {
|
||||
QuickbooksIngest::dispatch($data, $user->company() );
|
||||
}
|
||||
// $hash = Str::random(32);
|
||||
// foreach($request->input('import_types') as $type) {
|
||||
// $this->preimport($type, $hash);
|
||||
// }
|
||||
// /** @var \App\Models\User $user */
|
||||
// // $user = auth()->user() ?? Auth::loginUsingId(60);
|
||||
// $data = ['import_types' => $request->input('import_types') ] + compact('hash');
|
||||
// if (Ninja::isHosted()) {
|
||||
// QuickbooksIngest::dispatch($data, $user->company());
|
||||
// } else {
|
||||
// QuickbooksIngest::dispatch($data, $user->company());
|
||||
// }
|
||||
|
||||
return response()->json(['message' => 'Processing'], 200);
|
||||
// return response()->json(['message' => 'Processing'], 200);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class MailgunWebhookController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ use Illuminate\Support\Str;
|
||||
|
||||
class OneTimeTokenController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -19,7 +19,6 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class PostMarkController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -297,8 +297,7 @@ class PreviewController extends BaseController
|
||||
->setTemplate($design_object)
|
||||
->mock();
|
||||
} catch(SyntaxError $e) {
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
} catch(\Exception $e) {
|
||||
return response()->json(['message' => 'invalid data access', 'errors' => ['design.design.body' => $e->getMessage()]], 422);
|
||||
}
|
||||
|
||||
|
@ -181,8 +181,9 @@ class SelfUpdateController extends BaseController
|
||||
|
||||
public function checkVersion()
|
||||
{
|
||||
if(Ninja::isHosted())
|
||||
if(Ninja::isHosted()) {
|
||||
return '5.10.SaaS';
|
||||
}
|
||||
|
||||
return trim(file_get_contents(config('ninja.version_url')));
|
||||
}
|
||||
|
@ -85,7 +85,10 @@ class ThrottleRequestsWithPredis extends \Illuminate\Routing\Middleware\Throttle
|
||||
protected function tooManyAttempts($key, $maxAttempts, $decaySeconds)
|
||||
{
|
||||
$limiter = new DurationLimiter(
|
||||
$this->getRedisConnection(), $key, $maxAttempts, $decaySeconds
|
||||
$this->getRedisConnection(),
|
||||
$key,
|
||||
$maxAttempts,
|
||||
$decaySeconds
|
||||
);
|
||||
|
||||
return tap(! $limiter->acquire(), function () use ($key, $limiter) {
|
||||
|
@ -68,8 +68,9 @@ class StoreNoteRequest extends Request
|
||||
|
||||
public function getEntity()
|
||||
{
|
||||
if(!$this->entity)
|
||||
if(!$this->entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$class = "\\App\\Models\\".ucfirst(Str::camel(rtrim($this->entity, 's')));
|
||||
return $class::withTrashed()->find(is_string($this->entity_id) ? $this->decodePrimaryKey($this->entity_id) : $this->entity_id);
|
||||
|
@ -66,8 +66,7 @@ class ShowCalculatedFieldRequest extends Request
|
||||
$input['end_date'] = now()->format('Y-m-d');
|
||||
}
|
||||
|
||||
if(isset($input['period']) && $input['period'] == 'previous')
|
||||
{
|
||||
if(isset($input['period']) && $input['period'] == 'previous') {
|
||||
$dates = $this->calculatePreviousPeriodStartAndEndDates($input, $user->company());
|
||||
$input['start_date'] = $dates[0];
|
||||
$input['end_date'] = $dates[1];
|
||||
|
@ -40,8 +40,9 @@ class BulkInvoiceRequest extends Request
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key))
|
||||
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key)) {
|
||||
throw new DuplicatePaymentException('Duplicate request.', 429);
|
||||
}
|
||||
|
||||
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key), true, 1);
|
||||
|
||||
|
@ -80,8 +80,9 @@ class StorePaymentRequest extends Request
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('amount', 0)."|".$this->input('client_id', '')."|".$user->company()->company_key))
|
||||
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('amount', 0)."|".$this->input('client_id', '')."|".$user->company()->company_key)) {
|
||||
throw new DuplicatePaymentException('Duplicate request.', 429);
|
||||
}
|
||||
|
||||
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('amount', 0)."|".$this->input('client_id', '')."|".$user->company()->company_key), true, 1);
|
||||
|
||||
|
@ -17,7 +17,6 @@ use Illuminate\Auth\Access\AuthorizationException;
|
||||
|
||||
class GenericReportRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
@ -15,7 +15,6 @@ use App\Http\Requests\Request;
|
||||
|
||||
class DisconnectUserMailerRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
@ -77,8 +77,7 @@ class UpdateUserRequest extends Request
|
||||
unset($input['oauth_user_token']);
|
||||
}
|
||||
|
||||
if(isset($input['password']) && is_string($input['password']))
|
||||
{
|
||||
if(isset($input['password']) && is_string($input['password'])) {
|
||||
$input['password'] = trim($input['password']);
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,7 @@ class ValidClientScheme implements ValidationRule, ValidatorAwareRule
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
if(isset($value['Invoice']))
|
||||
{
|
||||
if(isset($value['Invoice'])) {
|
||||
$r = new EInvoice();
|
||||
$errors = $r->validateRequest($value['Invoice'], ClientLevel::class);
|
||||
|
||||
|
@ -24,7 +24,6 @@ use Illuminate\Contracts\Validation\ValidatorAwareRule;
|
||||
*/
|
||||
class ValidCompanyScheme implements ValidationRule, ValidatorAwareRule
|
||||
{
|
||||
|
||||
/**
|
||||
* The validator instance.
|
||||
*
|
||||
@ -35,8 +34,7 @@ class ValidCompanyScheme implements ValidationRule, ValidatorAwareRule
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
if(isset($value['Invoice']))
|
||||
{
|
||||
if(isset($value['Invoice'])) {
|
||||
$r = new EInvoice();
|
||||
$errors = $r->validateRequest($value['Invoice'], CompanyLevel::class);
|
||||
|
||||
|
@ -42,7 +42,8 @@ class AccountComponent extends Component
|
||||
"authorization_type" => 'Online'
|
||||
];
|
||||
|
||||
public function __construct(public array $account) {
|
||||
public function __construct(public array $account)
|
||||
{
|
||||
$this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields));
|
||||
}
|
||||
|
||||
|
@ -34,16 +34,20 @@ class AddressComponent extends Component
|
||||
'country' => 'US'
|
||||
];
|
||||
|
||||
public function __construct(public array $address) {
|
||||
public function __construct(public array $address)
|
||||
{
|
||||
if(strlen($this->address['state']) > 2) {
|
||||
$this->address['state'] = $this->address['country'] == 'US' ? array_search($this->address['state'], USStates::$states) : CAProvinces::getAbbreviation($this->address['state']);
|
||||
}
|
||||
|
||||
$this->attributes = $this->newAttributeBag(
|
||||
Arr::only(Arr::mapWithKeys($this->address, function ($item, $key) {
|
||||
Arr::only(
|
||||
Arr::mapWithKeys($this->address, function ($item, $key) {
|
||||
return in_array($key, ['address1','address2','state']) ? [ (['address1' => 'address_1','address2' => 'address_2','state' => 'province_code'])[$key] => $item ] : [ $key => $item ];
|
||||
}),
|
||||
$this->fields) );
|
||||
$this->fields
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,12 +18,11 @@ use App\Models\ClientContact;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\View\View;
|
||||
|
||||
|
||||
// Contact Component
|
||||
class ContactComponent extends Component
|
||||
{
|
||||
|
||||
public function __construct(ClientContact $contact) {
|
||||
public function __construct(ClientContact $contact)
|
||||
{
|
||||
|
||||
$contact = collect($contact->client->contacts->firstWhere('is_primary', 1)->toArray())->merge([
|
||||
'home_phone' => $contact->client->phone,
|
||||
|
@ -12,23 +12,24 @@
|
||||
namespace App\Import\Providers;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Factory\ProductFactory;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Factory\ProductFactory;
|
||||
use App\Import\ImportException;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Repositories\ClientRepository;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use App\Repositories\ProductRepository;
|
||||
use App\Repositories\PaymentRepository;
|
||||
use App\Repositories\ProductRepository;
|
||||
use App\Http\Requests\Client\StoreClientRequest;
|
||||
use App\Http\Requests\Product\StoreProductRequest;
|
||||
use App\Http\Requests\Invoice\StoreInvoiceRequest;
|
||||
use App\Http\Requests\Payment\StorePaymentRequest;
|
||||
use App\Http\Requests\Product\StoreProductRequest;
|
||||
use App\Import\Transformer\Quickbooks\ClientTransformer;
|
||||
use App\Import\Transformer\Quickbooks\InvoiceTransformer;
|
||||
use App\Import\Transformer\Quickbooks\ProductTransformer;
|
||||
use App\Import\Transformer\Quickbooks\PaymentTransformer;
|
||||
use App\Import\Transformer\Quickbooks\ProductTransformer;
|
||||
|
||||
class Quickbooks extends BaseImport
|
||||
{
|
||||
@ -94,10 +95,11 @@ class Quickbooks extends BaseImport
|
||||
$this->entity_count['products'] = $count;
|
||||
}
|
||||
|
||||
public function getData($type) {
|
||||
public function getData($type)
|
||||
{
|
||||
|
||||
// get the data from cache? file? or api ?
|
||||
return json_decode(base64_decode(Cache::get("{$this->hash}-$type")), 1);
|
||||
return json_decode(base64_decode(Cache::get("{$this->hash}-{$type}")), true);
|
||||
}
|
||||
|
||||
public function payment()
|
||||
@ -198,8 +200,7 @@ class Quickbooks extends BaseImport
|
||||
'error' => $validator->errors()->all(),
|
||||
];
|
||||
} else {
|
||||
if(!Invoice::where('number',$invoice_data['number'])->get()->first())
|
||||
{
|
||||
if(!Invoice::where('number', $invoice_data['number'])->first()) {
|
||||
$invoice = InvoiceFactory::create(
|
||||
$this->company->id,
|
||||
$this->company->owner()->id
|
||||
|
@ -244,8 +244,7 @@ class Wave extends BaseImport implements ImportInterface
|
||||
if (empty($expense_data['vendor_id'])) {
|
||||
$vendor_data['user_id'] = $this->getUserIDForRecord($expense_data);
|
||||
|
||||
if(isset($raw_expense['Vendor Name']) || isset($raw_expense['Vendor']))
|
||||
{
|
||||
if(isset($raw_expense['Vendor Name']) || isset($raw_expense['Vendor'])) {
|
||||
$vendor_repository->save(
|
||||
['name' => isset($raw_expense['Vendor Name']) ? $raw_expense['Vendor Name'] : isset($raw_expense['Vendor'])],
|
||||
$vendor = VendorFactory::create(
|
||||
|
@ -119,8 +119,9 @@ class BaseTransformer
|
||||
{
|
||||
$code = array_key_exists($key, $data) ? $data[$key] : false;
|
||||
|
||||
if(!$code)
|
||||
if(!$code) {
|
||||
return $this->company->settings->currency_id;
|
||||
}
|
||||
|
||||
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||
$currencies = app('currencies');
|
||||
|
@ -24,7 +24,6 @@ use Illuminate\Support\Str;
|
||||
*/
|
||||
class ClientTransformer extends BaseTransformer
|
||||
{
|
||||
|
||||
use CommonTrait {
|
||||
transform as preTransform;
|
||||
}
|
||||
@ -49,7 +48,7 @@ class ClientTransformer extends BaseTransformer
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model;
|
||||
$this->model = new Model();
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +72,8 @@ class ClientTransformer extends BaseTransformer
|
||||
return $transformed_data;
|
||||
}
|
||||
|
||||
protected function getContacts($data) {
|
||||
protected function getContacts($data)
|
||||
{
|
||||
return (new ClientContact())->fill([
|
||||
'first_name' => $this->getString($data, 'GivenName'),
|
||||
'last_name' => $this->getString($data, 'FamilyName'),
|
||||
@ -84,11 +84,13 @@ class ClientTransformer extends BaseTransformer
|
||||
}
|
||||
|
||||
|
||||
public function getShipAddrCountry($data,$field) {
|
||||
public function getShipAddrCountry($data, $field)
|
||||
{
|
||||
return is_null(($c = $this->getString($data, $field))) ? null : $this->getCountryId($c);
|
||||
}
|
||||
|
||||
public function getBillAddrCountry($data,$field) {
|
||||
public function getBillAddrCountry($data, $field)
|
||||
{
|
||||
return is_null(($c = $this->getString($data, $field))) ? null : $this->getCountryId($c);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,8 @@ trait CommonTrait
|
||||
{
|
||||
protected $model;
|
||||
|
||||
public function getString($data,$field) {
|
||||
public function getString($data, $field)
|
||||
{
|
||||
return Arr::get($data, $field);
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,11 @@
|
||||
|
||||
namespace App\Import\Transformer\Quickbooks;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Import\ImportException;
|
||||
use Illuminate\Support\Str;
|
||||
use App\DataMapper\InvoiceItem;
|
||||
use App\Import\ImportException;
|
||||
use App\Models\Invoice as Model;
|
||||
use App\Import\Transformer\BaseTransformer;
|
||||
use App\Import\Transformer\Quickbooks\CommonTrait;
|
||||
@ -48,7 +49,7 @@ class InvoiceTransformer extends BaseTransformer
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model;
|
||||
$this->model = new Model();
|
||||
}
|
||||
|
||||
public function getInvoiceStatus($data)
|
||||
@ -73,18 +74,19 @@ class InvoiceTransformer extends BaseTransformer
|
||||
'description' => $this->getString($item, 'Description'),
|
||||
'product_key' => $this->getString($item, 'Description'),
|
||||
'quantity' => (int) $this->getString($item, 'SalesItemLineDetail.Qty'),
|
||||
'unit_price' =>(double) $this->getString($item,'SalesItemLineDetail.UnitPrice'),
|
||||
'line_total' => (double) $this->getString($item,'Amount'),
|
||||
'cost' =>(double) $this->getString($item,'SalesItemLineDetail.UnitPrice'),
|
||||
'product_cost' => (double) $this->getString($item,'SalesItemLineDetail.UnitPrice'),
|
||||
'tax_amount' => (double) $this->getString($item,'TxnTaxDetail.TotalTax'),
|
||||
'unit_price' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
|
||||
'line_total' => (float) $this->getString($item, 'Amount'),
|
||||
'cost' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
|
||||
'product_cost' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
|
||||
'tax_amount' => (float) $this->getString($item, 'TxnTaxDetail.TotalTax'),
|
||||
];
|
||||
}, array_filter($this->getString($data, 'Line'), function ($item) {
|
||||
return $this->getString($item, 'DetailType') !== 'SubTotalLineDetail';
|
||||
}));
|
||||
}
|
||||
|
||||
public function getInvoiceClient($data, $field = null) {
|
||||
public function getInvoiceClient($data, $field = null)
|
||||
{
|
||||
/**
|
||||
* "CustomerRef": {
|
||||
"value": "23",
|
||||
@ -145,8 +147,7 @@ class InvoiceTransformer extends BaseTransformer
|
||||
"BillAddr" => array_combine(['City','CountrySubDivisionCode','PostalCode'], array_pad($address, 3, 'N/A')) + ['Line1' => $has_company ? $bill_address->Line3 : $bill_address->Line2 ],
|
||||
"ShipAddr" => $ship_address
|
||||
] + $customer + ['PrimaryEmailAddr' => ['Address' => $this->getString($data, 'BillEmail.Address') ]];
|
||||
if($this->hasClient($client['CompanyName']))
|
||||
{
|
||||
if($this->hasClient($client['CompanyName'])) {
|
||||
$client_id = $this->getClient($client['CompanyName'], $this->getString($client, 'PrimaryEmailAddr.Address'));
|
||||
}
|
||||
|
||||
@ -161,12 +162,12 @@ class InvoiceTransformer extends BaseTransformer
|
||||
|
||||
public function getDeposit($data)
|
||||
{
|
||||
return (double) $this->getString($data,'Deposit');
|
||||
return (float) $this->getString($data, 'Deposit');
|
||||
}
|
||||
|
||||
public function getBalance($data)
|
||||
{
|
||||
return (double) $this->getString($data,'Balance');
|
||||
return (float) $this->getString($data, 'Balance');
|
||||
}
|
||||
|
||||
public function getCustomerMemo($data)
|
||||
@ -176,7 +177,8 @@ class InvoiceTransformer extends BaseTransformer
|
||||
|
||||
public function getDocNumber($data, $field = null)
|
||||
{
|
||||
return sprintf("%s-%s",
|
||||
return sprintf(
|
||||
"%s-%s",
|
||||
$this->getString($data, 'DocNumber'),
|
||||
$this->getString($data, 'Id.value')
|
||||
);
|
||||
@ -185,7 +187,9 @@ class InvoiceTransformer extends BaseTransformer
|
||||
public function getLinkedTxn($data)
|
||||
{
|
||||
$payments = $this->getString($data, 'LinkedTxn');
|
||||
if(empty($payments)) return [];
|
||||
if(empty($payments)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [[
|
||||
'amount' => $this->getTotalAmt($data),
|
||||
|
@ -44,10 +44,11 @@ class PaymentTransformer extends BaseTransformer
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model;
|
||||
$this->model = new Model();
|
||||
}
|
||||
|
||||
public function getTotalAmt($data, $field = null) {
|
||||
public function getTotalAmt($data, $field = null)
|
||||
{
|
||||
return (float) $this->getString($data, $field);
|
||||
}
|
||||
|
||||
@ -70,8 +71,12 @@ class PaymentTransformer extends BaseTransformer
|
||||
{
|
||||
$invoices = [];
|
||||
$invoice = $this->getString($data, 'Line.LinkedTxn.TxnType');
|
||||
if(is_null($invoice) || $invoice !== 'Invoice') return $invoices;
|
||||
if( is_null( ($invoice_id = $this->getInvoiceId($this->getString($data, 'Line.LinkedTxn.TxnId.value')))) ) return $invoices;
|
||||
if(is_null($invoice) || $invoice !== 'Invoice') {
|
||||
return $invoices;
|
||||
}
|
||||
if(is_null(($invoice_id = $this->getInvoiceId($this->getString($data, 'Line.LinkedTxn.TxnId.value'))))) {
|
||||
return $invoices;
|
||||
}
|
||||
|
||||
return [[
|
||||
'amount' => (float) $this->getString($data, 'Line.Amount'),
|
||||
@ -88,7 +93,9 @@ class PaymentTransformer extends BaseTransformer
|
||||
{
|
||||
$invoice = Invoice::query()->where('company_id', $this->company->id)
|
||||
->where('is_deleted', false)
|
||||
->where("number", "LIKE",
|
||||
->where(
|
||||
"number",
|
||||
"LIKE",
|
||||
"%-$invoice_number%",
|
||||
)
|
||||
->first();
|
||||
|
@ -22,7 +22,6 @@ use App\Import\ImportException;
|
||||
*/
|
||||
class ProductTransformer extends BaseTransformer
|
||||
{
|
||||
|
||||
use CommonTrait;
|
||||
|
||||
protected $fillable = [
|
||||
@ -41,19 +40,22 @@ class ProductTransformer extends BaseTransformer
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model;
|
||||
$this->model = new Model();
|
||||
}
|
||||
|
||||
public function getQtyOnHand($data, $field = null) {
|
||||
public function getQtyOnHand($data, $field = null)
|
||||
{
|
||||
return (int) $this->getString($data, $field);
|
||||
}
|
||||
|
||||
public function getPurchaseCost($data, $field = null) {
|
||||
return (double) $this->getString($data, $field);
|
||||
public function getPurchaseCost($data, $field = null)
|
||||
{
|
||||
return (float) $this->getString($data, $field);
|
||||
}
|
||||
|
||||
|
||||
public function getUnitPrice($data, $field = null) {
|
||||
public function getUnitPrice($data, $field = null)
|
||||
{
|
||||
return (float) $this->getString($data, $field);
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,13 @@ class ExpenseTransformer extends BaseTransformer
|
||||
|
||||
$tax_rate = $total_tax > 0 ? round(($total_tax / $amount) * 100, 3) : 0;
|
||||
|
||||
if(isset($data['Notes / Memo']) && strlen($data['Notes / Memo']) > 1)
|
||||
if(isset($data['Notes / Memo']) && strlen($data['Notes / Memo']) > 1) {
|
||||
$public_notes = $data['Notes / Memo'];
|
||||
elseif (isset($data['Transaction Description']) && strlen($data['Transaction Description']) > 1)
|
||||
} elseif (isset($data['Transaction Description']) && strlen($data['Transaction Description']) > 1) {
|
||||
$public_notes = $data['Transaction Description'];
|
||||
else
|
||||
} else {
|
||||
$public_notes = '';
|
||||
}
|
||||
|
||||
|
||||
$transformed = [
|
||||
|
@ -114,8 +114,7 @@ class RecurringExpensesCron
|
||||
$exchange_rate = new CurrencyApi();
|
||||
|
||||
$expense->exchange_rate = $exchange_rate->exchangeRate($expense->currency_id, (int)$expense->company->settings->currency_id, Carbon::parse($expense->date));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$expense->exchange_rate = 1;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,10 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
class QuickbooksIngest implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected $engine;
|
||||
protected $request;
|
||||
|
@ -48,8 +48,7 @@ class TaskAssigned implements ShouldQueue
|
||||
|
||||
$company_user = $this->task->assignedCompanyUser();
|
||||
|
||||
if(($company_user instanceof CompanyUser) && $this->findEntityAssignedNotification($company_user, 'task'))
|
||||
{
|
||||
if(($company_user instanceof CompanyUser) && $this->findEntityAssignedNotification($company_user, 'task')) {
|
||||
$mo = new EmailObject();
|
||||
$mo->subject = ctrans('texts.task_assigned_subject', ['task' => $this->task->number, 'date' => now()->setTimeZone($this->task->company->timezone()->name)->format($this->task->company->date_format()) ]);
|
||||
$mo->body = ctrans('texts.task_assigned_body', ['task' => $this->task->number, 'description' => $this->task->description ?? '', 'client' => $this->task->client ? $this->task->client->present()->name() : ' ']);
|
||||
|
@ -363,10 +363,11 @@ class BillingPortalPurchase extends Component
|
||||
$method_values = array_column($this->methods, 'is_paypal');
|
||||
$is_paypal = in_array('1', $method_values);
|
||||
|
||||
if($is_paypal && !$this->steps['check_rff'])
|
||||
if($is_paypal && !$this->steps['check_rff']) {
|
||||
$this->rff();
|
||||
elseif(!$this->steps['check_rff'])
|
||||
} elseif(!$this->steps['check_rff']) {
|
||||
$this->steps['fetched_payment_methods'] = true;
|
||||
}
|
||||
|
||||
$this->heading_text = ctrans('texts.payment_methods');
|
||||
|
||||
|
@ -515,8 +515,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
strlen($this->contact_email ?? '') == 0 ||
|
||||
strlen($this->client_city ?? '') == 0 ||
|
||||
strlen($this->client_postal_code ?? '') == 0
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->check_rff = true;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ class InvoicePay extends Component
|
||||
|
||||
$this->payment_method_accepted = true;
|
||||
|
||||
$company_gateway = CompanyGateway::find($company_gateway_id);
|
||||
$company_gateway = CompanyGateway::query()->find($company_gateway_id);
|
||||
|
||||
$this->checkRequiredFields($company_gateway);
|
||||
}
|
||||
@ -240,8 +240,9 @@ class InvoicePay extends Component
|
||||
|
||||
nlog($this->invoices);
|
||||
|
||||
if(is_array($this->invoices))
|
||||
if(is_array($this->invoices)) {
|
||||
$this->invoices = Invoice::find($this->transformKeys($this->invoices));
|
||||
}
|
||||
|
||||
$invoices = $this->invoices->filter(function ($i) {
|
||||
$i = $i->service()
|
||||
|
@ -16,10 +16,8 @@ use Livewire\Component;
|
||||
|
||||
class Signature extends Component
|
||||
{
|
||||
|
||||
public function render()
|
||||
{
|
||||
return render('components.livewire.signature');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ use Livewire\Component;
|
||||
|
||||
class UnderOverPayment extends Component
|
||||
{
|
||||
|
||||
use WithSecureContext;
|
||||
|
||||
public $payableAmount;
|
||||
@ -51,8 +50,7 @@ class UnderOverPayment extends Component
|
||||
|
||||
$input_amount = collect($payableInvoices)->sum('amount');
|
||||
|
||||
if($settings->client_portal_allow_under_payment && $settings->client_portal_under_payment_minimum != 0)
|
||||
{
|
||||
if($settings->client_portal_allow_under_payment && $settings->client_portal_under_payment_minimum != 0) {
|
||||
if($input_amount <= $settings->client_portal_under_payment_minimum) {
|
||||
// return error message under payment too low.
|
||||
$this->errors = ctrans('texts.minimum_required_payment', ['amount' => $settings->client_portal_under_payment_minimum]);
|
||||
|
@ -449,8 +449,9 @@ class Activity extends StaticModel
|
||||
$replacements['created_at'] = $this->created_at ?? '';
|
||||
$replacements['ip'] = $this->ip ?? '';
|
||||
|
||||
if($this->activity_type_id == 141)
|
||||
if($this->activity_type_id == 141) {
|
||||
$replacements = $this->harvestNoteEntities($replacements);
|
||||
}
|
||||
|
||||
return $replacements;
|
||||
|
||||
@ -472,12 +473,12 @@ class Activity extends StaticModel
|
||||
|
||||
];
|
||||
|
||||
foreach($entities as $entity)
|
||||
{
|
||||
foreach($entities as $entity) {
|
||||
$entity_key = substr($entity, 1);
|
||||
|
||||
if($this?->{$entity_key})
|
||||
if($this?->{$entity_key}) {
|
||||
$replacements = array_merge($replacements, $this->matchVar($entity));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -376,8 +376,7 @@ class BaseModel extends Model
|
||||
|
||||
try {
|
||||
$pdf = (new PdfMerge($files->flatten()->toArray()))->run();
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch(\Exception $e) {
|
||||
nlog("Exception:: BaseModel:: PdfMerge::" . $e->getMessage());
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property string|null $smtp_port
|
||||
* @property string|null $smtp_encryption
|
||||
* @property string|null $smtp_local_domain
|
||||
* @property string|null $quickbooks
|
||||
* @property object|null $quickbooks
|
||||
* @property boolean $smtp_verify_peer
|
||||
* @property-read \App\Models\Account $account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
|
||||
|
@ -431,9 +431,9 @@ class Invoice extends BaseModel
|
||||
|
||||
public function isPayable(): bool
|
||||
{
|
||||
if($this->is_deleted || $this->status_id == self::STATUS_PAID)
|
||||
if($this->is_deleted || $this->status_id == self::STATUS_PAID) {
|
||||
return false;
|
||||
elseif ($this->status_id == self::STATUS_DRAFT && $this->is_deleted == false) {
|
||||
} elseif ($this->status_id == self::STATUS_DRAFT && $this->is_deleted == false) {
|
||||
return true;
|
||||
} elseif ($this->status_id == self::STATUS_SENT && $this->is_deleted == false) {
|
||||
return true;
|
||||
|
@ -435,8 +435,9 @@ class Quote extends BaseModel
|
||||
*/
|
||||
public function canRemind(): bool
|
||||
{
|
||||
if (in_array($this->status_id, [self::STATUS_DRAFT, self::STATUS_APPROVED, self::STATUS_CONVERTED]) || $this->is_deleted)
|
||||
if (in_array($this->status_id, [self::STATUS_DRAFT, self::STATUS_APPROVED, self::STATUS_CONVERTED]) || $this->is_deleted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -296,8 +296,7 @@ class Task extends BaseModel
|
||||
$client_currency = $this->client->getSetting('currency_id');
|
||||
$company_currency = $this->company->getSetting('currency_id');
|
||||
|
||||
if($client_currency != $company_currency)
|
||||
{
|
||||
if($client_currency != $company_currency) {
|
||||
$converter = new CurrencyApi();
|
||||
return $converter->convert($this->taskValue(), $client_currency, $company_currency);
|
||||
}
|
||||
@ -374,8 +373,9 @@ class Task extends BaseModel
|
||||
|
||||
public function assignedCompanyUser()
|
||||
{
|
||||
if(!$this->assigned_user_id)
|
||||
if(!$this->assigned_user_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CompanyUser::where('company_id', $this->company_id)->where('user_id', $this->assigned_user_id)->first();
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\AuthorizePaymentDriver;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest;
|
||||
use net\authorize\api\contract\v1\DeleteCustomerProfileRequest;
|
||||
@ -31,7 +30,7 @@ use net\authorize\api\controller\DeleteCustomerProfileController;
|
||||
/**
|
||||
* Class AuthorizeCreditCard.
|
||||
*/
|
||||
class AuthorizeCreditCard implements LivewireMethodInterface
|
||||
class AuthorizeCreditCard
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -42,7 +41,7 @@ class AuthorizeCreditCard implements LivewireMethodInterface
|
||||
$this->authorize = $authorize;
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
public function processPaymentView($data)
|
||||
{
|
||||
$tokens = ClientGatewayToken::where('client_id', $this->authorize->client->id)
|
||||
->where('company_gateway_id', $this->authorize->company_gateway->id)
|
||||
@ -55,13 +54,6 @@ class AuthorizeCreditCard implements LivewireMethodInterface
|
||||
$data['public_client_id'] = $this->authorize->init()->getPublicClientKey();
|
||||
$data['api_login_id'] = $this->authorize->company_gateway->getConfigField('apiLoginId');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function processPaymentView($data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
|
||||
return render('gateways.authorize.credit_card.pay', $data);
|
||||
}
|
||||
|
||||
@ -321,9 +313,4 @@ class AuthorizeCreditCard implements LivewireMethodInterface
|
||||
'invoices' => $vars['invoices'],
|
||||
];
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.authorize.credit_card.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ namespace App\PaymentDrivers\BTCPay;
|
||||
|
||||
use App\Models\Payment;
|
||||
use App\PaymentDrivers\BTCPayPaymentDriver;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
@ -25,7 +24,7 @@ use App\Services\Email\EmailObject;
|
||||
use App\Services\Email\Email;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class BTCPay implements MethodInterface, LivewireMethodInterface
|
||||
class BTCPay implements MethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -50,7 +49,9 @@ class BTCPay implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
public function paymentView($data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->driver_class;
|
||||
$data['amount'] = $data['total']['amount_with_fee'];
|
||||
$data['currency'] = $this->driver_class->client->getCurrencyCode();
|
||||
|
||||
return render('gateways.btcpay.pay', $data);
|
||||
}
|
||||
@ -175,24 +176,4 @@ class BTCPay implements MethodInterface, LivewireMethodInterface
|
||||
throw new PaymentFailed('Error during BTCPay refund : ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.btcpay.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->driver_class;
|
||||
$data['amount'] = $data['total']['amount_with_fee'];
|
||||
$data['currency'] = $this->driver_class->client->getCurrencyCode();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -867,14 +867,4 @@ class BaseDriver extends AbstractPaymentDriver
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return $this->payment_method->livewirePaymentView($data);
|
||||
}
|
||||
|
||||
public function processPaymentViewData(array $data): array
|
||||
{
|
||||
return $this->payment_method->paymentData($data);
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,11 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\BraintreePaymentDriver;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ACH implements MethodInterface, LivewireMethodInterface
|
||||
class ACH implements MethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -98,7 +97,10 @@ class ACH implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->braintree;
|
||||
$data['currency'] = $this->braintree->client->getCurrencyCode();
|
||||
$data['payment_method_id'] = GatewayType::BANK_TRANSFER;
|
||||
$data['amount'] = $this->braintree->payment_hash->data->amount_with_fee;
|
||||
|
||||
return render('gateways.braintree.ach.pay', $data);
|
||||
}
|
||||
@ -179,24 +181,4 @@ class ACH implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed($response->transaction->additionalProcessorResponse, $response->transaction->processorResponseCode);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.braintree.ach.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->braintree;
|
||||
$data['currency'] = $this->braintree->client->getCurrencyCode();
|
||||
$data['payment_method_id'] = GatewayType::BANK_TRANSFER;
|
||||
$data['amount'] = $this->braintree->payment_hash->data->amount_with_fee;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,8 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\BraintreePaymentDriver;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
|
||||
class CreditCard implements LivewireMethodInterface
|
||||
class CreditCard
|
||||
{
|
||||
/**
|
||||
* @var BraintreePaymentDriver
|
||||
@ -77,7 +76,6 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
$data['gateway'] = $this->braintree;
|
||||
$data['client_token'] = $this->braintree->gateway->clientToken()->generate();
|
||||
$data['threeds'] = $this->threeDParameters($data);
|
||||
@ -89,9 +87,6 @@ class CreditCard implements LivewireMethodInterface
|
||||
'merchantAccountId' => $this->braintree->company_gateway->getConfigField('merchantAccountId'),
|
||||
]);
|
||||
}
|
||||
=======
|
||||
$data = $this->paymentData($data);
|
||||
>>>>>>> new_payment_flow
|
||||
|
||||
return render('gateways.braintree.credit_card.pay', $data);
|
||||
}
|
||||
@ -283,32 +278,4 @@ class CreditCard implements LivewireMethodInterface
|
||||
return $this->braintree->processInternallyFailedPayment($this->braintree, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.braintree.credit_card.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->braintree;
|
||||
$data['client_token'] = $this->braintree->gateway->clientToken()->generate();
|
||||
$data['threeds'] = $this->threeDParameters($data);
|
||||
$data['threeds_enable'] = $this->braintree->company_gateway->getConfigField('threeds') ? "true" : "false";
|
||||
|
||||
if ($this->braintree->company_gateway->getConfigField('merchantAccountId')) {
|
||||
/** https://developer.paypal.com/braintree/docs/reference/request/client-token/generate#merchant_account_id */
|
||||
$data['client_token'] = $this->braintree->gateway->clientToken()->generate([
|
||||
'merchantAccountId' => $this->braintree->company_gateway->getConfigField('merchantAccountId'),
|
||||
]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,8 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\BraintreePaymentDriver;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
|
||||
class PayPal implements LivewireMethodInterface
|
||||
class PayPal
|
||||
{
|
||||
/**
|
||||
* @var BraintreePaymentDriver
|
||||
@ -46,7 +45,8 @@ class PayPal implements LivewireMethodInterface
|
||||
*/
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->braintree;
|
||||
$data['client_token'] = $this->braintree->gateway->clientToken()->generate();
|
||||
|
||||
return render('gateways.braintree.paypal.pay', $data);
|
||||
}
|
||||
@ -188,23 +188,4 @@ class PayPal implements LivewireMethodInterface
|
||||
return $this->braintree->processInternallyFailedPayment($this->braintree, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.braintree.paypal.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->braintree;
|
||||
$data['client_token'] = $this->braintree->gateway->clientToken()->generate();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ use App\Models\ClientGatewayToken;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\CheckoutComPaymentDriver;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Checkout\CheckoutApiException;
|
||||
@ -33,7 +32,7 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class CreditCard implements MethodInterface, LivewireMethodInterface
|
||||
class CreditCard implements MethodInterface
|
||||
{
|
||||
use Utilities;
|
||||
use MakesHash;
|
||||
@ -141,7 +140,7 @@ class CreditCard implements MethodInterface, LivewireMethodInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
public function paymentView($data)
|
||||
{
|
||||
$data['gateway'] = $this->checkout;
|
||||
$data['company_gateway'] = $this->checkout->company_gateway;
|
||||
@ -151,25 +150,9 @@ class CreditCard implements MethodInterface, LivewireMethodInterface
|
||||
$data['raw_value'] = $data['total']['amount_with_fee'];
|
||||
$data['customer_email'] = $this->checkout->client->present()->email();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function paymentView($data, $livewire = false)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
|
||||
if ($livewire) {
|
||||
return render('gateways.checkout.credit_card.pay_livewire', $data);
|
||||
}
|
||||
|
||||
return render('gateways.checkout.credit_card.pay', $data);
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.checkout.credit_card.livewire_pay';
|
||||
}
|
||||
|
||||
public function paymentResponse(PaymentResponseRequest $request)
|
||||
{
|
||||
$state = [
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
namespace App\PaymentDrivers;
|
||||
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use Exception;
|
||||
use App\Models\Company;
|
||||
use App\Models\Invoice;
|
||||
|
@ -17,11 +17,10 @@ use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\EwayPaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class CreditCard implements LivewireMethodInterface
|
||||
class CreditCard
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -103,18 +102,11 @@ class CreditCard implements LivewireMethodInterface
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
public function paymentView($data)
|
||||
{
|
||||
$data['gateway'] = $this->eway_driver;
|
||||
$data['public_api_key'] = $this->eway_driver->company_gateway->getConfigField('publicApiKey');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function paymentView($data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
|
||||
return render('gateways.eway.pay', $data);
|
||||
}
|
||||
|
||||
@ -284,8 +276,4 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
return $payment;
|
||||
}
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.eway.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,11 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\FortePaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ACH implements LivewireMethodInterface
|
||||
class ACH
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -80,8 +79,10 @@ class ACH implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data);
|
||||
$this->forte->payment_hash->save();
|
||||
|
||||
$data['gateway'] = $this->forte;
|
||||
return render('gateways.forte.ach.pay', $data);
|
||||
}
|
||||
|
||||
@ -174,25 +175,4 @@ class ACH implements LivewireMethodInterface
|
||||
return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.forte.ach.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data);
|
||||
$this->forte->payment_hash->save();
|
||||
|
||||
$data['gateway'] = $this->forte;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,11 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\FortePaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class CreditCard implements LivewireMethodInterface
|
||||
class CreditCard
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -158,8 +157,10 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data);
|
||||
$this->forte->payment_hash->save();
|
||||
|
||||
$data['gateway'] = $this->forte;
|
||||
return render('gateways.forte.credit_card.pay', $data);
|
||||
}
|
||||
|
||||
@ -286,25 +287,4 @@ class CreditCard implements LivewireMethodInterface
|
||||
return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.forte.credit_card.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data);
|
||||
$this->forte->payment_hash->save();
|
||||
|
||||
$data['gateway'] = $this->forte;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -32,7 +31,7 @@ use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
|
||||
//@deprecated
|
||||
class ACH implements MethodInterface, LivewireMethodInterface
|
||||
class ACH implements MethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -147,7 +146,9 @@ class ACH implements MethodInterface, LivewireMethodInterface
|
||||
*/
|
||||
public function paymentView(array $data): View
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->go_cardless;
|
||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||
|
||||
return render('gateways.gocardless.ach.pay', $data);
|
||||
}
|
||||
@ -256,23 +257,4 @@ class ACH implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.gocardless.ach.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->go_cardless;
|
||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -30,7 +29,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class DirectDebit implements MethodInterface, LivewireMethodInterface
|
||||
class DirectDebit implements MethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -219,7 +218,9 @@ class DirectDebit implements MethodInterface, LivewireMethodInterface
|
||||
*/
|
||||
public function paymentView(array $data): View
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->go_cardless;
|
||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||
|
||||
return render('gateways.gocardless.direct_debit.pay', $data);
|
||||
}
|
||||
@ -329,24 +330,4 @@ class DirectDebit implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.gocardless.direct_debit.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->go_cardless;
|
||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,13 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InstantBankPay implements MethodInterface, LivewireMethodInterface
|
||||
class InstantBankPay implements MethodInterface
|
||||
{
|
||||
protected GoCardlessPaymentDriver $go_cardless;
|
||||
|
||||
@ -195,8 +194,9 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface
|
||||
* Process unsuccessful payments for Direct Debit.
|
||||
*
|
||||
* @param ResourcesPayment $payment
|
||||
* @return never
|
||||
*/
|
||||
public function processUnsuccessfulPayment(\GoCardlessPro\Resources\Payment $payment): void
|
||||
public function processUnsuccessfulPayment(\GoCardlessPro\Resources\Payment $payment)
|
||||
{
|
||||
PaymentFailureMailer::dispatch($this->go_cardless->client, $payment->status, $this->go_cardless->client->company, $this->go_cardless->payment_hash->data->amount_with_fee);
|
||||
|
||||
@ -221,24 +221,4 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface
|
||||
$this->go_cardless->client->company,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
// not supported, this is offsite payment method.
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->paymentView($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -30,7 +29,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SEPA implements MethodInterface, LivewireMethodInterface
|
||||
class SEPA implements MethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -146,7 +145,9 @@ class SEPA implements MethodInterface, LivewireMethodInterface
|
||||
*/
|
||||
public function paymentView(array $data): View
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->go_cardless;
|
||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||
|
||||
return render('gateways.gocardless.sepa.pay', $data);
|
||||
}
|
||||
@ -256,24 +257,4 @@ class SEPA implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.gocardless.sepa.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->go_cardless;
|
||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,13 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\MolliePaymentDriver;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class Bancontact implements MethodInterface, LivewireMethodInterface
|
||||
class Bancontact implements MethodInterface
|
||||
{
|
||||
protected MolliePaymentDriver $mollie;
|
||||
|
||||
@ -210,24 +209,4 @@ class Bancontact implements MethodInterface, LivewireMethodInterface
|
||||
{
|
||||
return $this->processSuccessfulPayment($payment, 'open');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
// Doesn't support, it's offsite payment method.
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->paymentView($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\MolliePaymentDriver;
|
||||
use Exception;
|
||||
@ -29,7 +28,7 @@ use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Mollie\Api\Resources\Payment as ResourcesPayment;
|
||||
|
||||
class BankTransfer implements MethodInterface, LivewireMethodInterface
|
||||
class BankTransfer implements MethodInterface
|
||||
{
|
||||
protected MolliePaymentDriver $mollie;
|
||||
|
||||
@ -207,24 +206,4 @@ class BankTransfer implements MethodInterface, LivewireMethodInterface
|
||||
{
|
||||
return $this->processSuccessfulPayment($payment, 'open');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
// Doesn't support, it's offsite payment method.
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->paymentView($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,12 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\MolliePaymentDriver;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class CreditCard implements LivewireMethodInterface
|
||||
class CreditCard
|
||||
{
|
||||
/**
|
||||
* @var MolliePaymentDriver
|
||||
@ -38,7 +37,7 @@ class CreditCard implements LivewireMethodInterface
|
||||
*/
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->mollie;
|
||||
|
||||
return render('gateways.mollie.credit_card.pay', $data);
|
||||
}
|
||||
@ -258,22 +257,4 @@ class CreditCard implements LivewireMethodInterface
|
||||
{
|
||||
return redirect()->route('client.payment_methods.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.mollie.credit_card.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->mollie;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,13 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\MolliePaymentDriver;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class IDEAL implements MethodInterface, LivewireMethodInterface
|
||||
class IDEAL implements MethodInterface
|
||||
{
|
||||
protected MolliePaymentDriver $mollie;
|
||||
|
||||
@ -210,24 +209,4 @@ class IDEAL implements MethodInterface, LivewireMethodInterface
|
||||
{
|
||||
return $this->processSuccessfulPayment($payment, 'open');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
// Doesn't support, it's offsite payment method.
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->paymentView($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,13 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\MolliePaymentDriver;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class KBC implements MethodInterface, LivewireMethodInterface
|
||||
class KBC implements MethodInterface
|
||||
{
|
||||
protected MolliePaymentDriver $mollie;
|
||||
|
||||
@ -194,24 +193,4 @@ class KBC implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
return redirect()->route('client.payments.show', ['payment' => $this->mollie->encodePrimaryKey($payment_record->id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
// Doesn't support, it's offsite payment method.
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->paymentView($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,12 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\PayFastPaymentDriver;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreditCard implements LivewireMethodInterface
|
||||
class CreditCard
|
||||
{
|
||||
public $payfast;
|
||||
|
||||
@ -159,9 +158,24 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
public function paymentView($data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$payfast_data = [
|
||||
'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'),
|
||||
'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'),
|
||||
'return_url' => route('client.payments.index'),
|
||||
'cancel_url' => route('client.payment_methods.index'),
|
||||
'notify_url' => $this->payfast->genericWebhookUrl(),
|
||||
'm_payment_id' => $data['payment_hash'],
|
||||
'amount' => $data['amount_with_fee'],
|
||||
'item_name' => 'purchase',
|
||||
'item_description' => ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number'),
|
||||
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
|
||||
];
|
||||
|
||||
return render('gateways.payfast.pay', array_merge($data));
|
||||
$payfast_data['signature'] = $this->payfast->generateSignature($payfast_data);
|
||||
$payfast_data['gateway'] = $this->payfast;
|
||||
$payfast_data['payment_endpoint_url'] = $this->payfast->endpointUrl();
|
||||
|
||||
return render('gateways.payfast.pay', array_merge($data, $payfast_data));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -249,36 +263,4 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.payfast.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$payfast_data = [
|
||||
'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'),
|
||||
'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'),
|
||||
'return_url' => route('client.payments.index'),
|
||||
'cancel_url' => route('client.payment_methods.index'),
|
||||
'notify_url' => $this->payfast->genericWebhookUrl(),
|
||||
'm_payment_id' => $data['payment_hash'],
|
||||
'amount' => $data['amount_with_fee'],
|
||||
'item_name' => 'purchase',
|
||||
'item_description' => ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number'),
|
||||
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
|
||||
];
|
||||
|
||||
$payfast_data['signature'] = $this->payfast->generateSignature($payfast_data);
|
||||
$payfast_data['gateway'] = $this->payfast;
|
||||
$payfast_data['payment_endpoint_url'] = $this->payfast->endpointUrl();
|
||||
|
||||
return array_merge($data, $payfast_data);
|
||||
}
|
||||
}
|
||||
|
@ -85,13 +85,30 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
||||
*/
|
||||
public function processPaymentView($data)
|
||||
{
|
||||
$data = $this->processPaymentViewData($data);
|
||||
|
||||
$this->init()->checkPaymentsReceivable();
|
||||
|
||||
$data['gateway'] = $this;
|
||||
$this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['total']['amount_with_fee']]);
|
||||
$this->payment_hash->save();
|
||||
|
||||
$data['client_id'] = config('ninja.paypal.client_id');
|
||||
$data['token'] = $this->getClientToken();
|
||||
$data['order_id'] = $this->createOrder($data);
|
||||
$data['funding_source'] = $this->paypal_payment_method;
|
||||
$data['gateway_type_id'] = $this->gateway_type_id;
|
||||
$data['merchantId'] = $this->company_gateway->getConfigField('merchantId');
|
||||
$data['currency'] = $this->client->currency()->code;
|
||||
$data['guid'] = $this->risk_guid;
|
||||
$data['identifier'] = "s:INN_".$this->company_gateway->getConfigField('merchantId')."_CHCK";
|
||||
$data['pp_client_reference'] = $this->getClientHash();
|
||||
|
||||
if($this->gateway_type_id == 29) {
|
||||
return render('gateways.paypal.ppcp.card', $data);
|
||||
} else {
|
||||
return render('gateways.paypal.ppcp.pay', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -463,40 +480,7 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
||||
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
|
||||
|
||||
=======
|
||||
public function processPaymentViewData(array $data): array
|
||||
{
|
||||
$this->init()->checkPaymentsReceivable();
|
||||
|
||||
$data['gateway'] = $this;
|
||||
$this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['total']['amount_with_fee']]);
|
||||
$this->payment_hash->save();
|
||||
|
||||
$data['client_id'] = config('ninja.paypal.client_id');
|
||||
$data['token'] = $this->getClientToken();
|
||||
$data['order_id'] = $this->createOrder($data);
|
||||
$data['funding_source'] = $this->paypal_payment_method;
|
||||
$data['gateway_type_id'] = $this->gateway_type_id;
|
||||
$data['merchantId'] = $this->company_gateway->getConfigField('merchantId');
|
||||
$data['currency'] = $this->client->currency()->code;
|
||||
$data['guid'] = $this->risk_guid;
|
||||
$data['identifier'] = "s:INN_".$this->company_gateway->getConfigField('merchantId')."_CHCK";
|
||||
$data['pp_client_reference'] = $this->getClientHash();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
if ($this->gateway_type_id == 29) {
|
||||
return 'gateways.paypal.ppcp.card_livewire';
|
||||
}
|
||||
|
||||
return 'gateways.paypal.ppcp.pay_livewire';
|
||||
}
|
||||
>>>>>>> new_payment_flow
|
||||
}
|
||||
|
@ -31,13 +31,30 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||
|
||||
public function processPaymentView($data)
|
||||
{
|
||||
$data = $this->processPaymentViewData($data);
|
||||
|
||||
$this->init();
|
||||
|
||||
$data['gateway'] = $this;
|
||||
|
||||
$this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['total']['amount_with_fee']]);
|
||||
$this->payment_hash->save();
|
||||
|
||||
$data['client_id'] = $this->company_gateway->getConfigField('clientId');
|
||||
$data['token'] = $this->getClientToken();
|
||||
$data['order_id'] = $this->createOrder($data);
|
||||
$data['funding_source'] = $this->paypal_payment_method;
|
||||
$data['gateway_type_id'] = $this->gateway_type_id;
|
||||
$data['currency'] = $this->client->currency()->code;
|
||||
$data['guid'] = $this->risk_guid;
|
||||
$data['identifier'] = "s:INN_ACDC_CHCK";
|
||||
$data['pp_client_reference'] = $this->getClientHash();
|
||||
|
||||
if($this->gateway_type_id == 29) {
|
||||
return render('gateways.paypal.ppcp.card', $data);
|
||||
} else {
|
||||
return render('gateways.paypal.pay', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -417,35 +434,4 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||
SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company);
|
||||
|
||||
}
|
||||
|
||||
public function processPaymentViewData(array $data): array
|
||||
{
|
||||
$this->init();
|
||||
|
||||
$data['gateway'] = $this;
|
||||
|
||||
$this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['total']['amount_with_fee']]);
|
||||
$this->payment_hash->save();
|
||||
|
||||
$data['client_id'] = $this->company_gateway->getConfigField('clientId');
|
||||
$data['token'] = $this->getClientToken();
|
||||
$data['order_id'] = $this->createOrder($data);
|
||||
$data['funding_source'] = $this->paypal_payment_method;
|
||||
$data['gateway_type_id'] = $this->gateway_type_id;
|
||||
$data['currency'] = $this->client->currency()->code;
|
||||
$data['guid'] = $this->risk_guid;
|
||||
$data['identifier'] = "s:INN_ACDC_CHCK";
|
||||
$data['pp_client_reference'] = $this->getClientHash();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
if ($this->gateway_type_id == 29) {
|
||||
return 'gateways.paypal.ppcp.card_livewire';
|
||||
}
|
||||
|
||||
return 'gateways.paypal.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,12 @@ use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\PaytracePaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreditCard implements LivewireMethodInterface
|
||||
class CreditCard
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -37,7 +36,8 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
public function authorizeView($data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['client_key'] = $this->paytrace->getAuthToken();
|
||||
$data['gateway'] = $this->paytrace;
|
||||
|
||||
return render('gateways.paytrace.authorize', $data);
|
||||
}
|
||||
@ -240,23 +240,4 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
return $this->paytrace->processUnsuccessfulTransaction($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.paytrace.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['client_key'] = $this->paytrace->getAuthToken();
|
||||
$data['gateway'] = $this->paytrace;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\RazorpayPaymentDriver;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@ -27,7 +26,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Razorpay\Api\Errors\SignatureVerificationError;
|
||||
|
||||
class Hosted implements MethodInterface, LivewireMethodInterface
|
||||
class Hosted implements MethodInterface
|
||||
{
|
||||
protected RazorpayPaymentDriver $razorpay;
|
||||
|
||||
@ -68,7 +67,23 @@ class Hosted implements MethodInterface, LivewireMethodInterface
|
||||
*/
|
||||
public function paymentView(array $data): View
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$order = $this->razorpay->gateway->order->create([
|
||||
'currency' => $this->razorpay->client->currency()->code,
|
||||
'amount' => $this->razorpay->convertToRazorpayAmount((float) $this->razorpay->payment_hash->data->amount_with_fee),
|
||||
]);
|
||||
|
||||
$this->razorpay->payment_hash->withData('order_id', $order->id);
|
||||
$this->razorpay->payment_hash->withData('order_amount', $order->amount);
|
||||
|
||||
$data['gateway'] = $this->razorpay;
|
||||
|
||||
$data['options'] = [
|
||||
'key' => $this->razorpay->company_gateway->getConfigField('apiKey'),
|
||||
'amount' => $this->razorpay->convertToRazorpayAmount((float) $this->razorpay->payment_hash->data->amount_with_fee),
|
||||
'currency' => $this->razorpay->client->currency()->code,
|
||||
'name' => $this->razorpay->company_gateway->company->present()->name(),
|
||||
'order_id' => $order->id,
|
||||
];
|
||||
|
||||
return render('gateways.razorpay.hosted.pay', $data);
|
||||
}
|
||||
@ -159,38 +174,4 @@ class Hosted implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.razorpay.hosted.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$order = $this->razorpay->gateway->order->create([
|
||||
'currency' => $this->razorpay->client->currency()->code,
|
||||
'amount' => $this->razorpay->convertToRazorpayAmount((float) $this->razorpay->payment_hash->data->amount_with_fee),
|
||||
]);
|
||||
|
||||
$this->razorpay->payment_hash->withData('order_id', $order->id);
|
||||
$this->razorpay->payment_hash->withData('order_amount', $order->amount);
|
||||
|
||||
$data['gateway'] = $this->razorpay;
|
||||
|
||||
$data['options'] = [
|
||||
'key' => $this->razorpay->company_gateway->getConfigField('apiKey'),
|
||||
'amount' => $this->razorpay->convertToRazorpayAmount((float) $this->razorpay->payment_hash->data->amount_with_fee),
|
||||
'currency' => $this->razorpay->client->currency()->code,
|
||||
'name' => $this->razorpay->company_gateway->company->present()->name(),
|
||||
'order_id' => $order->id,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\SquarePaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -30,7 +29,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Square\Http\ApiResponse;
|
||||
|
||||
class CreditCard implements MethodInterface, LivewireMethodInterface
|
||||
class CreditCard implements MethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -65,7 +64,10 @@ class CreditCard implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
public function paymentView($data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->square_driver;
|
||||
$data['amount'] = $this->square_driver->payment_hash->data->amount_with_fee;
|
||||
$data['currencyCode'] = $this->square_driver->client->getCurrencyCode();
|
||||
$data['square_contact'] = $this->buildClientObject();
|
||||
|
||||
return render('gateways.square.credit_card.pay', $data);
|
||||
}
|
||||
@ -236,24 +238,5 @@ class CreditCard implements MethodInterface, LivewireMethodInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.square.credit_card.pay_livewire';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->square_driver;
|
||||
$data['amount'] = $this->square_driver->payment_hash->data->amount_with_fee;
|
||||
$data['currencyCode'] = $this->square_driver->client->getCurrencyCode();
|
||||
$data['square_contact'] = $this->buildClientObject();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Exception;
|
||||
@ -36,7 +35,7 @@ use Stripe\Exception\InvalidRequestException;
|
||||
use Stripe\Exception\RateLimitException;
|
||||
use Stripe\PaymentIntent;
|
||||
|
||||
class ACH implements LivewireMethodInterface
|
||||
class ACH
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -200,7 +199,47 @@ class ACH implements LivewireMethodInterface
|
||||
*/
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$this->paymentData($data);
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['currency'] = $this->stripe->client->getCurrencyCode();
|
||||
$data['payment_method_id'] = GatewayType::BANK_TRANSFER;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer();
|
||||
$data['amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
|
||||
$description = $this->stripe->getDescription(false);
|
||||
|
||||
$intent = false;
|
||||
|
||||
if (count($data['tokens']) == 1) {
|
||||
|
||||
$token = $data['tokens'][0];
|
||||
|
||||
$meta = $token->meta;
|
||||
|
||||
if(isset($meta->state) && $meta->state == 'unauthorized') {
|
||||
return redirect()->route('client.payment_methods.show', $token->hashed_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($data['tokens']) == 0) {
|
||||
$intent =
|
||||
$this->stripe->createPaymentIntent(
|
||||
[
|
||||
'amount' => $data['amount'],
|
||||
'currency' => $data['currency'],
|
||||
'setup_future_usage' => 'off_session',
|
||||
'customer' => $data['customer']->id,
|
||||
'payment_method_types' => ['us_bank_account'],
|
||||
'description' => $description,
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::BANK_TRANSFER,
|
||||
],
|
||||
'statement_descriptor' => $this->stripe->getStatementDescriptor(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$data['client_secret'] = $intent ? $intent->client_secret : false;
|
||||
|
||||
return render('gateways.stripe.ach.pay', $data);
|
||||
}
|
||||
@ -589,56 +628,4 @@ class ACH implements LivewireMethodInterface
|
||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.ach.pay_livewire';
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['currency'] = $this->stripe->client->getCurrencyCode();
|
||||
$data['payment_method_id'] = GatewayType::BANK_TRANSFER;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer();
|
||||
$data['amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
|
||||
$description = $this->stripe->getDescription(false);
|
||||
|
||||
$intent = false;
|
||||
|
||||
if (count($data['tokens']) == 1) {
|
||||
|
||||
$token = $data['tokens'][0];
|
||||
|
||||
$meta = $token->meta;
|
||||
|
||||
if(isset($meta->state) && $meta->state == 'unauthorized') {
|
||||
return redirect()->route('client.payment_methods.show', $token->hashed_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($data['tokens']) == 0) {
|
||||
$intent =
|
||||
$this->stripe->createPaymentIntent(
|
||||
[
|
||||
'amount' => $data['amount'],
|
||||
'currency' => $data['currency'],
|
||||
'setup_future_usage' => 'off_session',
|
||||
'customer' => $data['customer']->id,
|
||||
'payment_method_types' => ['us_bank_account'],
|
||||
'description' => $description,
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::BANK_TRANSFER,
|
||||
],
|
||||
'statement_descriptor' => $this->stripe->getStatementDescriptor(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$data['client_secret'] = $intent ? $intent->client_secret : false;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ use App\Models\SystemLog;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
@ -30,7 +29,7 @@ use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use Stripe\PaymentIntent;
|
||||
|
||||
class ACSS implements LivewireMethodInterface
|
||||
class ACSS
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -128,7 +127,7 @@ class ACSS implements LivewireMethodInterface
|
||||
$this->stripe->setClient($hash->fee_invoice->client);
|
||||
$this->stripe->setPaymentMethod(GatewayType::ACSS);
|
||||
|
||||
return $this->paymentView($data);
|
||||
return $this->continuePayment($data);
|
||||
}
|
||||
|
||||
return redirect()->route('client.payment_methods.show', $client_gateway_token->hashed_id);
|
||||
@ -162,15 +161,36 @@ class ACSS implements LivewireMethodInterface
|
||||
return $intent;
|
||||
}
|
||||
|
||||
public function paymentData(array $data)
|
||||
/**
|
||||
* Payment view for ACSS
|
||||
*
|
||||
* Determines if any payment tokens are available and if not, generates a mandate
|
||||
*
|
||||
* @param array $data
|
||||
|
||||
*/
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
|
||||
if(count($data['tokens']) == 0) {
|
||||
$hash = Str::random(32);
|
||||
|
||||
Cache::put($hash, $data, 3600);
|
||||
|
||||
$data['post_auth_response'] = $hash;
|
||||
$data['needs_mandate_generate'] = true;
|
||||
|
||||
return $this->generateMandate($data);
|
||||
}
|
||||
|
||||
return $this->continuePayment($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a payment Mandate for ACSS
|
||||
*
|
||||
* @param array $data
|
||||
|
||||
*/
|
||||
private function generateMandate(array $data)
|
||||
{
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['company_gateway'] = $this->stripe->company_gateway;
|
||||
@ -196,9 +216,18 @@ class ACSS implements LivewireMethodInterface
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
return $data;
|
||||
return render('gateways.stripe.acss.authorize', array_merge($data));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Continues the payment flow after a Mandate has been successfully generated
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
private function continuePayment(array $data)
|
||||
{
|
||||
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
@ -211,25 +240,6 @@ class ACSS implements LivewireMethodInterface
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment view for ACSS
|
||||
*
|
||||
* Determines if any payment tokens are available and if not, generates a mandate
|
||||
*
|
||||
* @param array $data
|
||||
|
||||
*/
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
|
||||
if (array_key_exists('needs_mandate_generate', $data)) {
|
||||
return render('gateways.stripe.acss.authorize', array_merge($data));
|
||||
}
|
||||
|
||||
return render('gateways.stripe.acss.pay', $data);
|
||||
}
|
||||
|
||||
@ -390,13 +400,4 @@ class ACSS implements LivewireMethodInterface
|
||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
if (array_key_exists('needs_mandate_generate', $data)) {
|
||||
return 'gateways.stripe.acss.authorize_livewire';
|
||||
}
|
||||
|
||||
return 'gateways.stripe.acss.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,12 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Stripe\Jobs\UpdateCustomer;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Utils\Number;
|
||||
use Stripe\Checkout\Session;
|
||||
|
||||
class BACS implements LivewireMethodInterface
|
||||
class BACS
|
||||
{
|
||||
public $stripe;
|
||||
|
||||
@ -70,7 +69,9 @@ class BACS implements LivewireMethodInterface
|
||||
}
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['amount'] = $data['total']['amount_with_fee'];
|
||||
$data['payment_hash'] = $this->stripe->payment_hash->hash;
|
||||
|
||||
return render('gateways.stripe.bacs.pay', $data);
|
||||
}
|
||||
@ -186,18 +187,4 @@ class BACS implements LivewireMethodInterface
|
||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['amount'] = $data['total']['amount_with_fee'];
|
||||
$data['payment_hash'] = $this->stripe->payment_hash->hash;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.bacs.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class BECS implements LivewireMethodInterface
|
||||
class BECS
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -40,7 +39,33 @@ class BECS implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['payment_method_id'] = GatewayType::BECS;
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
$data['payment_hash'] = $this->stripe->payment_hash->hash;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => $this->stripe->client->currency()->code,
|
||||
'payment_method_types' => ['au_becs_debit'],
|
||||
'setup_future_usage' => 'off_session',
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::BECS,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.becs.pay', $data);
|
||||
}
|
||||
@ -136,42 +161,4 @@ class BECS implements LivewireMethodInterface
|
||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['payment_method_id'] = GatewayType::BECS;
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
$data['payment_hash'] = $this->stripe->payment_hash->hash;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => $this->stripe->client->currency()->code,
|
||||
'payment_method_types' => ['au_becs_debit'],
|
||||
'setup_future_usage' => 'off_session',
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::BECS,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.becs.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class Bancontact implements LivewireMethodInterface
|
||||
class Bancontact
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -38,7 +37,32 @@ class Bancontact implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['bancontact'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::BANCONTACT,
|
||||
],
|
||||
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.bancontact.pay', $data);
|
||||
}
|
||||
@ -119,41 +143,4 @@ class Bancontact implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['bancontact'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::BANCONTACT,
|
||||
],
|
||||
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.bancontact.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,12 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Utils\Number;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Stripe\PaymentIntent;
|
||||
|
||||
class BankTransfer implements LivewireMethodInterface
|
||||
class BankTransfer
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
@ -39,7 +38,37 @@ class BankTransfer implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()),
|
||||
'currency' => $this->stripe->client->currency()->code,
|
||||
'customer' => $this->stripe->findOrCreateCustomer()->id,
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'payment_method_types' => ['customer_balance'],
|
||||
'payment_method_data' => [
|
||||
'type' => 'customer_balance',
|
||||
],
|
||||
'payment_method_options' => [
|
||||
'customer_balance' => [
|
||||
'funding_type' => 'bank_transfer',
|
||||
'bank_transfer' => $this->resolveBankType()
|
||||
],
|
||||
],
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::DIRECT_DEBIT,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency())]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
$data = [];
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['client_secret'] = $intent ? $intent->client_secret : false;
|
||||
|
||||
return render('gateways.stripe.bank_transfer.pay', $data);
|
||||
}
|
||||
@ -288,46 +317,4 @@ class BankTransfer implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()),
|
||||
'currency' => $this->stripe->client->currency()->code,
|
||||
'customer' => $this->stripe->findOrCreateCustomer()->id,
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'payment_method_types' => ['customer_balance'],
|
||||
'payment_method_data' => [
|
||||
'type' => 'customer_balance',
|
||||
],
|
||||
'payment_method_options' => [
|
||||
'customer_balance' => [
|
||||
'funding_type' => 'bank_transfer',
|
||||
'bank_transfer' => $this->resolveBankType()
|
||||
],
|
||||
],
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::DIRECT_DEBIT,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency())]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
$data = [];
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['client_secret'] = $intent ? $intent->client_secret : false;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.bank_transfer.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Utils\Ninja;
|
||||
@ -30,7 +29,7 @@ use Stripe\ApplePayDomain;
|
||||
use Stripe\Exception\ApiErrorException;
|
||||
use Stripe\PaymentIntent;
|
||||
|
||||
class BrowserPay implements MethodInterface, LivewireMethodInterface
|
||||
class BrowserPay implements MethodInterface
|
||||
{
|
||||
protected StripePaymentDriver $stripe;
|
||||
|
||||
@ -65,8 +64,7 @@ class BrowserPay implements MethodInterface, LivewireMethodInterface
|
||||
return redirect()->route('client.payment_methods.index');
|
||||
}
|
||||
|
||||
|
||||
public function paymentData(array $data): array
|
||||
public function paymentView(array $data): View
|
||||
{
|
||||
$payment_intent_data = [
|
||||
'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()),
|
||||
@ -95,13 +93,6 @@ class BrowserPay implements MethodInterface, LivewireMethodInterface
|
||||
'requestPayerEmail' => true,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function paymentView(array $data): View
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
|
||||
return render('gateways.stripe.browser_pay.pay', $data);
|
||||
}
|
||||
|
||||
@ -240,9 +231,4 @@ class BrowserPay implements MethodInterface, LivewireMethodInterface
|
||||
|
||||
return str_replace(['https://', '/public'], '', $domain);
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.browser_pay.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,12 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Stripe\Jobs\UpdateCustomer;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use Stripe\PaymentIntent;
|
||||
use Stripe\PaymentMethod;
|
||||
|
||||
class CreditCard implements LivewireMethodInterface
|
||||
class CreditCard
|
||||
{
|
||||
public $stripe;
|
||||
|
||||
@ -58,7 +57,7 @@ class CreditCard implements LivewireMethodInterface
|
||||
return redirect()->route('client.payment_methods.index');
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$description = $this->stripe->getDescription(false);
|
||||
|
||||
@ -78,21 +77,9 @@ class CreditCard implements LivewireMethodInterface
|
||||
$data['intent'] = $this->stripe->createPaymentIntent($payment_intent_data);
|
||||
$data['gateway'] = $this->stripe;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
|
||||
return render('gateways.stripe.credit_card.pay', $data);
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.credit_card.pay_livewire';
|
||||
}
|
||||
|
||||
public function paymentResponse(PaymentResponseRequest $request)
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
@ -18,10 +18,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class EPS implements LivewireMethodInterface
|
||||
class EPS
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -38,7 +37,31 @@ class EPS implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['eps'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::EPS,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.eps.pay', $data);
|
||||
}
|
||||
@ -119,40 +142,4 @@ class EPS implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['eps'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::EPS,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.eps.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class FPX implements LivewireMethodInterface
|
||||
class FPX
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -39,7 +38,31 @@ class FPX implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => $this->stripe->client->getCurrencyCode(),
|
||||
'payment_method_types' => ['fpx'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::FPX,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.fpx.pay', $data);
|
||||
}
|
||||
@ -120,40 +143,4 @@ class FPX implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 400);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => $this->stripe->client->getCurrencyCode(),
|
||||
'payment_method_types' => ['fpx'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::FPX,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.fpx.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class GIROPAY implements LivewireMethodInterface
|
||||
class GIROPAY
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -38,7 +37,31 @@ class GIROPAY implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['giropay'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::GIROPAY,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.giropay.pay', $data);
|
||||
}
|
||||
@ -119,40 +142,4 @@ class GIROPAY implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['giropay'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::GIROPAY,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.giropay.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class Klarna implements LivewireMethodInterface
|
||||
class Klarna
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -38,7 +37,33 @@ class Klarna implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$description = $this->stripe->getDescription(false);
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => $this->stripe->client->getCurrencyCode(),
|
||||
'payment_method_types' => ['klarna'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $description,
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::KLARNA,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.klarna.pay', $data);
|
||||
}
|
||||
@ -117,42 +142,4 @@ class Klarna implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed(ctrans('texts.gateway_error'), 500);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$description = $this->stripe->getDescription(false);
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => $this->stripe->client->getCurrencyCode(),
|
||||
'payment_method_types' => ['klarna'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $description,
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::KLARNA,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.klarna.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class PRZELEWY24 implements LivewireMethodInterface
|
||||
class PRZELEWY24
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -38,7 +37,31 @@ class PRZELEWY24 implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['p24'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::PRZELEWY24,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.przelewy24.pay', $data);
|
||||
}
|
||||
@ -119,40 +142,4 @@ class PRZELEWY24 implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['p24'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::PRZELEWY24,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.przelewy24.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class SEPA implements LivewireMethodInterface
|
||||
class SEPA
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -48,7 +47,33 @@ class SEPA implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['payment_method_id'] = GatewayType::SEPA;
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
$data['payment_hash'] = $this->stripe->payment_hash->hash;
|
||||
|
||||
$intent_data = [
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['sepa_debit'],
|
||||
'setup_future_usage' => 'off_session',
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::SEPA,
|
||||
],
|
||||
];
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create($intent_data, array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.sepa.pay', $data);
|
||||
}
|
||||
@ -151,42 +176,4 @@ class SEPA implements LivewireMethodInterface
|
||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['payment_method_id'] = GatewayType::SEPA;
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
$data['payment_hash'] = $this->stripe->payment_hash->hash;
|
||||
|
||||
$intent_data = [
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['sepa_debit'],
|
||||
'setup_future_usage' => 'off_session',
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::SEPA,
|
||||
],
|
||||
];
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create($intent_data, array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.sepa.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class SOFORT implements LivewireMethodInterface
|
||||
class SOFORT
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -38,7 +37,31 @@ class SOFORT implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['sofort'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::SOFORT,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.sofort.pay', $data);
|
||||
}
|
||||
@ -114,40 +137,4 @@ class SOFORT implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['sofort'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::SOFORT,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.sofort.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,9 @@ use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
|
||||
class iDeal implements LivewireMethodInterface
|
||||
class iDeal
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public StripePaymentDriver $stripe;
|
||||
@ -38,7 +37,31 @@ class iDeal implements LivewireMethodInterface
|
||||
|
||||
public function paymentView(array $data)
|
||||
{
|
||||
$data = $this->paymentData($data);
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['ideal'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::IDEAL,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return render('gateways.stripe.ideal.pay', $data);
|
||||
}
|
||||
@ -119,40 +142,4 @@ class iDeal implements LivewireMethodInterface
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
public function paymentData(array $data): array
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
$data['return_url'] = $this->buildReturnUrl();
|
||||
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
|
||||
$data['client'] = $this->stripe->client;
|
||||
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
|
||||
$data['country'] = $this->stripe->client->country->iso_3166_2;
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => 'eur',
|
||||
'payment_method_types' => ['ideal'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->getDescription(false),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::IDEAL,
|
||||
],
|
||||
], array_merge($this->stripe->stripe_connect_auth, ['idempotency_key' => uniqid("st", true)]));
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
||||
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
$this->stripe->payment_hash->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
return 'gateways.stripe.ideal.pay_livewire';
|
||||
}
|
||||
}
|
||||
|
@ -12,47 +12,6 @@
|
||||
|
||||
namespace App\PaymentDrivers;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\Exceptions\StripeConnectFailure;
|
||||
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\PaymentDrivers\Stripe\ACH;
|
||||
use App\PaymentDrivers\Stripe\ACSS;
|
||||
use App\PaymentDrivers\Stripe\Alipay;
|
||||
use App\PaymentDrivers\Stripe\BACS;
|
||||
use App\PaymentDrivers\Stripe\Bancontact;
|
||||
use App\PaymentDrivers\Stripe\BankTransfer;
|
||||
use App\PaymentDrivers\Stripe\BECS;
|
||||
use App\PaymentDrivers\Stripe\BrowserPay;
|
||||
use App\PaymentDrivers\Stripe\Charge;
|
||||
use App\PaymentDrivers\Stripe\Connect\Verify;
|
||||
use App\PaymentDrivers\Stripe\CreditCard;
|
||||
use App\PaymentDrivers\Stripe\EPS;
|
||||
use App\PaymentDrivers\Stripe\FPX;
|
||||
use App\PaymentDrivers\Stripe\GIROPAY;
|
||||
use App\PaymentDrivers\Stripe\iDeal;
|
||||
use App\PaymentDrivers\Stripe\ImportCustomers;
|
||||
use App\PaymentDrivers\Stripe\Jobs\PaymentIntentFailureWebhook;
|
||||
use App\PaymentDrivers\Stripe\Jobs\PaymentIntentPartiallyFundedWebhook;
|
||||
use App\PaymentDrivers\Stripe\Jobs\PaymentIntentProcessingWebhook;
|
||||
use App\PaymentDrivers\Stripe\Jobs\PaymentIntentWebhook;
|
||||
use App\PaymentDrivers\Stripe\Klarna;
|
||||
use App\PaymentDrivers\Stripe\PRZELEWY24;
|
||||
use App\PaymentDrivers\Stripe\SEPA;
|
||||
use App\PaymentDrivers\Stripe\SOFORT;
|
||||
use App\PaymentDrivers\Stripe\Utilities;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
>>>>>>> new_payment_flow
|
||||
use Exception;
|
||||
use Stripe\Stripe;
|
||||
use Stripe\Account;
|
||||
@ -460,33 +419,6 @@ class StripePaymentDriver extends BaseDriver
|
||||
return $this->payment_method->paymentView($data);
|
||||
}
|
||||
|
||||
public function processPaymentViewData(array $data): array
|
||||
{
|
||||
$data = $this->payment_method->paymentData($data);
|
||||
|
||||
$data['stripe_account_id'] = $this->company_gateway->getConfigField('account_id');
|
||||
|
||||
if (array_key_exists('intent', $data)) {
|
||||
$data['client_secret'] = $data['intent']->client_secret;
|
||||
}
|
||||
|
||||
unset($data['intent']);
|
||||
|
||||
$token_billing_string = 'true';
|
||||
|
||||
if($this->company_gateway->token_billing == 'off' || $this->company_gateway->token_billing == 'optin') {
|
||||
$token_billing_string = 'false';
|
||||
}
|
||||
|
||||
if (isset($data['pre_payment']) && $data['pre_payment'] == '1' && isset($data['is_recurring']) && $data['is_recurring'] == '1') {
|
||||
$token_billing_string = 'true';
|
||||
}
|
||||
|
||||
$data['token_billing_string'] = $token_billing_string;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function processPaymentResponse($request)
|
||||
{
|
||||
return $this->payment_method->paymentResponse($request);
|
||||
|
@ -4,9 +4,9 @@ namespace App\Repositories\Import\Quickbooks\Contracts;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface RepositoryInterface {
|
||||
|
||||
function get(int $max = 100): Collection;
|
||||
function all(): Collection;
|
||||
function count(): int;
|
||||
interface RepositoryInterface
|
||||
{
|
||||
public function get(int $max = 100): Collection;
|
||||
public function all(): Collection;
|
||||
public function count(): int;
|
||||
}
|
@ -9,7 +9,6 @@ use App\Repositories\Import\Quickbooks\Transformers\Transformer as QuickbooksTra
|
||||
|
||||
abstract class Repository implements RepositoryInterface
|
||||
{
|
||||
|
||||
protected string $entity;
|
||||
protected QuickbooksInterface $db;
|
||||
protected QuickbooksTransformer $transfomer;
|
||||
@ -20,7 +19,8 @@ abstract class Repository implements RepositoryInterface
|
||||
$this->transformer = $transfomer;
|
||||
}
|
||||
|
||||
public function count() : int {
|
||||
public function count(): int
|
||||
{
|
||||
return $this->db->totalRecords($this->entity);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,9 @@ class Transformer
|
||||
{
|
||||
public function transform(array $items, string $type): Collection
|
||||
{
|
||||
if(!method_exists($this, ($method = "transform{$type}s"))) throw new \InvalidArgumentException("Unknown type: $type");
|
||||
if(!method_exists($this, ($method = "transform{$type}s"))) {
|
||||
throw new \InvalidArgumentException("Unknown type: $type");
|
||||
}
|
||||
|
||||
return call_user_func([$this, $method], $items);
|
||||
}
|
||||
|
@ -46,8 +46,9 @@ class TaskRepository extends BaseRepository
|
||||
$this->new_task = false;
|
||||
}
|
||||
|
||||
if(!is_numeric($task->rate) && !isset($data['rate']))
|
||||
if(!is_numeric($task->rate) && !isset($data['rate'])) {
|
||||
$data['rate'] = 0;
|
||||
}
|
||||
|
||||
$task->fill($data);
|
||||
$task->saveQuietly();
|
||||
@ -118,13 +119,15 @@ class TaskRepository extends BaseRepository
|
||||
|
||||
$key_values = array_column($time_log, 0);
|
||||
|
||||
if(count($key_values) > 0)
|
||||
if(count($key_values) > 0) {
|
||||
array_multisort($key_values, SORT_ASC, $time_log);
|
||||
}
|
||||
|
||||
foreach($time_log as $key => $value) {
|
||||
|
||||
if(is_array($time_log[$key]) && count($time_log[$key]) >=2)
|
||||
if(is_array($time_log[$key]) && count($time_log[$key]) >= 2) {
|
||||
$time_log[$key][1] = $this->roundTimeLog($time_log[$key][0], $time_log[$key][1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -72,19 +72,20 @@ class ProcessBankRules extends AbstractService
|
||||
// $client.custom4
|
||||
private function matchCredit()
|
||||
{
|
||||
$match_set = [];
|
||||
|
||||
$this->credit_rules = $this->bank_transaction->company->credit_rules();
|
||||
|
||||
foreach ($this->credit_rules as $bank_transaction_rule)
|
||||
{
|
||||
foreach ($this->credit_rules as $bank_transaction_rule) {
|
||||
$match_set = [];
|
||||
|
||||
if (!is_array($bank_transaction_rule['rules'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($bank_transaction_rule['rules'] as $rule) {
|
||||
$rule_count = count($bank_transaction_rule['rules']);
|
||||
|
||||
foreach ($bank_transaction_rule['rules'] as $rule) {
|
||||
|
||||
$payments = Payment::query()
|
||||
->withTrashed()
|
||||
@ -93,41 +94,74 @@ class ProcessBankRules extends AbstractService
|
||||
->whereNull('transaction_id')
|
||||
->get();
|
||||
|
||||
match($rule['search_key']){
|
||||
'$payment.amount' => $results = $this->searchPaymentResource('amount', $rule),
|
||||
'$payment.transaction_reference' => $results = $this->searchPaymentResource('transaction_reference', $rule),
|
||||
'$payment.custom1' => $results = $this->searchPaymentResource('custom1', $rule),
|
||||
'$payment.custom2' => $results = $this->searchPaymentResource('custom2', $rule),
|
||||
'$payment.custom3' => $results = $this->searchPaymentResource('custom3', $rule),
|
||||
'$payment.custom4' => $results = $this->searchPaymentResource('custom4', $rule),
|
||||
'$invoice.amount' => $results = $this->searchInvoiceResource('amount', $rule),
|
||||
'$invoice.number' => $results = $this->searchInvoiceResource('number', $rule),
|
||||
'$invoice.po_number' => $results = $this->searchInvoiceResource('po_number', $rule),
|
||||
'$invoice.custom1' => $results = $this->searchInvoiceResource('custom1', $rule),
|
||||
'$invoice.custom2' => $results = $this->searchInvoiceResource('custom2', $rule),
|
||||
'$invoice.custom3' => $results = $this->searchInvoiceResource('custom3', $rule),
|
||||
'$invoice.custom4' => $results = $this->searchInvoiceResource('custom4', $rule),
|
||||
'$client.id_number' => $results = $this->searchClientResource('id_number', $rule),
|
||||
'$client.email' => $results = $this->searchClientResource('email', $rule),
|
||||
'$client.custom1' => $results = $this->searchClientResource('custom1', $rule),
|
||||
'$client.custom2' => $results = $this->searchClientResource('custom2', $rule),
|
||||
'$client.custom3' => $results = $this->searchClientResource('custom3', $rule),
|
||||
'$client.custom4' => $results = $this->searchClientResource('custom4', $rule),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function searchInvoiceResource(string $column, array $rule)
|
||||
{
|
||||
|
||||
return Invoice::query()
|
||||
$invoices = Invoice::query()
|
||||
->withTrashed()
|
||||
->where('company_id', $this->bank_transaction->company_id)
|
||||
->whereIn('status_id', [1,2,3])
|
||||
->where('is_deleted', 0)
|
||||
->when($rule['search_key'] == 'description', function ($q) use ($rule, $column){
|
||||
->get();
|
||||
|
||||
$results = [];
|
||||
|
||||
match($rule['search_key']) {
|
||||
'$payment.amount' => $results = [Payment::class, $this->searchPaymentResource('amount', $rule, $payments)],
|
||||
'$payment.transaction_reference' => $results = [Payment::class, $this->searchPaymentResource('transaction_reference', $rule, $payments)],
|
||||
'$payment.custom1' => $results = [Payment::class, $this->searchPaymentResource('custom1', $rule, $payments)],
|
||||
'$payment.custom2' => $results = [Payment::class, $this->searchPaymentResource('custom2', $rule, $payments)],
|
||||
'$payment.custom3' => $results = [Payment::class, $this->searchPaymentResource('custom3', $rule, $payments)],
|
||||
'$payment.custom4' => $results = [Payment::class, $this->searchPaymentResource('custom4', $rule, $payments)],
|
||||
'$invoice.amount' => $results = [Invoice::class, $this->searchInvoiceResource('amount', $rule, $invoices)],
|
||||
'$invoice.number' => $results = [Invoice::class, $this->searchInvoiceResource('number', $rule, $invoices)],
|
||||
'$invoice.po_number' => $results = [Invoice::class, $this->searchInvoiceResource('po_number', $rule, $invoices)],
|
||||
'$invoice.custom1' => $results = [Invoice::class, $this->searchInvoiceResource('custom1', $rule, $invoices)],
|
||||
'$invoice.custom2' => $results = [Invoice::class, $this->searchInvoiceResource('custom2', $rule, $invoices)],
|
||||
'$invoice.custom3' => $results = [Invoice::class, $this->searchInvoiceResource('custom3', $rule, $invoices)],
|
||||
'$invoice.custom4' => $results = [Invoice::class, $this->searchInvoiceResource('custom4', $rule, $invoices)],
|
||||
'$client.id_number' => $results = [Client::class, $this->searchClientResource('id_number', $rule, $invoices, $payments)],
|
||||
'$client.email' => $results = [Client::class, $this->searchClientResource('email', $rule, $invoices, $payments)],
|
||||
'$client.custom1' => $results = [Client::class, $this->searchClientResource('custom1', $rule, $invoices, $payments)],
|
||||
'$client.custom2' => $results = [Client::class, $this->searchClientResource('custom2', $rule, $invoices, $payments)],
|
||||
'$client.custom3' => $results = [Client::class, $this->searchClientResource('custom3', $rule, $invoices, $payments)],
|
||||
'$client.custom4' => $results = [Client::class, $this->searchClientResource('custom4', $rule, $invoices, $payments)],
|
||||
default => $results = [Client::class, [collect([]), Invoice::class]],
|
||||
};
|
||||
|
||||
if($results[0] == 'App\Models\Client') {
|
||||
$set = $results[1];
|
||||
$result_set = $set[0];
|
||||
$entity = $set[1];
|
||||
|
||||
if($result_set->count() > 0) {
|
||||
$match_set[] = [$entity, $result_set->pluck('id')];
|
||||
}
|
||||
|
||||
} elseif($results[1]->count() > 0) {
|
||||
$match_set[] = $results;
|
||||
}
|
||||
}
|
||||
|
||||
if (($bank_transaction_rule['matches_on_all'] && (count($match_set) == $rule_count)) || (!$bank_transaction_rule['matches_on_all'] && count($match_set) > 0)) {
|
||||
|
||||
$this->bank_transaction->vendor_id = $bank_transaction_rule->vendor_id;
|
||||
$this->bank_transaction->ninja_category_id = $bank_transaction_rule->category_id;
|
||||
$this->bank_transaction->status_id = BankTransaction::STATUS_MATCHED;
|
||||
$this->bank_transaction->bank_transaction_rule_id = $bank_transaction_rule->id;
|
||||
$this->bank_transaction->save();
|
||||
|
||||
|
||||
//auto-convert
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function searchInvoiceResource(string $column, array $rule, $invoices)
|
||||
{
|
||||
|
||||
return $invoices->when($rule['search_key'] == 'description', function ($q) use ($rule, $column) {
|
||||
return $q->cursor()->filter(function ($record) use ($rule, $column) {
|
||||
return $this->matchStringOperator($this->bank_transaction->description, $record->{$column}, $rule['operator']);
|
||||
});
|
||||
@ -140,14 +174,68 @@ class ProcessBankRules extends AbstractService
|
||||
|
||||
}
|
||||
|
||||
private function searchPaymentResource()
|
||||
private function searchPaymentResource(string $column, array $rule, $payments)
|
||||
{
|
||||
|
||||
return $payments->when($rule['search_key'] == 'description', function ($q) use ($rule, $column) {
|
||||
return $q->cursor()->filter(function ($record) use ($rule, $column) {
|
||||
return $this->matchStringOperator($this->bank_transaction->description, $record->{$column}, $rule['operator']);
|
||||
});
|
||||
})
|
||||
->when($rule['search_key'] == 'amount', function ($q) use ($rule, $column) {
|
||||
return $q->cursor()->filter(function ($record) use ($rule, $column) {
|
||||
return $this->matchNumberOperator($this->bank_transaction->amount, $record->{$column}, $rule['operator']);
|
||||
});
|
||||
})->pluck("id");
|
||||
|
||||
}
|
||||
|
||||
private function searchClientResource()
|
||||
private function searchClientResource(string $column, array $rule, $invoices, $payments)
|
||||
{
|
||||
|
||||
$invoice_matches = Client::query()
|
||||
->whereIn('id', $invoices->pluck('client_id'))
|
||||
->when($column == 'email', function ($q) {
|
||||
return $q->whereHas('contacts', function ($qc) {
|
||||
$qc->where('email', $this->bank_transaction->description);
|
||||
});
|
||||
})
|
||||
->when($column != 'email', function ($q) use ($rule, $column) {
|
||||
|
||||
return $q->cursor()->filter(function ($record) use ($rule, $column) {
|
||||
return $this->matchStringOperator($this->bank_transaction->description, $record->{$column}, $rule['operator']);
|
||||
});
|
||||
})->pluck('id');
|
||||
|
||||
|
||||
$intersection = $invoices->whereIn('client_id', $invoice_matches);
|
||||
|
||||
if($intersection->count() > 0) {
|
||||
return [$intersection, Invoice::class];
|
||||
}
|
||||
|
||||
$payments_matches = Client::query()
|
||||
->whereIn('id', $payments->pluck('client_id'))
|
||||
->when($column == 'email', function ($q) {
|
||||
return $q->whereHas('contacts', function ($qc) {
|
||||
$qc->where('email', $this->bank_transaction->description);
|
||||
});
|
||||
})
|
||||
->when($column != 'email', function ($q) use ($rule, $column) {
|
||||
|
||||
return $q->cursor()->filter(function ($record) use ($rule, $column) {
|
||||
return $this->matchStringOperator($this->bank_transaction->description, $record->{$column}, $rule['operator']);
|
||||
});
|
||||
})->pluck('id');
|
||||
|
||||
$intersection = $payments->whereIn('client_id', $payments_matches);
|
||||
|
||||
if($intersection->count() > 0) {
|
||||
return [$intersection, Payment::class];
|
||||
}
|
||||
|
||||
return [Client::class, collect([])];
|
||||
|
||||
}
|
||||
// $payment.amount => "Payment Amount", float
|
||||
// $payment.transaction_reference => "Payment Transaction Reference", string
|
||||
|
@ -23,7 +23,6 @@ use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
*/
|
||||
trait ChartCalculations
|
||||
{
|
||||
|
||||
public function getActiveInvoices($data): int|float
|
||||
{
|
||||
$result = 0;
|
||||
@ -34,8 +33,9 @@ trait ChartCalculations
|
||||
->where('is_deleted', 0)
|
||||
->whereIn('status_id', [2,3,4]);
|
||||
|
||||
if(in_array($data['period'],['current,previous']))
|
||||
if(in_array($data['period'], ['current,previous'])) {
|
||||
$q->whereBetween('date', [$data['start_date'], $data['end_date']]);
|
||||
}
|
||||
|
||||
match ($data['calculation']) {
|
||||
'sum' => $result = $q->sum('amount'),
|
||||
@ -58,8 +58,9 @@ trait ChartCalculations
|
||||
->where('is_deleted', 0)
|
||||
->whereIn('status_id', [2,3]);
|
||||
|
||||
if(in_array($data['period'],['current,previous']))
|
||||
if(in_array($data['period'], ['current,previous'])) {
|
||||
$q->whereBetween('date', [$data['start_date'], $data['end_date']]);
|
||||
}
|
||||
|
||||
match ($data['calculation']) {
|
||||
'sum' => $result = $q->sum('balance'),
|
||||
@ -82,8 +83,9 @@ trait ChartCalculations
|
||||
->where('is_deleted', 0)
|
||||
->where('status_id', 4);
|
||||
|
||||
if(in_array($data['period'],['current,previous']))
|
||||
if(in_array($data['period'], ['current,previous'])) {
|
||||
$q->whereBetween('date', [$data['start_date'], $data['end_date']]);
|
||||
}
|
||||
|
||||
match ($data['calculation']) {
|
||||
'sum' => $result = $q->sum('amount'),
|
||||
@ -106,8 +108,9 @@ trait ChartCalculations
|
||||
->where('is_deleted', 0)
|
||||
->whereIn('status_id', [5,6]);
|
||||
|
||||
if(in_array($data['period'],['current,previous']))
|
||||
if(in_array($data['period'], ['current,previous'])) {
|
||||
$q->whereBetween('date', [$data['start_date'], $data['end_date']]);
|
||||
}
|
||||
|
||||
match ($data['calculation']) {
|
||||
'sum' => $result = $q->sum('refunded'),
|
||||
@ -133,8 +136,9 @@ trait ChartCalculations
|
||||
$qq->where('due_date', '>=', now()->toDateString())->orWhereNull('due_date');
|
||||
});
|
||||
|
||||
if(in_array($data['period'],['current,previous']))
|
||||
if(in_array($data['period'], ['current,previous'])) {
|
||||
$q->whereBetween('date', [$data['start_date'], $data['end_date']]);
|
||||
}
|
||||
|
||||
match ($data['calculation']) {
|
||||
'sum' => $result = $q->sum('refunded'),
|
||||
@ -160,8 +164,9 @@ trait ChartCalculations
|
||||
$qq->where('due_date', '>=', now()->toDateString())->orWhereNull('due_date');
|
||||
});
|
||||
|
||||
if(in_array($data['period'],['current,previous']))
|
||||
if(in_array($data['period'], ['current,previous'])) {
|
||||
$q->whereBetween('date', [$data['start_date'], $data['end_date']]);
|
||||
}
|
||||
|
||||
match ($data['calculation']) {
|
||||
'sum' => $result = $q->sum('refunded'),
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user