How to use the mercadopago.abstract_api.CreatableAPIResource function in mercadopago

To help you get started, we’ve selected a few mercadopago examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github federicobond / pymercadopago / mercadopago / api.py View on Github external
SearchableAPIResource):
    _base_path = '/v1/customers'

    def cards(self, id):
        return CardAPI(self._client, id)


class IdentificationTypeAPI(ListableAPIResource):
    _base_path = '/identification_types'


class InvoiceAPI(RetrievableAPIResource):
    _base_path = '/v1/invoices'


class MerchantOrderAPI(RetrievableAPIResource, CreatableAPIResource,
                       UpdatableAPIResource):
    _base_path = '/merchant_orders'


class PaymentMethodAPI(ListableAPIResource):
    _base_path = '/v1/payment_methods'

    def card_issuers(self, payment_method_id):
        return self._client.get('/card_issuers', params={'payment_method_id': payment_method_id})

    def installments(self, **data):
        return self._client.get('/installments', params=data)


class PaymentAPI(RetrievableAPIResource, CreatableAPIResource,
                 UpdatableAPIResource, SearchableAPIResource):
github federicobond / pymercadopago / mercadopago / api.py View on Github external
class MerchantOrderAPI(RetrievableAPIResource, CreatableAPIResource,
                       UpdatableAPIResource):
    _base_path = '/merchant_orders'


class PaymentMethodAPI(ListableAPIResource):
    _base_path = '/v1/payment_methods'

    def card_issuers(self, payment_method_id):
        return self._client.get('/card_issuers', params={'payment_method_id': payment_method_id})

    def installments(self, **data):
        return self._client.get('/installments', params=data)


class PaymentAPI(RetrievableAPIResource, CreatableAPIResource,
                 UpdatableAPIResource, SearchableAPIResource):
    _base_path = '/v1/payments'

    def cancel(self, id):
        return self.update(id, status='cancelled')

    def refund(self, id):
        return self._client.post('/{id}/refunds', {'id': id})

    def partial_refund(self, id, amount):
        return self._client.post('/{id}/refunds', {'id': id}, json={'amount': amount})


class AdvancedPaymentAPI(RetrievableAPIResource, CreatableAPIResource,
                          UpdatableAPIResource, SearchableAPIResource):
github federicobond / pymercadopago / mercadopago / api.py View on Github external
class ChargebackAPI(RetrievableAPIResource):
    _base_path = '/v1/chargebacks'


class PlanAPI(RetrievableAPIResource, CreatableAPIResource,
              UpdatableAPIResource):
    _base_path = '/v1/plans'


class PreferenceAPI(RetrievableAPIResource, CreatableAPIResource,
                    UpdatableAPIResource, ListableAPIResource):
    _base_path = '/checkout/preferences'


class MoneyRequestAPI(RetrievableAPIResource, CreatableAPIResource):
    _base_path = '/money_requests'


class PreapprovalAPI(CreatableAPIResource, UpdatableAPIResource,
                     SearchableAPIResource):
    _base_path = '/preapproval'

    def get(self, id):
        # NOTE: this is actually performing a search with ID and mangling
        # the response data to conform to a single object format.
        # There is no method to retrieve a preapproval by ID at the moment.

        res = self.search(id=id)

        if not res.data['results']:
            raise errors.NotFoundError('could not find preapproval with ID = %s' % id)
github federicobond / pymercadopago / mercadopago / api.py View on Github external
def cancel(self, id):
        return self.update(id, status='cancelled')

    def pause(self, id):
        return self.update(id, status='paused')


class ShippingOptionAPI(API):
    _base_path = '/shipping_options'

    def get(self, **data):
        return self._client.get(params=data)


class PosAPI(RetrievableAPIResource, CreatableAPIResource,
             UpdatableAPIResource, DeletableAPIResource, ListableAPIResource):
    _base_path = '/pos'


class UsersAPI(API):
    _base_path = '/users'

    def me(self):
        return self._client.get('/me')

    def account_balance(self, user_id=None):
        if user_id is None:
            user_id = self.me().data['id']

        return self._client.get('/{user_id}/mercadopago_account/balance', {
            'user_id': user_id
github federicobond / pymercadopago / mercadopago / api.py View on Github external
class PaymentAPI(RetrievableAPIResource, CreatableAPIResource,
                 UpdatableAPIResource, SearchableAPIResource):
    _base_path = '/v1/payments'

    def cancel(self, id):
        return self.update(id, status='cancelled')

    def refund(self, id):
        return self._client.post('/{id}/refunds', {'id': id})

    def partial_refund(self, id, amount):
        return self._client.post('/{id}/refunds', {'id': id}, json={'amount': amount})


class AdvancedPaymentAPI(RetrievableAPIResource, CreatableAPIResource,
                          UpdatableAPIResource, SearchableAPIResource):

    _base_path = '/v1/advanced_payments'

    def refund(self, id):
        return self._client.post('/{id}/refunds', {'id': id})

    def disburses(self, id, **data):
        return self._client.post('/{id}/disburses', {'id': id}, json=data)

    def disbursements(self, id):
        return DisbursementAPI(self._client, id)


class DisbursementAPI(API):
    _base_path = '/v1/advanced_payments/{payment_id}/disbursements'
github federicobond / pymercadopago / mercadopago / api.py View on Github external
def __init__(self, client, payment_id):
        super().__init__(client, path_args={'payment_id': payment_id})

    def refunds(self, id, **data):
        return self._client.post('/{disbursement_id}/refunds', {'disbursement_id': id}, json=data)

    def disburses(self, id, **data):
        return self._client.post('/{disbursement_id}/disburses', {'disbursement_id': id}, json=data)


class ChargebackAPI(RetrievableAPIResource):
    _base_path = '/v1/chargebacks'


class PlanAPI(RetrievableAPIResource, CreatableAPIResource,
              UpdatableAPIResource):
    _base_path = '/v1/plans'


class PreferenceAPI(RetrievableAPIResource, CreatableAPIResource,
                    UpdatableAPIResource, ListableAPIResource):
    _base_path = '/checkout/preferences'


class MoneyRequestAPI(RetrievableAPIResource, CreatableAPIResource):
    _base_path = '/money_requests'


class PreapprovalAPI(CreatableAPIResource, UpdatableAPIResource,
                     SearchableAPIResource):
    _base_path = '/preapproval'
github federicobond / pymercadopago / mercadopago / api.py View on Github external
return self._client.post('/{disbursement_id}/refunds', {'disbursement_id': id}, json=data)

    def disburses(self, id, **data):
        return self._client.post('/{disbursement_id}/disburses', {'disbursement_id': id}, json=data)


class ChargebackAPI(RetrievableAPIResource):
    _base_path = '/v1/chargebacks'


class PlanAPI(RetrievableAPIResource, CreatableAPIResource,
              UpdatableAPIResource):
    _base_path = '/v1/plans'


class PreferenceAPI(RetrievableAPIResource, CreatableAPIResource,
                    UpdatableAPIResource, ListableAPIResource):
    _base_path = '/checkout/preferences'


class MoneyRequestAPI(RetrievableAPIResource, CreatableAPIResource):
    _base_path = '/money_requests'


class PreapprovalAPI(CreatableAPIResource, UpdatableAPIResource,
                     SearchableAPIResource):
    _base_path = '/preapproval'

    def get(self, id):
        # NOTE: this is actually performing a search with ID and mangling
        # the response data to conform to a single object format.
        # There is no method to retrieve a preapproval by ID at the moment.
github federicobond / pymercadopago / mercadopago / api.py View on Github external
class CardTokenAPI(API):
    _base_path = '/v1/card_tokens'

    def create(self, public_key, **data):
        return self._client.post('/', params={'public_key': public_key}, json=data)

    def get(self, id, public_key):
        return self._client.get('/{id}', {'id': id}, params={'public_key': public_key})

    def update(self, id, public_key, **data):
        return self._client.put('/{id}', {'id': id}, params={'public_key': public_key}, json=data)


class CustomerAPI(RetrievableAPIResource, CreatableAPIResource,
                  UpdatableAPIResource, DeletableAPIResource,
                  SearchableAPIResource):
    _base_path = '/v1/customers'

    def cards(self, id):
        return CardAPI(self._client, id)


class IdentificationTypeAPI(ListableAPIResource):
    _base_path = '/identification_types'


class InvoiceAPI(RetrievableAPIResource):
    _base_path = '/v1/invoices'