Skip to main content

Python SDK for integrating with the Getnet payment API

Project description

PyPI version [Python Version] [License]


Table of Contents

  1. About

  2. Features

  3. Requirements

  4. Installation

  5. Quickstart

  6. Configuration

  7. API Reference

  8. Contributing

  9. License

  10. Author


About

A lightweight, Pythonic SDK for the Getnet Web Checkout API, featuring:

  • TLS 1.2 out of the box
  • HMAC‑SHA256 authentication
  • Session creation, status checks, reversals, and detailed info

Features

  • 🔒 Secure: TLSAdapter for strict TLS 1.2 connections
  • 🔑 Authenticated: Nonce + seed + secret → tranKey
  • 💳 create_session: Start a payment session
  • ↩️ reverse_payment: Cancel a transaction
  • 📋 get_request_information: Full transaction details

Requirements


Installation

pip install getnet_sdk

or via source

git clone https://github.com/ninjaroot-509/getnet_sdk.git
cd getnet_sdk
pip install .

Quickstart

from getnet_sdk.client import GetnetClient

client = GetnetClient(
    login="YOUR_LOGIN",
    secret_key="YOUR_SECRET_KEY",
    return_url="https://yourapp.com/payment/return",
    sandbox=True
)

# 1. Create a payment session
session = client.create_session(
    order_id="ORD12345",
    total=1500.00,
    currency="CLP",
    buyer={
        "name": "Stanley Castin",
        "surname": "Ninjaroot",
        "email": "test@n1n24.dev",
        "document": "11111111-9",
        "documentType": "CLRUT",
        "mobile": "+509xxxxxxxx"
    },
    ip_address="0.0.0.0",
    user_agent="MyApp/1.0"
)
print(session)

# 2. Reverse a payment
reverse = client.reverse_payment(request_id=session["session"]["id"])
print(reverse)

# 3. Get full transaction info
info = client.get_request_information(request_id=session["session"]["id"])
print(info)

Configuration

Parameter Description
login Your Getnet merchant login
secret_key Your Getnet secret key
return_url Redirect URL after payment completion
sandbox True for test, False for production

API Reference

Initialization

client = GetnetClient(
    login: str,
    secret_key: str,
    return_url: str,
    sandbox: bool = True,
    session: requests.Session = None
)

create_session

create_session(
    order_id: str,
    total: float,
    currency: str = "CLP",
    buyer: dict = None,
    expiration_minutes: int = 15,
    locale: str = "es_CL",
    ip_address: str = None,
    user_agent: str = None,
    **extra_fields
) -> dict
  • Starts a new checkout session.
  • Returns (200 OK):
{
  "status": {
    "status": "OK",
    "reason": "PC",
    "message": "La petición se ha procesado correctamente",
    "date": "2022-02-05T14:48:15+00:00"
  },
  "requestId": "234567",
  "processUrl": "https://checkout.getnet.cl/session/xxxx/xxxxxxxxxxxxxxxxx"
}

reverse_payment

reverse_payment(request_id: str) -> dict
  • Cancels (reverses) a prior payment session.
  • Returns (200 OK):
{
  "status": {
    "status": "APPROVED",
    "reason": "00",
    "message": "Se ha reversado el pago correctamente",
    "date": "2022-02-05T18:54:49-05:00"
  },
  "payment": {
    "status": {
      "status": "APPROVED",
      "reason": "00",
      "message": "Aprobada",
      "date": "2022-02-05T18:54:49-05:00"
    },
    "internalReference": "1502099576",
    "paymentMethod": "visa",
    "paymentMethodName": "Visa",
    "issuerName": "BANCO DE PRUEBAS",
    "amount": {
      "from": {
        "currency": "CLP",
        "total": -2000
      },
      "to": {
        "currency": "CLP",
        "total": -2000
      },
      "factor": 1
    },
    "authorization": "000000",
    "reference": "123456",
    "receipt": "1611446089",
    "franchise": "CR_VS",
    "refunded": false
  }
}

get_request_information

get_request_information(request_id: str) -> dict
  • Retrieves full details for a session and its transactions.
  • Returns (200 OK):
{
  "requestId": 251623,
  "status": {
    "status": "APPROVED",
    "reason": "00",
    "message": "La petición ha sido aprobada exitosamente",
    "date": "2022-02-05T14:51:44+00:00"
  },
  "request": {
    "locale": "es_CL",
    "payer": {
      "document": "11.111.111-1",
      "documentType": "CLRUT",
      "name": "Luis",
      "surname": "Perez",
      "email": "luis.perez.prueba@gmail.com",
      "mobile": "+56999999999"
    },
    "payment": {
      "reference": "TEST_20220205_080946",
      "description": "Pago de pruebas",
      "amount": { "currency": "CLP", "total": 1000 }
    },
    "returnUrl": "https://dnetix.co/p2p/client",
    "ipAddress": "127.0.0.1",
    "userAgent": "PlacetoPay Sandbox",
    "expiration": "2022-02-05T09:45:46-05:00"
  },
  "payment": [
    {
      "amount": {
        "to": { "total": 1000, "currency": "CLP" },
        "from": { "total": 1000, "currency": "CLP" },
        "factor": 1
      },
      "status": {
        "date": "2022-02-05T14:51:44+00:00",
        "reason": "00",
        "status": "APPROVED",
        "message": "Aprobada"
      },
      "receipt": "303312009300",
      "refunded": false,
      "franchise": "PS_MC",
      "reference": "TEST_20220205_080946",
      "issuerName": "Bank",
      "authorization": "600236",
      "paymentMethod": "master",
      "processorFields": [
        { "value": "000896", "keyword": "merchantCode" },
        { "value": "10000001", "keyword": "terminalNumber" },
        { "value": "P", "keyword": "cardType" },
        { "value": "555912", "keyword": "bin" },
        { "value": 1, "keyword": "installments" },
        { "value": "4753", "keyword": "lastDigits" },
        { "value": "cbd306y665508789e150bacc84f4facd", "keyword": "id" },
        { "value": "000", "keyword": "b24" }
      ],
      "internalReference": 94236,
      "paymentMethodName": "Master"
    }
  ],
  "subscription": null
}

Contributing

  1. Fork the repo
  2. Create a feature branch
  3. Commit your changes
  4. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for details.


Author

Maintained by ninjaroot-509 https://github.com/ninjaroot-509/getnet_sdk

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

getnet_sdk-0.1.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

getnet_sdk-0.1.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file getnet_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: getnet_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for getnet_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f854bd305c30889ab8415ae9086b1f6fa2dff9f93b69d05ac3733f3486414bb2
MD5 b469074bb37f5702ecb34cc97e9f407f
BLAKE2b-256 a432c92d49b1d4e5ff85de81935e9ab5abb28fe6547ccf539132a04cf33341c0

See more details on using hashes here.

File details

Details for the file getnet_sdk-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: getnet_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for getnet_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dae3bf8836a428352e07381700239647c13379cee2ef592bedfb42b8a8440cf8
MD5 2b0311b5526e49d5cf33c3b1414b76db
BLAKE2b-256 944f18d4668a77b74d8688cb44d6298772febef3730f59c3a933da63a663e649

See more details on using hashes here.

Supported by

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