PaymentMethodParser.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Braintree;
/**
 * Braintree PaymentMethodParser module
 *
 * @package    Braintree
 * @category   Resources
 */
/**
 * Manages Braintree PaymentMethodParser
 *
 * <b>== More information ==</b>
 *
 *
 * @package    Braintree
 * @category   Resources
 *
 */
class PaymentMethodParser
{
    public static function parsePaymentMethod($response)
    {
        if (isset($response['creditCard'])) {
            return CreditCard::factory($response['creditCard']);
        } else if (isset($response['paypalAccount'])) {
            return PayPalAccount::factory($response['paypalAccount']);
        } else if (isset($response['coinbaseAccount'])) {
            return CoinbaseAccount::factory($response['coinbaseAccount']);
        } else if (isset($response['applePayCard'])) {
            return ApplePayCard::factory($response['applePayCard']);
        } else if (isset($response['androidPayCard'])) {
            return AndroidPayCard::factory($response['androidPayCard']);
        } else if (isset($response['amexExpressCheckoutCard'])) {
            return AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']);
        } else if (isset($response['europeBankAccount'])) {
            return EuropeBankAccount::factory($response['europeBankAccount']);
        } else if (isset($response['usBankAccount'])) {
            return UsBankAccount::factory($response['usBankAccount']);
        } else if (isset($response['venmoAccount'])) {
            return VenmoAccount::factory($response['venmoAccount']);
        } else if (isset($response['visaCheckoutCard'])) {
            return VisaCheckoutCard::factory($response['visaCheckoutCard']);
        } else if (isset($response['masterpassCard'])) {
            return MasterpassCard::factory($response['masterpassCard']);
        } else if (isset($response['samsungPayCard'])) {
            return SamsungPayCard::factory($response['samsungPayCard']);
        } else if (is_array($response)) {
            return UnknownPaymentMethod::factory($response);
        } else {
            throw new Exception\Unexpected(
                'Expected payment method'
            );
        }
    }
}
class_alias('Braintree\PaymentMethodParser', 'Braintree_PaymentMethodParser');