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!
culqi-python-oficial
Advanced tools
Nuestra Biblioteca PYTHON oficial, es compatible con la v2.0 del Culqi API, con el cual tendrás la posibilidad de realizar cobros con tarjetas de débito y crédito, Yape, PagoEfectivo, billeteras móviles y Cuotéalo con solo unos simples pasos de configuración.
Nuestra biblioteca te da la posibilidad de capturar el status_code
de la solicitud HTTP que se realiza al API de Culqi, así como el response
que contiene el cuerpo de la respuesta obtenida.
Recuerda que para obtener tus llaves debes ingresar a tu CulqiPanel > Desarrollo > API Keys.
Recuerda que las credenciales son enviadas al correo que registraste en el proceso de afiliación.
Ejecuta los siguientes comandos:
py -m pip install pytest
py -m pip install python-dotenv
py -m pip install culqi
py -m pip install jsonschema
py -m pip install pycryptodome
Para empezar a enviar peticiones al API de Culqi debes configurar tu llave pública (pk), llave privada (sk). Para habilitar encriptación de payload debes configurar tu rsa_id y rsa_public_key.
from dotenv import load_dotenv
from culqi2 import __version__
from culqi2.client import Culqi
self.public_key = "pk_test_e94078b9b248675d"
self.private_key = "sk_test_c2267b5b262745f0"
self.culqi = Culqi(self.public_key, self.private_key)
#ecnrypt variables
self.rsa_public_key = "-----BEGIN PUBLIC KEY-----\n" + \
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDswQycch0x/7GZ0oFojkWCYv+g\n" + \
"r5CyfBKXc3Izq+btIEMCrkDrIsz4Lnl5E3FSD7/htFn1oE84SaDKl5DgbNoev3pM\n" + \
"C7MDDgdCFrHODOp7aXwjG8NaiCbiymyBglXyEN28hLvgHpvZmAn6KFo0lMGuKnz8\n" + \
"iuTfpBl6HpD6+02SQIDAQAB\n" + \
"-----END PUBLIC KEY-----"
self.rsa_id = "de35e120-e297-4b96-97ef-10a43423ddec"
Para encriptar el payload necesitas agregar el parámetros options que contiene tu id y llave RSA.
Ejemplo
options = {}
options["rsa_public_key"] = self.rsa_public_key #"la llave pública RSA"
options["rsa_id"] = self.rsa_id # "el id de tu llave"
token = self.token.create(data=self.token_data, **options)
token = self.token.create(data=self.token_data)
charge = self.charge.create(data=self.charge_data)
plan = self.plan.create(data=self.plan_data)
customer = self.customer.create(data=self.customer_data)
updated_customer = self.customer.update(
id_=created_customer["data"]["id"], data=metadatada
)
retrieved_customer = self.customer.read(created_customer["data"]["id"])
card = self.card.create(data=self.card_data)
subscription = self.subscription.create(data=self.subscription_data)
refund = self.refund.create(data=self.refund_data)
En la caperta /test econtraras ejemplo para crear un token, charge, plan, órdenes, card, suscripciones, etc.
Recuerda que si quieres probar tu integración, puedes utilizar nuestras tarjetas de prueba.
@pytest.mark.vcr()
def test_token_create(self):
token = self.token.create(data=self.token_data)
print(token)
assert token["data"]["object"] == "token"
@property
def charge_data(self):
# pylint: disable=no-member
token_data = deepcopy(Data.TOKEN)
token = self.culqi.token.create(data=token_data)
print(token)
charge_data = deepcopy(Data.CHARGE)
charge_data["source_id"] = token["data"]["id"]
return charge_data
@pytest.mark.vcr()
def test_charge_create(self):
charge = self.charge.create(data=self.charge_data)
print (charge)
assert charge["data"]["object"] == "charge"
Todos los cambios en las versiones de esta biblioteca están listados en CHANGELOG.md.
Team Culqi
El código fuente de culqi-python está distribuido bajo MIT License, revisar el archivo LICENSE.
FAQs
Biblioteca de Culqi para Python
We found that culqi-python-oficial demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.