Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from .mercadopagorestclient import MercadoPagoRestClient
class DiscountCampaign(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(DiscountCampaign, self).__init__(client_id, client_secret, access_token, version)
def get(self, transaction_amount, payer_email, coupon_code):
access_token = self.get_access_token()
filters = {}
filters["access_token"] = access_token
filters["transaction_amount"] = transaction_amount
filters["payer_email"] = payer_email
filters["coupon_code"] = coupon_code
payment_result = self.get_rest_client().get("/v1/discount_campaigns", filters)
return payment_result
from .mercadopagorestclient import MercadoPagoRestClient
class MerchantOrder(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(MerchantOrder, self).__init__(client_id, client_secret, access_token, version)
def create(self, merchant_order):
access_token = self.get_access_token()
result = self.get_rest_client().post("/merchant_orders?access_token=" + access_token, merchant_order)
return result
def update(self, id, merchant_order):
access_token = self.get_access_token()
result = self.get_rest_client().put("/merchant_orders/" + id + "?access_token=" + access_token, merchant_order)
return result
def get(self, id):
access_token = self.get_access_token()
result = self.get_rest_client().get("/merchant_orders/" + id + "?access_token=" + access_token)
from .mercadopagorestclient import MercadoPagoRestClient
class GenericCall(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(GenericCall, self).__init__(client_id, client_secret, access_token, version)
def get(self, uri, params=None, authenticate=True):
if params is None:
params = {}
if authenticate:
access_token = self.get_access_token()
params["access_token"] = access_token
result = self.get_rest_client().get(uri, params)
return result
def post(self, uri, data, params=None):
if params is None:
from .mercadopagorestclient import MercadoPagoRestClient
class Preference(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(Preference, self).__init__(client_id, client_secret, access_token, version)
def create(self, preference):
access_token = self.get_access_token()
preference_result = self.get_rest_client().post("/checkout/preferences?access_token=" + access_token, preference)
return preference_result
def update(self, id, preference):
access_token = self.get_access_token()
preference_result = self.get_rest_client().put("/checkout/preferences/" + id + "?access_token=" + access_token, preference)
return preference_result
def get(self, id):
access_token = self.get_access_token()
preference_result = self.get_rest_client().get("/checkout/preferences/" + id + "?access_token=" + access_token)
from .mercadopagorestclient import MercadoPagoRestClient
class Payment(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(Payment, self).__init__(client_id, client_secret, access_token, version)
def get(self, id):
access_token = self.get_access_token()
#uri_prefix = "/sandbox" if MercadoPago.__sandbox else ""
payment_info = self.get_rest_client().get("/v1/payments/" + id + "?access_token=" + access_token)
return payment_info
def get_authorized(self, id):
access_token = self.get_access_token()
authorized_payment_info = self.get_rest_client().get("/authorized_payments/" + id + "?access_token=" + access_token)
return authorized_payment_info
from .mercadopagorestclient import MercadoPagoRestClient
class IdentificationType(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(IdentificationType, self).__init__(client_id, client_secret, access_token, version)
def get(self, id):
access_token = self.get_access_token()
result = self.get_rest_client().get("/v1/identification_types?access_token=" + access_token)
return result
from .mercadopagorestclient import MercadoPagoRestClient
class CardToken(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(CardToken, self).__init__(client_id, client_secret, access_token, version)
def create(self, cardtoken):
access_token = self.get_access_token()
result = self.get_rest_client().post("/v1/card_tokens?access_token=" + access_token, cardtoken)
return result
def get(self, id):
access_token = self.get_access_token()
result = self.get_rest_client().get("/v1/card_tokens/" + id + "?access_token=" + access_token)
return result
from .mercadopagorestclient import MercadoPagoRestClient
class Customer(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(Customer, self).__init__(client_id, client_secret, access_token, version)
def get(self, id):
access_token = self.get_access_token()
result = self.get_rest_client().get("/v1/customers/" + id + "?access_token=" + access_token)
return result
def create(self, customer):
access_token = self.get_access_token()
response = self.get_rest_client().post("/v1/customers?access_token=" + access_token, customer)
return response
def update(self, id, customer):
access_token = self.get_access_token()
response = self.get_rest_client().put("/v1/customers/" + id + "?access_token=" + access_token, customer)
from .mercadopagorestclient import MercadoPagoRestClient
class Card(MercadoPagoRestClient):
def __init__(self, client_id, client_secret, access_token, version):
super(Card, self).__init__(client_id, client_secret, access_token, version)
def create(self, card):
access_token = self.get_access_token()
result = self.get_rest_client().post("/v1/customers/" + id + "/cards?access_token=" + access_token, card)
return result
def update(self, id, card):
access_token = self.get_access_token()
result = self.get_rest_client().put("/v1/customers/" + id + "/cards?access_token=" + access_token, card)
return result
def delete(self, id):
access_token = self.get_access_token()
result = self.get_rest_client().delete("/v1/customers/" + id + "/cards?access_token=" + access_token)