1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Models/Gateway.php

185 lines
9.9 KiB
PHP
Raw Normal View History

<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2019-05-11 05:32:07 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2022-04-27 05:20:41 +02:00
* @copyright Copyright (c) 2022. 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
*/
namespace App\Models;
class Gateway extends StaticModel
{
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',
'sort_order' => 'int',
'updated_at' => 'timestamp',
'created_at' => 'timestamp',
'default_gateway_type_id' => 'string',
// '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-10-06 05:01:28 +02:00
public function getOptionsAttribute()
{
return $this->getMethods();
}
2019-09-05 14:42:26 +02:00
/**
* Test if gateway is custom.
* @return bool TRUE|FALSE
2019-09-05 14:42:26 +02:00
*/
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';
} elseif ($this->id == 15) {
$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';
} 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
2020-10-06 05:01:28 +02:00
break;
2021-07-22 03:30:16 +02:00
case 3:
return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]]; //eWay
2021-08-26 15:37:17 +02:00
break;
2021-08-18 13:21:05 +02:00
case 11:
return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]]; //Payfast
2021-07-21 12:35:22 +02:00
break;
2021-08-14 11:32:16 +02:00
case 7:
return [
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:
return [
GatewayType::PAYPAL => ['refund' => false, 'token_billing' => false],
]; //Paypal
2020-10-06 05:01:28 +02:00
break;
case 20:
return [
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded', 'charge.failed', '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],
2021-10-05 16:31:33 +02:00
GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']], //Stripe
2021-10-09 10:09:04 +02:00
GatewayType::SEPA => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
GatewayType::PRZELEWY24 => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
2021-10-10 00:37:42 +02:00
GatewayType::GIROPAY => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
2021-10-10 06:47:03 +02:00
GatewayType::EPS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
2021-10-10 11:39:29 +02:00
GatewayType::BANCONTACT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
2021-10-11 18:05:47 +02:00
GatewayType::BECS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
2021-10-12 16:32:16 +02:00
GatewayType::IDEAL => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
2022-01-20 08:25:11 +01:00
GatewayType::ACSS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
GatewayType::FPX => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']], ];
2020-10-06 05:01:28 +02:00
case 39:
return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']]]; //Checkout
2020-10-06 05:01:28 +02:00
break;
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:
return [
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']],
]; //WePay
2021-08-26 15:37:17 +02:00
break;
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],
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']],
2021-05-04 14:56:30 +02:00
];
break;
2021-08-21 14:22:22 +02:00
case 56:
return [
2022-02-11 23:10:10 +01:00
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true, 'webhooks' => ['payment_intent.succeeded']],
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
2021-08-21 14:22:22 +02:00
GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],
GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false],
GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']], //Stripe
GatewayType::SEPA => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']],
GatewayType::PRZELEWY24 => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']],
GatewayType::GIROPAY => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']],
GatewayType::EPS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']],
GatewayType::BANCONTACT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']],
GatewayType::BECS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']],
GatewayType::IDEAL => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']],
GatewayType::ACSS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded', 'payment_intent.succeeded']],
GatewayType::FPX => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
];
2021-08-21 14:22:22 +02:00
break;
2021-08-14 11:32:16 +02:00
case 57:
2021-08-04 14:31:47 +02:00
return [
2021-08-21 14:22:22 +02:00
GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true], //Square
2021-08-04 14:31:47 +02:00
];
break;
2021-09-28 18:24:35 +02:00
case 52:
return [
GatewayType::BANK_TRANSFER => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']], // GoCardless
GatewayType::DIRECT_DEBIT => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']],
2021-11-11 15:54:16 +01:00
GatewayType::SEPA => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']],
GatewayType::INSTANT_BANK_PAY => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']],
2021-09-28 18:24:35 +02:00
];
2021-08-14 11:32:16 +02:00
break;
2021-10-07 16:24:40 +02:00
case 58:
return [
GatewayType::HOSTED_PAGE => ['refund' => false, 'token_billing' => false, 'webhooks' => [' ']], // Razorpay
2021-10-07 16:24:40 +02:00
];
break;
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' => [' ']],
];
break;
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
break;
}
}
}