Skip to main content

A Python scripts for consume eccomerce Api

Project description

Build Status README Cover Image

Netpay Ecommerce Python - SDK Python

Bienvenido a la documentación para usar los servicios de Netpay Ecommerce interactuando con scripts de python.

Instalacion

pip install netpay-ecommerce-python

Uso

Para utilizar los servicios es indispensable tener el token de autorización, para ello se utiliza el objeto AuthJwt, la respuesta contiene un array con un hash de respuesta y el código de respuesta del servicio:

import netpay_ecommerce

login_object = {
    'security': {
        "userName": "adrian@netpay.com",
        "password": "adm0n2"
    }
}

response = netpay_ecommerce.AuthJwt.create(login_object)

token = response["token"]
##eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ7XCJpZFwiOjI4NzAxLFwic3RvcmVJZFwiOjQwOTQ0LFwic3RvcmVJZEFjcVwiOlwiNTI5Mzk1XCIsXCJuYW1lXCI6XCJQT1NcIixcInVz...

Con el token ya es posible tener acceso a los demas servicios.

Tokenizacion de la tarjeta

Para poder realizar transacciones, el primer paso es crear un token de la tarjeta con la cual se realizara la transacciones. Para esto haremos uso del objeto TokenCard.

import netpay_ecommerce

jwt_token = "json web token"

token_card_object = {
    "username": "adrian@netpay.com",
    "storeApiKey": "6kQui=_ZJ4r15GRT5ix7Pot_sCObk1WG",
    "customerCard": {
        "cardNumber": "4000000000000004",
        "expirationMonth": "01",
        "expirationYear":  "24",
        "cvv": "123",
        "cardType": "001",
        "cardHolderName": "John Doe"
    }
}

response = netpay_ecommerce.TokenCard.create(data=token_card_object,token=jwt_token)

# Acceso a la tarjeta tokenizada
response["response"]["customerToken"]["token"]["publicToken"]
# GSlvaCAueF+Wl4zVg/ReUdWKeRKriNoSeDtISAqqdGPx4pEzy8t/3ckYPxJgfFdFIF9JNIm6sVHY3B+dbt8txg==

Servicio de Risk Manager

El Risk Manager evaluara el riesgo de la trasaccion y nos entregara un status de la transaccion. Eso lo realizaremos con el objeto RiskManager

import netpay_ecommerce

jwt_token = "json web token"

risk_manager_object = {  
    "storeApiKey":"6kQui=_ZJ4r15GRT5ix7Pot_sCObk1WG",
    "riskManager":{
        "promotion":"000000",
        "requestFraudService":{  
            "merchantReferenceCode":"14500049450000",
            "deviceFingerprintID":"086e46a7d7b0d22a8966feed39eefd1c881507939638",
            "bill":{  
            "city":"city",
            "country":"MX",
            "firstName":"mailto",
            "lastName":"mailto",
            "email":"accept@netpay.com.mx",
            "phoneNumber":"8110000011",
            "postalCode":"12345",
            "state":"state",
            "street1":"street 1",
            "street2":"street 2",
            "ipAddress":"10.0.0.1"
            },
            "ship":{  
            "city":"city ship",
            "country":"MX",
            "firstName":"mailto",
            "lastName":"mailto",
            "phoneNumber":"8110111111",
            "postalCode":"12345",
            "state":"state",
            "street1":"street 1",
            "street2":"street 2",
            "shippingMethod":"flatrate_flatrate"
            },
            "itemList":[{  
                "id":"421",
                "productSKU":"wbk012c-Royal Blue-S",
                "unitPrice":"1.0000",
                "productName":"Elizabeth Knit Top",
                "quantity":1,
                "productCode":"Tops & Blouses"
            }
            ],
            "card":{  
            "cardToken":"VW2FdHVU6BXGoiR99teVRKnuvIE897u7AMlh8MVHprBr4/LHIv6r7Nn0SwNEfsEfx8i7ngLOZyEL+eLsKoZCGg=="
            },
            "purchaseTotals":{  
            "grandTotalAmount":"6",
            "currency":"MXN"
            },
            "merchanDefinedDataList":[{  
                "id":2,
                "value":"Web"
            },{  
                "id":4,
                "value":"515"
            },{  
                "id":5,
                "value":"0"
            },{  
                "id":6,
                "value":"0"
            },{ 
                "id":7,
                "value":"0"
            },{  
                "id":9,
                "value":"Retail"
            },{  
                "id":10,
                "value":"3D"
            },{  
                "id":11,
                "value":"flatrate_flatrate"
            },{  
                "id":13,
                "value":"N"
            },{  
                "id":14,
                "value":"Domicilio"
            },{  
                "id":"16",
                "value":"50000"
            }]
        }
    }   
}

response = netpay_ecommerce.RiskManager.create(data=token_card_object,token=jwt_token)

response["transactionTokenId"] 
# 138f8b75-3d13-4fff-ac8b-29da3f99b851

# Estatus
response["status"]
# CHARGEABLE 

Endpoints Disponibles

netpay_ecommerce.AuthJwt.create()
netpay_ecommerce.TokenCard.create()
netpay_ecommerce.CustomerTokens.create()
netpay_ecommerce.RiskManager.create()
netpay_ecommerce.WebAuthorizer.create()
netpay_ecommerce.Transaction.create()
netpay_ecommerce.TransactionRefund.create()
netpay_commerce.TokenCardDelete.create()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netpay-ecommerce-python-1.0.2.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file netpay-ecommerce-python-1.0.2.tar.gz.

File metadata

  • Download URL: netpay-ecommerce-python-1.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.14

File hashes

Hashes for netpay-ecommerce-python-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c0f4be4c04e6d6866141ca1b2c21efef9a91bd9aedaef0217e58a46090c7e7b8
MD5 6f382b1b7b7b81e9259963a63a0a3bf1
BLAKE2b-256 d0eefadd3dd1746daae1e0feaca9445e1a1e227b57ff0a090b94b6a59734aa83

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page