Skip to content

Commit 71c72f8

Browse files
Merge pull request #88 from renanneri01/release/2.3.0
Release/2.3.0
2 parents 4dc978c + bee83fd commit 71c72f8

24 files changed

+1237
-27
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
17+
python-version: ['3.9', '3.10', '3.11', '3.12']
1818

1919
steps:
2020
- uses: actions/checkout@v2

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/melisource/fury_websec-git-hooks
3+
rev: v2.0.0
4+
hooks:
5+
- id: pre_commit_hook
6+
stages: [commit]
7+
- id: post_commit_hook
8+
stages: [post-commit]
9+
10+
- repo: https://github.com/melisource/fury_datasec-git-hooks
11+
rev: 1.2.2
12+
hooks:
13+
- id: pre_commit_hook
14+
stages: [commit]
15+
- id: post_commit_hook
16+
stages: [post-commit]

mercadopago/config/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Config:
1010
"""
1111

1212
def __init__(self):
13-
self.__version = "2.2.3"
13+
self.__version = "2.3.0"
1414
self.__user_agent = "MercadoPago Python SDK v" + self.__version
1515
self.__product_id = "bc32bpftrpp001u8nhlg"
1616
self.__tracking_id = "platform:" + platform.python_version()

mercadopago/config/request_options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class RequestOptions: # pylint: disable=too-many-instance-attributes
2121
__integrator_id = None
2222
__platform_id = None
2323

24-
def __init__( # pylint: disable=too-many-arguments
24+
def __init__( # pylint: disable=too-many-positional-arguments
25+
# pylint: disable=too-many-arguments
2526
self,
2627
access_token=None,
2728
connection_timeout=60.0,
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import os
2+
import time
3+
4+
from mercadopago import SDK
5+
6+
def main():
7+
# Define the authentication token
8+
access_token = "<YOUR_ACCESS_TOKEN>"
9+
10+
# Define the authentication token
11+
sdk = SDK(access_token)
12+
13+
# Create a test card token
14+
def create_test_card():
15+
card_token_object = {
16+
"card_number": "5031433215406351",
17+
"security_code": "123",
18+
"expiration_year": "2030",
19+
"expiration_month": "11",
20+
"cardholder": {"name": "APRO"}
21+
}
22+
card_token_created = sdk.card_token().create(card_token_object)
23+
return card_token_created["response"]["id"]
24+
25+
# Create an order object
26+
card_token_id = create_test_card()
27+
order_object = {
28+
"type": "online",
29+
"capture_mode": "manual",
30+
"processing_mode": "automatic",
31+
"total_amount": "880.00",
32+
"external_reference": "ext_ref_1234",
33+
"transactions": {
34+
"payments": [
35+
{
36+
"amount": "880.00",
37+
"payment_method": {
38+
"id": "master",
39+
"type": "credit_card",
40+
"token": card_token_id,
41+
"installments": 2
42+
}
43+
}
44+
]
45+
},
46+
"payer": {
47+
"email": "<PAYER_EMAIL>"
48+
}
49+
}
50+
51+
try:
52+
# Call the method to create the order
53+
response = sdk.order().create(order_object)
54+
print("Order created successfully")
55+
56+
# Get the order ID from the response
57+
order_id = response["response"]["id"]
58+
59+
time.sleep(5)
60+
# Call the method to CANCEL
61+
order_details = sdk.order().cancel(order_id)
62+
print("Order details:", order_details["response"])
63+
except Exception as e:
64+
print("Error:", e)
65+
66+
if __name__ == "__main__":
67+
main()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import os
2+
from mercadopago import SDK
3+
4+
def main():
5+
# Define the authentication token
6+
access_token = "<YOUR_ACCESS_TOKEN>"
7+
8+
# Define the authentication token
9+
sdk = SDK(access_token)
10+
11+
# Create a test card token
12+
def create_test_card():
13+
card_token_object = {
14+
"card_number": "5031433215406351",
15+
"security_code": "123",
16+
"expiration_year": "2030",
17+
"expiration_month": "11",
18+
"cardholder": {"name": "APRO"}
19+
}
20+
card_token_created = sdk.card_token().create(card_token_object)
21+
return card_token_created["response"]["id"]
22+
23+
# Create an order object
24+
card_token_id = create_test_card()
25+
order_object = {
26+
"type": "online",
27+
"capture_mode": "manual", # Mode need to be Manual to use Capture Method.
28+
"processing_mode": "automatic",
29+
"total_amount": "880.00",
30+
"external_reference": "ext_ref_1234",
31+
"transactions": {
32+
"payments": [
33+
{
34+
"amount": "880.00",
35+
"payment_method": {
36+
"id": "master",
37+
"type": "credit_card",
38+
"token": card_token_id,
39+
"installments": 2
40+
}
41+
}
42+
]
43+
},
44+
"payer": {
45+
"email": "<PAYER_EMAIL>"
46+
}
47+
}
48+
49+
try:
50+
# Call the method to create the order
51+
response = sdk.order().create(order_object)
52+
print("Order created successfully")
53+
54+
# Get the order ID from the response
55+
order_id = response["response"]["id"]
56+
57+
# Call the method to CAPTURE the order
58+
order_details = sdk.order().capture(order_id)
59+
print("Order details:", order_details["response"])
60+
except Exception as e:
61+
print("Error:", e)
62+
63+
if __name__ == "__main__":
64+
main()
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from mercadopago import SDK
2+
3+
4+
def main():
5+
# Define the authentication token
6+
access_token = "<YOUR_ACCESS_TOKEN>"
7+
8+
# Define the authentication token
9+
sdk = SDK(access_token)
10+
11+
# Create a test card token
12+
def create_test_card():
13+
card_token_object = {
14+
"card_number": "5031433215406351",
15+
"security_code": "123",
16+
"expiration_year": "2030",
17+
"expiration_month": "11",
18+
"cardholder": {"name": "APRO"}
19+
}
20+
card_token_created = sdk.card_token().create(card_token_object)
21+
return card_token_created["response"]["id"]
22+
23+
# Create an order object
24+
card_token_id = create_test_card()
25+
order_object = {
26+
"type": "online",
27+
"total_amount": "880.00",
28+
"external_reference": "ext_ref_1234",
29+
"transactions": {
30+
"payments": [
31+
{
32+
"amount": "880.00",
33+
"payment_method": {
34+
"id": "master",
35+
"type": "credit_card",
36+
"token": card_token_id,
37+
"installments": 2
38+
}
39+
}
40+
]
41+
},
42+
"payer": {
43+
"email": "<PAYER_EMAIL>"
44+
}
45+
}
46+
47+
try:
48+
# Call the method to create the order
49+
response = sdk.order().create(order_object)
50+
print("Order created successfully:", response["response"])
51+
except Exception as e:
52+
print("Error:", e)
53+
54+
55+
if __name__ == "__main__":
56+
main()
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import os
2+
import time
3+
4+
from mercadopago import SDK
5+
6+
def main():
7+
# Define the authentication token
8+
access_token = "<YOUR_ACCESS_TOKEN>"
9+
10+
# Define the authentication token
11+
sdk = SDK(access_token)
12+
13+
# Create a test card token
14+
def create_test_card():
15+
card_token_object = {
16+
"card_number": "5031433215406351",
17+
"security_code": "123",
18+
"expiration_year": "2030",
19+
"expiration_month": "11",
20+
"cardholder": {"name": "APRO"}
21+
}
22+
card_token_created = sdk.card_token().create(card_token_object)
23+
return card_token_created["response"]["id"]
24+
25+
# Create an order object
26+
card_token_id = create_test_card()
27+
order_object = {
28+
"type": "online",
29+
"processing_mode": "manual",
30+
"total_amount": "200.00",
31+
"external_reference": "ext_ref_1234",
32+
"payer": {
33+
"email": "<PAYER_EMAIL>"
34+
}
35+
}
36+
37+
try:
38+
# Call the method to create the order
39+
response = sdk.order().create(order_object)
40+
print("Order created successfully")
41+
42+
# Get the order ID from the response
43+
order_id = response["response"]["id"]
44+
45+
transaction_object = {
46+
"payments": [
47+
{
48+
"amount": "200.00",
49+
"payment_method": {
50+
"id": "master",
51+
"type": "credit_card",
52+
"token": card_token_id,
53+
"installments": 12
54+
}
55+
}
56+
]
57+
}
58+
# Call the method to CREATE A TRANSACTION in the order
59+
transaction_created = sdk.order().create_transaction(order_id, transaction_object)
60+
print("Transaction created:", transaction_created["response"])
61+
except Exception as e:
62+
print("Error:", e)
63+
64+
if __name__ == "__main__":
65+
main()
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import os
2+
import time
3+
4+
from mercadopago import SDK
5+
6+
def main():
7+
# Define the authentication token
8+
access_token = "<YOUR_ACCESS_TOKEN>"
9+
10+
# Define the authentication token
11+
sdk = SDK(access_token)
12+
13+
# Create a test card token
14+
def create_test_card():
15+
card_token_object = {
16+
"card_number": "5031433215406351",
17+
"security_code": "123",
18+
"expiration_year": "2030",
19+
"expiration_month": "11",
20+
"cardholder": {"name": "APRO"}
21+
}
22+
card_token_created = sdk.card_token().create(card_token_object)
23+
return card_token_created["response"]["id"]
24+
25+
# Create an order object
26+
card_token_id = create_test_card()
27+
order_object = {
28+
"type": "online",
29+
"processing_mode": "manual",
30+
"total_amount": "200.00",
31+
"external_reference": "ext_ref_1234",
32+
"transactions": {
33+
"payments": [
34+
{
35+
"amount": "200.00",
36+
"payment_method": {
37+
"id": "master",
38+
"type": "credit_card",
39+
"token": card_token_id,
40+
"installments": 12
41+
}
42+
}
43+
]
44+
},
45+
"payer": {
46+
"email": "<PAYER_EMAIL>"
47+
}
48+
}
49+
50+
try:
51+
# Call the method to create the order
52+
response = sdk.order().create(order_object)
53+
print("Order created successfully")
54+
55+
# Get the order ID from the response
56+
order_id = response["response"]["id"]
57+
transaction_id = response["response"]["transactions"]["payments"][0]["id"]
58+
59+
# Call the method to DELETE the transaction in the order
60+
transaction_deleted = sdk.order().delete_transaction(order_id, transaction_id)
61+
print("Transaction Successful Deleted.", transaction_deleted["response"])
62+
except Exception as e:
63+
print("Error:", e)
64+
65+
if __name__ == "__main__":
66+
main()

0 commit comments

Comments
 (0)