Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
This library is still in the process of being created. It is not recommended to use it yet in development. The PaymentAPI and QRAPI development process will be incorporated gradually.
Enzona's payment platform API access library (https://www.enzona.net/)
pip install enzona-api
Requires Python >= 3.5 with pip. (https://pypi.org/project/enzona-api/)
To acquire the credentials to use this platform you must register your business at https://bulevar.enzona.net/. Once you have registered your business, to make the corresponding API requests you must access https://api.enzona.net/store/. The credentials for access to the above system, must be sent to your email within 72 hours (At the time of this publication, the granting of credentials was paralyzed but will be continued thereafter). Authenticated you must check if the registered commerce appears from the Applications section:
We enter our shop and in Production Keys we notice that we have two keys, Consumer Key and the Consumer Secret. Both keys must be copied in order to use the enzyme_api library.
from enzona_api.enzona_business_payment import enzona_business_payment
ebp = enzona_business_payment(CONSUMER_KEY, CONSUMER_SECRET)
merchant_uuid = "her put your merchant_uuid" #your merchant_uuid
SHIPPING = 10.0
DISCOUNT = 2.0
TIP = 5.0
MERCHANT_OP_ID = 950201146651 #your market identifier
INVOICE_NUMBER = 1004 #invoice number
TERMINAL_ID = 12121 #terminal identifier (POS, Cash Register, etc.)
URL_RETURN = "http://www.example.com/return_payment"
URL_CANCEL = "http://www.example.com/cancel_payment"
product1 = Product(name="producto1", description="description1", quantity=1, price=403.5, tax=20.18)
product2 = Product(name="producto2", description="description2", quantity=2, price=300.0, tax=15.0)
lst_products = [product1.get_product(), product2.get_product()]
pay = Payments(
merchant_uuid=merchant_uuid,
description_payment= "Description pay",
currency="CUP",
shipping=SHIPPING,
discount=DISCOUNT,
tip=TIP,
lst_products=lst_products,
merchant_op_id=MERCHANT_OP_ID,
invoice_number=INVOICE_NUMBER,
return_url=URL_RETURN,
cancel_url=URL_CANCEL,
terminal_id=TERMINAL_ID
)
response = ebp.create_payments(payment=pay.get_payment())
transaction_uuid = response.transaction_uuid()
link_confirm = response.link_confirm()
The function create_payments returns an object of type response_payments with the following functionalities
The url value set in URL_RETURN corresponds to the url that will redirect Enzona once the platform is successfully completed. URL_CANCEL is the url in case of cancellation.
In case of an effective payment you must make a confirmation of the payment:
response = ebp.complete_payments(transaction_uuid=transaction_uuid)
print(response.transaction_uuid())
print(response.status_denom())
When a successful payment is made from the platform, it returns to URL_RETURN with a transaction_uuid value in its GET request:
Example: www.example.com/complete_payment?transaction_uuid=eff02133c1724287b10860824c596777
That value must be captured and the payment confirmation created. The complete_payments function returns an object of type response_operation_payments:
In case of cancellation of a payment:
response = ebp.cancel_payments(transaction_uuid=transaction_uuid)
print(response.transaction_uuid())
print(response.status_denom())
The function cancel_payments returns a response_operation_payments object and cancels the initiated payment.
To make a partial payment you must use the payments_refund function with the Payload parameter that indicates the value you want to return to the customer. Not using this parameter indicates that a full payment has been made:
#Pago parcial
payload = Payload(total=20.0, description="devolucion parcial1")
response = ebp.payments_refund(transaction_uuid="57c5c848b00743db922022c92ad1d24f", Payload=payload)
print(response.transaction_uuid())
print(response.created_at())
print(response.amount_total())
print(response.description())
print(response.refund_fullname())
#Pago total
response = ebp.payments_refund(transaction_uuid="57c5c848b00743db922022c92ad1d24f")
print(response.transaction_uuid())
print(response.created_at())
print(response.amount_total())
print(response.description())
print(response.refund_fullname())
The payments_refund function returns a response_refound type object with the following functionality:
To obtain all the payments made, you must use the get_payments function, which returns a list of the payment data. This has several parameters:
merchant_uuid: Merchant Identifier
offset: Where to start displaying the data (Default 0)
limit: Amount of data to be displayed (Default 10)
status_filter: Filter by payment status
start_date_filter: Initial date for filtering payments
end_date_filter: Final date for filtering payments
payments = ebp.get_payments(merchant_uuid=merchant_uuid)
for payment in payments.get_payments():
print(payment.invoice_number())
print(payment.amount_total())
print(payment.amount_tip())
print(payment.amount_discount())
print(payment.amount_shipping())
print(payment.amount_tax())
print(payment.status_denom())
print(payment.commission())
print("")
In order to know the merchant_uid of your market you must enter the Enzona platform in the merchant section (https://www.enzona.net/merchant) and in the list of your merchants press Details of your market and a series of information will appear that you introduced during the creation of the trade. The merchant_uuid is the market ID.
To obtain the returns made you use the function get_payments_refund that will return an object of type response_get_refound that is a list of the return operations:
response = ebp.get_payments_refund(merchant_uuid=merchant_uuid)
refunds = response.get_refunds()
for refund in refunds:
print(refund["transaction_uuid"])
print(refund["refund_fullname"])
print(refund["refunded"])
print(refund["total_refunded"])
print(refund["total"])
print("")
FAQs
Enzona's payment platform API access library
We found that enzona-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.