File: payment_method.py

package info (click to toggle)
python-braintree 3.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,376 kB
  • ctags: 1,998
  • sloc: python: 13,634; makefile: 73; sh: 8
file content (74 lines) | stat: -rw-r--r-- 2,177 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import braintree
from braintree.address import Address
from braintree.resource import Resource
from braintree.configuration import Configuration

class PaymentMethod(Resource):
    @staticmethod
    def create(params={}):
        return Configuration.gateway().payment_method.create(params)

    @staticmethod
    def find(payment_method_token):
        return Configuration.gateway().payment_method.find(payment_method_token)

    @staticmethod
    def update(payment_method_token, params):
        return Configuration.gateway().payment_method.update(payment_method_token, params)

    @staticmethod
    def delete(payment_method_token):
        return Configuration.gateway().payment_method.delete(payment_method_token)

    @staticmethod
    def create_signature():
        return PaymentMethod.signature("create")

    @staticmethod
    def signature(type):
        signature = [
            "customer_id",
            "payment_method_nonce",
            "token",
            "billing_address_id",
            {"billing_address": Address.create_signature()},
            {"options": [
                "make_default",
                "verify_card",
                "fail_on_duplicate_payment_method",
                "verification_merchant_account_id",
                ]
            }
        ]
        return signature

    @staticmethod
    def update_signature():
        signature = [
            "billing_address_id",
            "cardholder_name",
            "cvv",
            "device_session_id",
            "expiration_date",
            "expiration_month",
            "expiration_year",
            "number",
            "token",
            "venmo_sdk_payment_method_code",
            "device_data",
            "fraud_merchant_id",
            "payment_method_nonce",
            {"options": [
                "make_default",
                "verify_card",
                "verification_merchant_account_id",
                "venmo_sdk_session"
                ]
            },
            {"billing_address" :
                Address.update_signature() +
                [{"options": ["update_existing"]}]
            }
        ]
        return signature