invoiceninja/app/Models/PaymentType.php

92 lines
2.4 KiB
PHP
Raw Normal View History

<?php
2019-05-11 13:32:07 +10:00
/**
* Invoice Ninja (https://invoiceninja.com).
2019-05-11 13:32:07 +10:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2022-04-27 13:20:41 +10:00
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
2019-05-11 13:32:07 +10:00
*
2021-06-16 16:58:16 +10:00
* @license https://www.elastic.co/licensing/elastic-license
2019-05-11 13:32:07 +10:00
*/
namespace App\Models;
class PaymentType extends StaticModel
{
2019-09-11 09:31:55 +10:00
/**
* @var bool
*/
public $timestamps = false;
2022-07-12 08:37:18 +10:00
const CREDIT = 32;
const ACH = 4;
const VISA = 5;
const MASTERCARD = 6;
const AMERICAN_EXPRESS = 7;
const DISCOVER = 8;
const DINERS = 9;
const EUROCARD = 10;
const NOVA = 11;
const CREDIT_CARD_OTHER = 12;
const PAYPAL = 13;
const CHECK = 15;
const CARTE_BLANCHE = 16;
const UNIONPAY = 17;
const JCB = 18;
const LASER = 19;
const MAESTRO = 20;
const SOLO = 21;
const SWITCH = 22;
const ALIPAY = 27;
const SOFORT = 28;
const SEPA = 29;
const GOCARDLESS = 30;
const CRYPTO = 31;
2021-09-24 22:22:42 +02:00
const MOLLIE_BANK_TRANSFER = 34;
2021-09-24 23:17:29 +02:00
const KBC = 35;
2021-09-24 23:39:58 +02:00
const BANCONTACT = 36;
2021-10-09 10:14:01 +02:00
const IDEAL = 37;
2021-10-07 18:01:14 +02:00
const HOSTED_PAGE = 38;
2021-10-09 10:14:01 +02:00
const GIROPAY = 39;
const PRZELEWY24 = 40;
2021-10-10 06:47:03 +02:00
const EPS = 41;
2021-10-16 15:53:05 +02:00
const DIRECT_DEBIT = 42;
2021-10-22 06:50:23 +02:00
const BECS = 43;
2021-10-12 16:32:16 +02:00
const ACSS = 44;
2021-11-11 17:49:31 +01:00
const INSTANT_BANK_PAY = 45;
2022-01-20 08:27:05 +01:00
const FPX = 46;
public static function parseCardType($cardName)
{
$cardTypes = [
'visa' => self::VISA,
'americanexpress' => self::AMERICAN_EXPRESS,
'amex' => self::AMERICAN_EXPRESS,
'mastercard' => self::MASTERCARD,
'discover' => self::DISCOVER,
'jcb' => self::JCB,
'dinersclub' => self::DINERS,
'carteblanche' => self::CARTE_BLANCHE,
'chinaunionpay' => self::UNIONPAY,
'unionpay' => self::UNIONPAY,
'laser' => self::LASER,
'maestro' => self::MAESTRO,
'solo' => self::SOLO,
'switch' => self::SWITCH,
];
$cardName = strtolower(str_replace([' ', '-', '_'], '', $cardName));
if (empty($cardTypes[$cardName]) && 1 == preg_match('/^('.implode('|', array_keys($cardTypes)).')/', $cardName, $matches)) {
// Some gateways return extra stuff after the card name
$cardName = $matches[1];
}
if (! empty($cardTypes[$cardName])) {
return $cardTypes[$cardName];
} else {
return self::CREDIT_CARD_OTHER;
}
}
}