Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_long_live_access_token(self):
if not ll_access_token is None:
preference = {
"items": [
{
"title": "sdk-python test_long_live_access_token",
"quantity": 1,
"currency_id": "ARS",
"unit_price": 10.5
}
]
}
mp = mercadopago.MP(ll_access_token)
self.assertEquals(mp.preference.create(preference)["status"], 201)
print("test_long_live_access_token OK!")
else:
print("test_long_live_access_token (NOT EXECUTED)")
def test_update_preference(self):
preference = {
"items": [
{
"title": "sdk-python",
"quantity": 1,
"currency_id": "ARS",
"unit_price": 10.5
}
]
}
mp = mercadopago.MP(client_id, client_secret)
create_preference_result = mp.preference.create(preference)
self.assertEquals(create_preference_result["status"], 201)
created_preference_id = create_preference_result["response"]["id"]
preference_update = {
"items": [
{
"title": "sdk-python rules!",
"quantity": 2,
"currency_id": "ARS",
"unit_price": 19.99
}
]
def test_get_preference(self):
preference = {
"items": [
{
"title": "sdk-python",
"quantity": 1,
"currency_id": "ARS",
"unit_price": 10.5
}
]
}
mp = mercadopago.MP(client_id, client_secret)
create_preference_result = mp.preference.create(preference)
#print(create_preference_result)
self.assertEquals(create_preference_result["status"], 201)
created_preference_id = create_preference_result["response"]["id"]
get_preference_result = mp.preference.get(created_preference_id)
self.assertEquals(get_preference_result["status"], 200)
obtained_preference = get_preference_result["response"]
self.assertEquals(obtained_preference["items"][0]["title"], "sdk-python")
preapprovalPayment = {
"payer_email": "my_customer@my_site.com",
"back_url": "http://www.my_site.com",
"reason": "Monthly subscription to premium package",
"external_reference": "OP-1234",
"auto_recurring": {
"frequency": 1,
"frequency_type": "months",
"transaction_amount": 60,
"currency_id": "BRL",
"start_date": "2012-12-10T14:58:11.778-03:00",
"end_date": "2013-06-10T14:58:11.778-03:00"
}
}
mp = mercadopago.MP("CLIENT_ID", "CLIENT_SECRET")
preapprovalPaymentResult = mp.create_preapproval_payment(preapprovalPayment)
url = preapprovalPaymentResult["response"]["init_point"]
output = """
<title>MercadoPago SDK - Create Preapproval Payment and Show Subscription Example</title>
<a class="blue-l-arall-rn" name="MP-Checkout" href="{url}">Pagar</a>
def index(req, **kwargs):
# Create an instance with your MercadoPago credentials (CLIENT_ID and CLIENT_SECRET):
# Argentina: https://www.mercadopago.com/mla/herramientas/aplicaciones
# Brasil: https://www.mercadopago.com/mlb/ferramentas/aplicacoes
mp = mercadopago.MP("CLIENT_ID", "CLIENT_SECRET")
filters = {
"external_reference": "Bill001"
}
# Search payment data according to filters
searchResult = mp.payment.search(filters)
# Show payment information
output = """
<title>Search payments</title>