-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcharges_example.py
More file actions
81 lines (65 loc) · 1.84 KB
/
charges_example.py
File metadata and controls
81 lines (65 loc) · 1.84 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
import sys
import datetime
from os import path, pardir
PROJECT_ROOT = path.dirname(path.abspath(__file__))
sys.path.append(path.join(PROJECT_ROOT, pardir))
import openpay
openpay.api_key = "sk_10d37cc4da8e4ffd902cdf62e37abd1b"
openpay.verify_ssl_certs = False
openpay.merchant_id = "mynvbjhtzxdyfewlzmdo"
openpay.public_ip = '138.84.62.226'
customer = openpay.Customer.retrieve('amce5ycvwycfzyarjf8l')
print "customer: ", customer
card = customer.cards.create(
card_number="4111111111111111",
holder_name="Juan Perez Ramirez",
expiration_year="29",
expiration_month="12",
cvv2="110",
address={
"city":"Querétaro",
"country_code":"MX",
"postal_code":"76900",
"line1":"Av 5 de Febrero",
"line2":"Roble 207",
"line3":"col carrillo",
"state":"Queretaro"
})
print "Card: ", card
print "Creating card as customer"
charge = customer.charges.create(source_id=card.id, method="card", amount=100, description="Charge", capture=False)
print "charge: ", charge
print charge.refund()
print "Creating card as merchant"
card = openpay.Card.create(
card_number="4111111111111111",
holder_name="Juan Perez",
expiration_year="29",
expiration_month="12",
cvv2="110",
address={
"city":"Querétaro",
"country_code":"MX",
"postal_code":"76900",
"line1":"Av 5 de Febrero",
"line2":"Roble 207",
"line3":"col carrillo",
"state":"Queretaro"
}
)
print "Card: ", card
print "Creating charge as merchant"
charge = openpay.Charge.create_as_merchant(
source_id="k2trvya1nxpcytgww4rt",
method="card", amount=100,
description="Fourth charge",
capture=False)
print "charge: ", charge
print "Retrieve charge with ID as merchant"
charge = openpay.Charge.retrieve_as_merchant(charge.id)
print "charge: ", charge
print "Capturing charge"
print charge.capture(merchant=True)
print "Refund charge"
print charge.refund(merchant=True)