2018-10-15 14:40:34 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2018-10-15 14:40:34 +02:00
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2023-03-08 08:33:42 +01:00
|
|
|
/**
|
|
|
|
* App\Models\Gateway
|
|
|
|
*
|
|
|
|
* @property int $id
|
|
|
|
* @property string $name
|
|
|
|
* @property string $key
|
|
|
|
* @property string $provider
|
|
|
|
* @property bool $visible
|
|
|
|
* @property int $sort_order
|
|
|
|
* @property string|null $site_url
|
|
|
|
* @property bool $is_offsite
|
|
|
|
* @property bool $is_secure
|
|
|
|
* @property object|null $fields
|
|
|
|
* @property string $default_gateway_type_id
|
|
|
|
* @property int|null $created_at
|
|
|
|
* @property int|null $updated_at
|
|
|
|
* @property-read mixed $options
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|StaticModel company()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|StaticModel exclude($columns)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway newModelQuery()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway newQuery()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway query()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereCreatedAt($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereDefaultGatewayTypeId($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereFields($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereId($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereIsOffsite($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereIsSecure($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereKey($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereName($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereProvider($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereSiteUrl($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereSortOrder($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereUpdatedAt($value)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Gateway whereVisible($value)
|
|
|
|
* @mixin \Eloquent
|
|
|
|
*/
|
2019-09-12 03:28:41 +02:00
|
|
|
class Gateway extends StaticModel
|
2018-10-15 14:40:34 +02:00
|
|
|
{
|
2019-09-17 12:27:48 +02:00
|
|
|
protected $casts = [
|
|
|
|
'is_offsite' => 'boolean',
|
|
|
|
'is_secure' => 'boolean',
|
2019-10-15 12:36:51 +02:00
|
|
|
'recommended' => 'boolean',
|
2020-10-12 01:21:24 +02:00
|
|
|
'visible' => 'boolean',
|
2020-10-04 10:52:58 +02:00
|
|
|
'sort_order' => 'int',
|
2019-09-26 00:27:26 +02:00
|
|
|
'updated_at' => 'timestamp',
|
|
|
|
'created_at' => 'timestamp',
|
2019-10-22 13:27:03 +02:00
|
|
|
'default_gateway_type_id' => 'string',
|
2020-10-14 22:58:20 +02:00
|
|
|
// 'fields' => 'json',
|
|
|
|
'fields' => 'object',
|
2020-10-06 05:01:28 +02:00
|
|
|
'options' => 'array',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $appends = [
|
|
|
|
'options',
|
2019-09-17 12:27:48 +02:00
|
|
|
];
|
|
|
|
|
2020-07-05 10:59:28 +02:00
|
|
|
protected $dateFormat = 'Y-m-d H:i:s.u';
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-10-06 05:01:28 +02:00
|
|
|
public function getOptionsAttribute()
|
|
|
|
{
|
|
|
|
return $this->getMethods();
|
|
|
|
}
|
|
|
|
|
2024-05-02 02:05:18 +02:00
|
|
|
// /**
|
|
|
|
// * Test if gateway is custom.
|
|
|
|
// * @return bool TRUE|FALSE
|
|
|
|
// */
|
|
|
|
// public function isCustom(): bool
|
|
|
|
// {
|
|
|
|
// return in_array($this->id, [62, 67, 68]); //static table ids of the custom gateways
|
|
|
|
// }
|
2020-09-28 04:56:11 +02:00
|
|
|
|
|
|
|
public function getHelp()
|
|
|
|
{
|
|
|
|
$link = '';
|
|
|
|
|
|
|
|
if ($this->id == 1) {
|
|
|
|
$link = 'http://reseller.authorize.net/application/?id=5560364';
|
2023-11-26 08:41:42 +01:00
|
|
|
} elseif (in_array($this->id, [15,60,61])) {
|
2020-09-28 04:56:11 +02:00
|
|
|
$link = 'https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run';
|
|
|
|
} elseif ($this->id == 24) {
|
|
|
|
$link = 'https://www.2checkout.com/referral?r=2c37ac2298';
|
|
|
|
} elseif ($this->id == 35) {
|
|
|
|
$link = 'https://bitpay.com/dashboard/signup';
|
|
|
|
} elseif ($this->id == 18) {
|
|
|
|
$link = 'https://applications.sagepay.com/apply/2C02C252-0F8A-1B84-E10D-CF933EFCAA99';
|
2021-10-12 09:41:36 +02:00
|
|
|
} elseif ($this->id == 20 || $this->id == 56) {
|
2020-09-28 04:56:11 +02:00
|
|
|
$link = 'https://dashboard.stripe.com/account/apikeys';
|
2022-04-18 04:47:08 +02:00
|
|
|
} elseif ($this->id == 59) {
|
|
|
|
$link = 'https://www.forte.net/';
|
2020-11-25 15:19:52 +01:00
|
|
|
}
|
2020-09-28 04:56:11 +02:00
|
|
|
|
2020-09-29 06:32:29 +02:00
|
|
|
return $link;
|
2020-09-28 04:56:11 +02:00
|
|
|
}
|
|
|
|
|
2020-10-06 05:01:28 +02:00
|
|
|
/**
|
|
|
|
* Returns an array of methods and the gatewaytypes possible
|
2020-11-25 15:19:52 +01:00
|
|
|
*
|
|
|
|
* @return array
|
2021-03-16 14:40:58 +01:00
|
|
|
*/
|
2020-10-06 05:01:28 +02:00
|
|
|
public function getMethods()
|
|
|
|
{
|
|
|
|
switch ($this->id) {
|
|
|
|
case 1:
|
2021-08-18 13:46:04 +02:00
|
|
|
return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true]]; //Authorize.net
|
2021-07-22 03:30:16 +02:00
|
|
|
case 3:
|
2022-06-21 11:57:17 +02:00
|
|
|
return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]]; //eWay
|
2021-08-18 13:21:05 +02:00
|
|
|
case 11:
|
2022-06-21 11:57:17 +02:00
|
|
|
return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]]; //Payfast
|
2021-08-14 11:32:16 +02:00
|
|
|
case 7:
|
|
|
|
return [
|
2021-10-12 09:41:36 +02:00
|
|
|
GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']], // Mollie
|
|
|
|
GatewayType::BANK_TRANSFER => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']],
|
|
|
|
GatewayType::KBC => ['refund' => false, 'token_billing' => false, 'webhooks' => [' ']],
|
|
|
|
GatewayType::BANCONTACT => ['refund' => false, 'token_billing' => false, 'webhooks' => [' ']],
|
|
|
|
GatewayType::IDEAL => ['refund' => false, 'token_billing' => false, 'webhooks' => [' ']],
|
2021-08-14 11:32:16 +02:00
|
|
|
];
|
2020-10-06 05:01:28 +02:00
|
|
|
case 15:
|
2021-10-12 09:41:36 +02:00
|
|
|
return [
|
2022-06-21 11:57:17 +02:00
|
|
|
GatewayType::PAYPAL => ['refund' => false, 'token_billing' => false],
|
2021-10-12 09:41:36 +02:00
|
|
|
]; //Paypal
|
2020-10-06 05:01:28 +02:00
|
|
|
case 20:
|
2023-03-18 08:24:56 +01:00
|
|
|
case 56:
|
2021-10-12 09:41:36 +02:00
|
|
|
return [
|
2023-03-17 03:55:46 +01:00
|
|
|
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true, 'webhooks' => ['payment_intent.succeeded', 'payment_intent.payment_failed']],
|
2024-03-08 00:05:48 +01:00
|
|
|
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'customer.source.updated','payment_intent.processing', 'payment_intent.payment_failed', 'charge.failed']],
|
2023-03-17 03:55:46 +01:00
|
|
|
GatewayType::DIRECT_DEBIT => ['refund' => false, 'token_billing' => false, 'webhooks' => ['payment_intent.processing','payment_intent.succeeded','payment_intent.partially_funded', 'payment_intent.payment_failed']],
|
2021-09-21 11:55:15 +02:00
|
|
|
GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],
|
|
|
|
GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false],
|
2024-03-08 03:13:19 +01:00
|
|
|
GatewayType::BACS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.processing', 'payment_intent.succeeded', 'mandate.updated', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::KLARNA => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::SEPA => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::PRZELEWY24 => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::GIROPAY => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::EPS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::BANCONTACT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::BECS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::IDEAL => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::ACSS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed']],
|
|
|
|
GatewayType::FPX => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'charge.failed', ]],
|
2023-01-06 08:43:28 +01:00
|
|
|
];
|
2020-10-06 05:01:28 +02:00
|
|
|
case 39:
|
2021-10-12 09:41:36 +02:00
|
|
|
return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']]]; //Checkout
|
2021-07-21 12:35:22 +02:00
|
|
|
case 46:
|
|
|
|
return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true]]; //Paytrace
|
2021-06-11 09:39:51 +02:00
|
|
|
case 49:
|
2021-10-12 09:41:36 +02:00
|
|
|
return [
|
|
|
|
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
|
2022-06-21 11:57:17 +02:00
|
|
|
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']],
|
|
|
|
]; //WePay
|
2021-05-04 14:56:30 +02:00
|
|
|
case 50:
|
|
|
|
return [
|
2021-08-11 08:43:20 +02:00
|
|
|
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true], //Braintree
|
2021-08-26 15:37:17 +02:00
|
|
|
GatewayType::PAYPAL => ['refund' => true, 'token_billing' => true],
|
2021-10-12 09:41:36 +02:00
|
|
|
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']],
|
2021-05-04 14:56:30 +02:00
|
|
|
];
|
2021-08-14 11:32:16 +02:00
|
|
|
case 57:
|
2021-08-04 14:31:47 +02:00
|
|
|
return [
|
2023-08-19 03:13:52 +02:00
|
|
|
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true], //Square
|
2021-08-04 14:31:47 +02:00
|
|
|
];
|
2021-09-28 18:24:35 +02:00
|
|
|
case 52:
|
|
|
|
return [
|
2023-09-17 10:44:05 +02:00
|
|
|
GatewayType::BANK_TRANSFER => ['refund' => false, 'token_billing' => true, 'webhooks' => ['confirmed','paid_out','failed','fulfilled']], // GoCardless
|
|
|
|
GatewayType::DIRECT_DEBIT => ['refund' => false, 'token_billing' => true, 'webhooks' => ['confirmed','paid_out','failed','fulfilled']],
|
|
|
|
GatewayType::SEPA => ['refund' => false, 'token_billing' => true, 'webhooks' => ['confirmed','paid_out','failed','fulfilled']],
|
|
|
|
GatewayType::INSTANT_BANK_PAY => ['refund' => false, 'token_billing' => true, 'webhooks' => ['confirmed','paid_out','failed','fulfilled']],
|
2021-09-28 18:24:35 +02:00
|
|
|
];
|
2021-10-07 16:24:40 +02:00
|
|
|
case 58:
|
|
|
|
return [
|
2022-06-21 11:57:17 +02:00
|
|
|
GatewayType::HOSTED_PAGE => ['refund' => false, 'token_billing' => false, 'webhooks' => [' ']], // Razorpay
|
2021-10-07 16:24:40 +02:00
|
|
|
];
|
2022-04-18 04:47:08 +02:00
|
|
|
case 59:
|
|
|
|
return [
|
|
|
|
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true], // Forte
|
|
|
|
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']],
|
|
|
|
];
|
2023-06-20 15:10:25 +02:00
|
|
|
case 60:
|
|
|
|
return [
|
|
|
|
GatewayType::PAYPAL => ['refund' => false, 'token_billing' => false],
|
2023-06-21 14:19:13 +02:00
|
|
|
GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false],
|
|
|
|
GatewayType::VENMO => ['refund' => false, 'token_billing' => false],
|
2024-04-22 06:38:29 +02:00
|
|
|
GatewayType::PAYPAL_ADVANCED_CARDS => ['refund' => false, 'token_billing' => true],
|
2023-07-23 01:32:05 +02:00
|
|
|
// GatewayType::SEPA => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::BANCONTACT => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::EPS => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::MYBANK => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::PAYLATER => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::PRZELEWY24 => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::SOFORT => ['refund' => false, 'token_billing' => false],
|
2023-06-20 15:10:25 +02:00
|
|
|
]; //Paypal
|
2023-10-16 03:05:19 +02:00
|
|
|
case 61:
|
|
|
|
return [
|
|
|
|
GatewayType::PAYPAL => ['refund' => false, 'token_billing' => false],
|
|
|
|
GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false],
|
|
|
|
GatewayType::VENMO => ['refund' => false, 'token_billing' => false],
|
2024-04-22 06:38:29 +02:00
|
|
|
GatewayType::PAYPAL_ADVANCED_CARDS => ['refund' => false, 'token_billing' => true],
|
2023-10-16 03:05:19 +02:00
|
|
|
// GatewayType::SEPA => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::BANCONTACT => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::EPS => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::MYBANK => ['refund' => false, 'token_billing' => false],
|
2023-12-07 09:32:08 +01:00
|
|
|
GatewayType::PAYLATER => ['refund' => false, 'token_billing' => false],
|
2023-10-16 03:05:19 +02:00
|
|
|
// GatewayType::PRZELEWY24 => ['refund' => false, 'token_billing' => false],
|
|
|
|
// GatewayType::SOFORT => ['refund' => false, 'token_billing' => false],
|
|
|
|
]; //Paypal PPCP
|
2020-10-06 05:01:28 +02:00
|
|
|
default:
|
2020-10-11 11:17:33 +02:00
|
|
|
return [];
|
2020-10-06 05:01:28 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-15 14:40:34 +02:00
|
|
|
}
|