Skip to content

SDK para python pagos con tarjeta de credito,debito y cash

Notifications You must be signed in to change notification settings

epayco/epayco-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

223 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Epayco

Python wrapper for Epayco API

Description

API to interact with Epayco https://api.epayco.co

Installation

Installation

If you want to clone the repository, point it directly into our GitHub project:

$ git clone https://github.com/epayco/epayco-python.git
Install from Packages (Linux), Python = 3.7

Run the file setup.py:

$ sudo python3 setup.py install

Install the ePayco module:

$ pip install epaycosdk
Install from Packages (Windows), Python = 3.7

Run the file setup.py:

$ pip install setuptools
$ python setup.py install

Install the ePayco module:

$ pip install epaycosdk

Usage

import epaycosdk.epayco as epayco

apiKey = "PUBLIC_KEY"
privateKey = "PRIVATE_KEY"
lenguage = "ES"
test = True
options={"apiKey":apiKey,"privateKey":privateKey,"test":test,"lenguage":lenguage}

objepayco=epayco.Epayco(options)

Create Token

credit_info = {
  "card[number]": "4575623182290326",
  "card[exp_year]": "2025",
  "card[exp_month]": "19",
  "card[cvc]": "123",
  "hasCvv": True #// hasCvv: validar codigo de seguridad en la transacción
  }

token=objepayco.token.create(credit_info)

Customers

Create

customer_info = {
  "token_card": "eXj5Wdqgj7xzvC7AR",
  "name": "Joe",
  "last_name": "Doe", #This parameter is optional
  "email": "joe@payco.co",
  "phone": "3005234321",
  "default": True,
  "city": "Bogota",
  "address": "Cr 4 # 55 36",
  "phone": "3005234321",
  "cell_phone": "3010000001"
  }

customer=objepayco.customer.create(customer_info)

Retrieve

customer=objepayco.customer.get("id_client")

List

customer_info = {
    "page": 1, #number of pages
    "perPage": 5 #number of customers per page
}
customers = objepayco.customer.getlist(customer_info)

Update

update_customer_info = {
  "customerId": "id_client",
  "name": "Alex"
}

customer =objepayco.customer.update(update_customer_info)

Delete Token

delete_customer_info = {
  "franchise": "visa",
  "mask": "457562******0326",
  "customer_id":"id_client"
}

customer =objepayco.customer.delete(delete_customer_info)

Add new token default to card existed

customer_info = {
    "customer_id":"id_client",
    "token": "**********Q2ZLD9",
    "franchise":"visa",
    "mask":"457562******0326"
}
customer=objepayco.customer.addDefaultCard(customer_info)

Add new token to customer existed

customer_info = {
    "token_card": "6tWRMjsiDGPds2Krb",
    "customer_id":"id_client"
}
customer=objepayco.customer.addNewToken(customer_info)

Plans

Create

plan_info = {
  "id_plan": "coursereact",
  "name": "Course react js",
  "description": "Course react and redux",
  "amount": 35700,
  "currency": "cop",
  "interval": "month",
  "interval_count": 1,
  "trial_days": 30,
  "ip": "000.00.000.000",
  "iva": 5700,
  "ico": 0,
  "planLink":"https://github.com/epayco",
  "greetMessage":"discounted react and redux course",
  "linkExpirationDate":"2025-03-11",
  "subscriptionLimit": 10, #Subscription limit between 0 and 10000
  "imgUrl":"https://epayco.com/wp-content/uploads/2023/04/logo-blanco.svg",
  "discountValue":5000, #discount value
  "discountPercentage":19, #discount percentage
  "transactionalLimit": 2, #transactional Limit
  "additionalChargePercentage":0.0, #Additional charge percentage limit
  "firstPaymentAdditionalCost":45700  #Installation Cost
}

plan = objepayco.plan.create(plan_info)

Retrieve

plan = objepayco.plan.get("coursereact")

List

planes = objepayco.plan.getlist()

Remove

plan = objepayco.plan.delete("coursereact")

Upadate

plan_info_update = {
    "name": "Course react js",
    "description": "Course react and redux",
    "amount": 35700,
    "currency": "cop",
    "interval": "month",
    "interval_count": 1,
    "trial_days": 30,
    "ip": "170.00.000.000",
    "iva": 1900,
    "ico": 0,
    #"transactionalLimit": 3,
    #"additionalChargePercentage":0.0,
    #"afterPayment":"message after paying"
}
plan = objepayco.plan.update(id_plan, plan_info_update)

Subscriptions

Create

subscription_info = {
    "id_plan": "coursereact2",
    "customer": "9xRxhaJ2YmLTkT5uz",
    "token_card": "eXj5Wdqgj7xzvC7AR",
    "doc_type": "CC",
    "doc_number": "0000000000",
    #Optional parameter: if these parameter it's not send, system get ePayco dashboard's url_confirmation
    "url_confirmation": "https://tudominio.com/confirmacion.php",
    "method_confirmation": "POST"
}

sub=objepayco.subscriptions.create(subscription_info)

Retrieve

sub=objepayco.subscriptions.get("efPXtZ5r4nZRoPtjZ")

List

sub=objepayco.subscriptions.getlist()

Cancel

sub=objepayco.subscriptions.cancel("fayE66HxYbxWydaN8")

Pay Subscription

subscription_info = {
  "id_plan": "coursereact",
  "customer": "A6ZGiJ6rgxK5RB2WT",
  "token_card": "eXj5Wdqgj7xzvC7AR",
  "doc_type": "CC",
  "doc_number": "1000000",
  "ip":"190.000.000.000"  #This is the client's IP, it is required

}

sub = objepayco.subscriptions.charge(subscription_info)

PSE

List Banks

banks = objepayco.bank.pseBank()

Create

pse_info = {
    "bank": "1007",
    "invoice": "147205",
    "description": "pay test",
    "value": "116000",
    "tax": float("16000"),
    "tax_base": float("100000"),
    "currency": "COP",
    "type_person": "0",
    "doc_type": "CC",
    "docNumber": "10000000",
    "name": "testing",
    "last_name": "PAYCO",
    "email": "no-responder@payco.co",
    "country": "CO",
    "cellPhone": "3010000001",
    "ip": "190.000.000.000",  # This is the client's IP, it is required,
    "url_response": "https://tudominio.com/respuesta.php",
    "url_confirmation": "https://tudominio.com/confirmacion.php",
    "metodoconfirmacion": "GET",
    # Los parámetros extras deben ser enviados tipo string, si se envía tipo array generara error.
    "extra1": "",
    "extra2": "",
    "extra3": "",
    "extra4": "",
    "extra5": "",
    "extra6": "",
    "extra7": ""
}

pse = objepayco.bank.create(pse_info)

Retrieve

pse = objepayco.bank.pseTransaction("ticketId")

Split Payments

Split payment

import json

pse_info = {
#Other customary parameters...
  "splitpayment":"true",
   "split_app_id":"P_CUST_ID_CLIENTE APPLICATION",
   "split_merchant_id":"P_CUST_ID_CLIENTE COMMERCE",
   "split_type" : "01",
   "split_primary_receiver" : "P_CUST_ID_CLIENTE APPLICATION",
   "split_primary_receiver_fee":"80000"
   "split_receivers": json.dumps([
            {"id":"P_CUST_ID_CLIENTE 1 RECEIVER","total":"58000","iva":"8000","base_iva":"50000","fee":"10"},
            {"id":"P_CUST_ID_CLIENTE 2 RECEIVER","total":"58000","iva":"8000","base_iva":"50000", "fee":"10"}
    ])
 }

pse_split = objepayco.bank.create(pse_info)

Cash

Create

    # paymentMethod: EF=> efecty, GA=>gana, PR=>puntored, RS=>redservi, SR=>sured
    cash_info = {
    "paymentMethod" :"EF",
    "invoice": "1472050778",
    "description": "pay test",
    "value": "116000",
    "tax": "16000",
    "tax_base": "100000",
    "currency": "COP",
    "type_person": "0",
    "doc_type": "CC",
    "docNumber": "100000",
    "name": "testing",
    "last_name": "PAYCO",
    "email": "test@mailinator.com",
    "cellPhone": "3010000001",
    "end_date": "2025-02-05",
    "ip": "190.000.000.000",  # This is the client's IP, it is required,
    "url_response": "https://tudominio.com/respuesta.php",
    "url_confirmation": "https://tudominio.com/confirmacion.php",
    "metodoconfirmacion": "GET",
    # Los parámetros extras deben ser enviados tipo string, si se envía tipo array generara error.
    "extra1": "",
    "extra2": "",
    "extra3": "",
    "extra4": "",
    "extra5": "",
    "extra6": "",
    "extra7": ""
}

cash = objepayco.cash.create(cash_info)

Retrieve

cash = epayco.cash.get("ref_payco")

Split Payments

Previous requirements: https://docs.epayco.co/tools/split-payment

Split payment:

use the following attributes in case you need to do a dispersion with one or multiple providers

import json

payment_info = {
#Other customary parameters...
    "splitpayment":"true",
    "split_app_id":"P_CUST_ID_CLIENTE APPLICATION",
    "split_merchant_id":"P_CUST_ID_CLIENTE COMMERCE",
    "split_type" : "02",
    "split_primary_receiver" : "P_CUST_ID_CLIENTE APPLICATION",
    "split_primary_receiver_fee":"0",
    "split_rule":'multiple', #si se envía este parámetro el campo split_receivers se vuelve obligatorio
    "split_receivers":json.dumps([
            {"id":"P_CUST_ID_CLIENTE 1 RECEIVER","total":"58000","iva":"8000","base_iva":"50000","fee":"10"},
            {"id":"P_CUST_ID_CLIENTE 2 RECEIVER","total":"58000","iva":"8000","base_iva":"50000", "fee":"10"}
    ]) #campo obligatorio sí se envía split_rule
    }

 cash_info_split = objepayco.cash.create('efecty',cash_info)

Payment

Create

payment_info = {
  "token_card": "token_card",
  "customer_id": "customer_id",
  "doc_type": "CC",
  "doc_number": "1000000",
  "name": "John",
  "last_name": "Doe",
  "email": "example@email.com",
  "bill": "OR-1234",
  "description": "Test Payment",
  "country": "CO",
  "city": "bogota",
  "value": "116000",
  "tax": "16000",
  "tax_base": "100000",
  "currency": "COP",
  "dues": "12",
  "ip":"190.000.000.000",  #This is the client's IP, it is required
  "url_response": "https://tudominio.com/respuesta.php",
  "url_confirmation": "https://tudominio.com/confirmacion.php",
  "method_confirmation": "GET",
  "use_default_card_customer":True, # if the user wants to be charged with the card that the customer currently has as default = true
  #Los parámetros extras deben ser enviados tipo string, si se envía tipo array generara error.
  "extra1": "",
  "extra2": "",
  "extra3": "",
  "extra4": "",
  "extra5": "",
  "extra6": "",
  "extra7": ""
}

pay = objepayco.charge.create(payment_info)

Retrieve

pay = epayco.charge.get("ref_payco")

Split Payments

Previous requirements https://docs.epayco.co/tools/split-payment

Split payment

use the following attributes in case you need to do a dispersion with one or multiple providers

import json

payment_info = {
#Other customary parameters...
    "splitpayment":"true",
    "split_app_id":"P_CUST_ID_CLIENTE APPLICATION",
    "split_merchant_id":"P_CUST_ID_CLIENTE COMMERCE",
    "split_type" : "02",
    "split_primary_receiver" : "P_CUST_ID_CLIENTE APPLICATION",
    "split_primary_receiver_fee":"0",
    "split_rule":'multiple', #si se envía este parámetro el campo split_receivers se vuelve obligatorio
    "split_receivers":[
            {"id":"P_CUST_ID_CLIENTE 1 RECEIVER","total":"58000","iva":"8000","base_iva":"50000","fee":"10"},
            {"id":"P_CUST_ID_CLIENTE 2 RECEIVER","total":"58000","iva":"8000","base_iva":"50000", "fee":"10"}
    ] #campo obligatorio sí se envía split_rule
    }

pay_split = objepayco.charge.create(payment_info)

Daviplata

Create

payment_info = {
    "doc_type": "CC",
    "document": "1053814580414720",
    "name": "Testing",
    "last_name": "PAYCO",
    "email": "exmaple@epayco.co",
    "ind_country": "57",
    "phone": "314853222200033",
    "country": "CO",
    "city": "bogota",
    "address": "Calle de prueba",
    "ip": "189.176.0.1",
    "currency": "COP",
    "description": "ejemplo de transaccion con daviplata",
    "value": "100",
    "tax": "0",
    "ico": "0"
    "tax_base": "0",
    "method_confirmation": "GET",
    "url_response": "https://tudominio.com/respuesta.php",
    "url_confirmation": "https://tudominio.com/confirmacion.php",
    "extra1": "",
    "extra2": "",
    "extra3": "",
    "extra4": "",
    "extra5": "",
    "extra6": "",
    "extra7": "",
    "extra8": "",
    "extra9": "",
    "extra10": ""
}

daviplata = objepayco.daviplata.create(payment_info)

confirm transaccion

confirm = {
    "ref_payco": "45508846", # It is obtained from the create response
    "id_session_token": "45081749", # It is obtained from the create response
    "otp": "2580"
}

daviplata = objepayco.daviplata.confirm(payment_info)

Safetypay

Create

payment_info = {
    "cash": "1",
    "end_date": "2021-08-05",
    "doc_type": "CC",
    "document"": "123456789",
    "name": "Jhon",
    "last_name": "doe",
    "email": "jhon.doe@yopmail.com",
    "ind_country": "57",
    "phone": "3003003434",
    "country": "CO",
    "invoice": "fac-01", # opcional
    "city": "N/A",
    "address": "N/A",
    "ip": "192.168.100.100",
    "currency": "COP",
    "description": "Thu Jun 17 2021 11:37:01 GMT-0400 (hora de Venezuela)",
    "value": 100000,
    "tax": 0,
    "ico": 0,
    "tax_base": 0,
    "url_confirmation": "https://tudominio.com/respuesta.php",
    "url_response": "https://tudominio.com/respuesta.php",
    "method_confirmation": "POST",
    "extra1": "",
    "extra2": "",
    "extra3": "",
    "extra4": "",
    "extra5": "",
    "extra6": "",
    "extra7": "",
    "extra8": "",
    "extra9": "",
    "extra10": ""
}

safetypay = objepayco.safetypay.create(payment_info)

About

SDK para python pagos con tarjeta de credito,debito y cash

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 13

Languages