Commit cb207a04 authored by StongLory's avatar StongLory
Browse files

Added support for receiving optional/required fields for payment outlets

parent 2b789f77
Pipeline #203702207 passed with stage
in 0 seconds
......@@ -7,80 +7,26 @@ from urllib.parse import urlparse, urlencode
import requests
_base_url_v2 = None
_base_url = None
_key = None
_secret = None
_base_url_v2: str = ""
_base_url: str = ""
_key: str = ""
_secret: str = ""
OUTLETS = {
"co": {
"available": "1",
"daily_limit": "250000.00",
"fee": "0.00",
"id": "co",
"maximum_transaction": "250000.00",
"minimum_transaction": "1.00",
"name": "Retiro en Efectivo",
"net": "1000.00",
"optional_fields": [
"receiver_message",
"agency_message"
],
"required_fields": [
"sender_first_name",
"sender_last_name",
"sender_address",
"sender_phone",
"sender_countycity",
"sender_state",
"receiver_first_name",
"receiver_last_name",
"receiver_address",
"receiver_phone",
"receiver_city",
"receiver_state",
"payout_point_id"
],
"verification_level_requirement": "4"
},
"dc": {
"available": "1",
"daily_limit": "2500000.00",
"fee": "0.00",
"id": "dc",
"maximum_transaction": "2500000.00",
"minimum_transaction": "1.00",
"name": "Tarjeta de Debito",
"net": "1000.00",
"optional_fields": [
"notes_ref",
"numeric_ref",
"bank_name"
],
"required_fields": [
"recipient_given_names",
"recipient_family_names",
"card_number",
"institution_code"
],
"verification_level_requirement": "1"
},
"eth": {
OUTLETS = [
{
"available": "1",
"daily_limit": "0.00",
"fee": "0.00",
"id": "eth",
"id": "bch",
"maximum_transaction": "0.00",
"minimum_transaction": "0.00",
"name": "Ethereum",
"net": "1000.00",
"minimum_transaction": "1.00",
"name": "Bitcoin Cash",
"net": "0.00",
"optional_fields": [],
"required_fields": [
"address"
],
"required_fields": [],
"verification_level_requirement": "0"
},
"sp": {
{
"available": "1",
"daily_limit": "2500000.00",
"fee": "0.00",
......@@ -90,42 +36,44 @@ OUTLETS = {
"name": "Transferencia SPEI",
"net": "1000.00",
"optional_fields": [
"notes_ref",
"numeric_ref",
"bank_name",
"rfc"
{
"id": "notes_ref",
"name": "Notas de referencia"
},
{
"id": "numeric_ref",
"name": "Número de referencia"
},
{
"id": "bank_name",
"name": "Nombre de institución financiera"
},
{
"id": "rfc",
"name": "RFC"
}
],
"required_fields": [
"recipient_given_names",
"recipient_family_names",
"clabe"
{
"id": "recipient_given_names",
"name": "Nombre del beneficiario"
},
{
"id": "recipient_family_names",
"name": "Apellidos del beneficiario"
},
{
"id": "clabe",
"name": "CLABE interbancaria"
}
],
"verification_level_requirement": "1"
},
"vo": {
"available": "1",
"daily_limit": "0.00",
"fee": "0.00",
"id": "vo",
"maximum_transaction": "9999.00",
"minimum_transaction": "25.00",
"name": "Voucher",
"net": "1000.00",
"optional_fields": [],
"required_fields": [
"email_address",
"recipient_given_name"
],
"verification_level_requirement": "0"
}
}
]
def get_outlets(id=None):
if id is None:
return {"outlets": OUTLETS}
elif id in OUTLETS:
return {"outlets": OUTLETS[id]}
def get_outlets():
return {"outlets": OUTLETS}
def current_milli_time():
......
......@@ -19,6 +19,7 @@ from werkzeug.middleware.proxy_fix import ProxyFix
import bitso_api
import exchangerate
import verifier
from bitso_api import OUTLETS
load_dotenv(verbose=True)
......@@ -209,10 +210,11 @@ def create_payment_request(ip_addr, amount="", label="", address=None):
def generate_payment(parameters, ip_addr):
parameters = parameters.to_dict()
if "amount" not in parameters:
abort(400, "Specify an amount!")
_amount = parameters.get("amount")
_amount = parameters.pop("amount")
_label = False
_payment = False
_uri = ""
......@@ -221,23 +223,23 @@ def generate_payment(parameters, ip_addr):
_qr_params = "&amount=" + _amount
if "label" in parameters:
_label = parameters.get("label")
_label = parameters.pop("label")
_qr_params += "&label=" + _label
_uri_params += "&message=" + _label
if "outlet" in parameters:
_quote = bitso_api.tranfer_quote(from_amount=_amount)
_rate = _quote['rate']
_outlet = parameters.get("outlet")
# _transfer = bitso_api.transfer_create(from_amount=_amount, rate=_rate, payment_outlet=_outlet)
_transfer = {
"expires_at": (datetime.now() + timedelta(seconds=60)).timestamp(),
"wallet_address": "bchtest:qqmcnayqr78npapp0sgvceyve6us9w07tuueydpkp8",
"qr_img_uri": "https:\/\/chart.googleapis.com\/chart?chl=bitcoin%3AmgKZfNdFJgztvfvhEaGgMTQRQ2iHCadHGa%3Famount%3D0.14965623&chs=400x400&cht=qr&choe=UTF-8&chld=L%7C0"
}
_expires = _transfer['expires_at']
_addr = create_payment_request(ip_addr=ip_addr, amount=_amount, label=_label,
address=_transfer['wallet_address'])
_outlet_id = parameters.pop("outlet")
_outlet = next((outlet for outlet in OUTLETS if outlet['id'] == _outlet_id), None)
if _outlet['id'] == 'sp':
_quote = bitso_api.tranfer_quote(from_amount=_amount)
_rate = _quote['rate']
_transfer = bitso_api.transfer_create(from_amount=_amount, rate=_rate, payment_outlet=_outlet, **parameters)
_expires = _transfer['expires_at']
_addr = create_payment_request(ip_addr=ip_addr, amount=_amount, label=_label,
address=_transfer['wallet_address'])
else:
_expires = (datetime.now() + timedelta(seconds=60)).timestamp()
_addr = create_payment_request(ip_addr=ip_addr, amount=_amount, label=_label)
else:
_expires = (datetime.now() + timedelta(seconds=60)).timestamp()
_addr = create_payment_request(ip_addr=ip_addr, amount=_amount, label=_label)
......@@ -781,17 +783,11 @@ class CreateTransfer(Resource):
@bitsoAPI.route("/outlet")
@bitsoAPI.doc(
description="Get available payment outlets and required fields of each.",
params={
"id": "Payment outlet id"
}
description="Get available payment outlets and required fields of each."
)
class Outlet(Resource):
def get(self):
_parameters = request.values
_id = _parameters.get("id")
_json = bitso_api.get_outlets(_id)
_json = bitso_api.get_outlets()
resp = make_response(_json)
headers(resp)
resp.headers["Content-type"] = "application/json"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment