Skip to main content

PaymentsGate's Python SDK for REST API

Project description

Paymentsgate Python SDK for Payments REST API

Requirements

Installation

The simplest way to install SDK is to use PIP:

pip install paymentsgate

Basic usage

from paymentsgate import ApiClient, Credentials, Currencies


# minimal configuration
config = Credentials().fromFile('/path/to/credentials.json');

# create ApiClient
client = ApiClient(config, baseUrl='https://api.example.com');

# request quote
res = cli.Quote(
  {
    "amount": 10.10,
    "currency_from": Currencies.EUR,
    "currency_to": Currencies.AZN,
  }
)
print(res);

The credentials.json file is used to connect to the client and contains all necessary data to use the API. This file can be obtained in your personal cabinet, in the service accounts section. Follow the instructions in the documentation to issue new keys. If you already have keys, but you don't feel comfortable storing them in a file, you can use client initialization via variables. In this case, the key data can be stored in external storage instead of on the file system:

from paymentsgate import ApiClient, Credentials

config = Credentials(
  account_id="00000000-4000-4000-0000-00000000000a" 
  public_key="LS0tLS1CRUdJTiBSU0EgUFJJVkFUNSUlFb3dJQk..."
)

client = ApiClient(config, baseUrl='https://api.example.com');

...

*It is important to note that the data format for key transfer is base46.

Examples

create PayIn

res = cli.PayIn(
  {
    "amount": 10.10,
    "currency": Currencies.AZN,
    "invoiceId": "INVOICE-112123124",
    "clientId": "",
    "successUrl": "https://example.com/success",
    "failUrl": "https://example.com/fail",
    "type": InvoiceTypes.m10
  }
)
print(res);

create PayOut

res = cli.PayOut(
  {
    "amount": 5.12,
    "currencyTo": Currencies.EUR,
    "invoiceId": "INVOICE-112123124",
    "clientId": "CLIENT-003010023004",
    "baseCurrency": CurrencyTypes.fiat,
    "feesStrategy": FeesStrategy.add,
    "recipient": {
      "account_number": "4000000000000012",
      "account_owner": "CARD HOLDER",
      "type": CredentialsTypes.card
    }
  }
)
print(res);

Error handling

try:
  res = cli.PayOut(
    {
      "amount": 5.12,
      "currencyTo": Currencies.EUR,
      "invoiceId": "INVOICE-112123124",
      "clientId": "CLIENT-003010023004",
      "baseCurrency": CurrencyTypes.fiat,
      "feesStrategy": FeesStrategy.add,
      "recipient": {
        "account_number": "4000000000000012",
        "account_owner": "CARD HOLDER",
        "type": CredentialsTypes.card
      }
    }
  )
  print(res);
except APIAuthenticationError as err:
  print(f"Authentication fail: {err.message}")
except APIResponseError as err:
  print(f"Exception: {err.error}; Message: {err.message}")

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

paymentsgate-1.5.4.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

paymentsgate-1.5.4-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file paymentsgate-1.5.4.tar.gz.

File metadata

  • Download URL: paymentsgate-1.5.4.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.13.1 Darwin/24.3.0

File hashes

Hashes for paymentsgate-1.5.4.tar.gz
Algorithm Hash digest
SHA256 5f291fe677862432d391e4b8e5400347ee97e97483304361789ebb7fb6e42226
MD5 383511a7003fe98a150ba9a92d557f14
BLAKE2b-256 284375f8cc1b3bb2bb0cc1acf24ec1c3c4e2b7313554613f07cb35d1294e85ab

See more details on using hashes here.

File details

Details for the file paymentsgate-1.5.4-py3-none-any.whl.

File metadata

  • Download URL: paymentsgate-1.5.4-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.13.1 Darwin/24.3.0

File hashes

Hashes for paymentsgate-1.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2df5e0e920e57d2bc5ec42694ebc1c8c864c7536ed394f36ed0791a8aa511368
MD5 58f6d4572a4b0add4e5b981e1e3586e8
BLAKE2b-256 1b12f9a7c8bc989af1a341c5f8840bb3c05f9cb95e7972b0e5dbcb11425eba8e

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