Skip to main content

GPWebPay Gateway access with Python

Project description

gpwebpay

Build Tests codecov GitHub contributors Python 3.6+ License: MIT Code style

GPWebPay Gateway access with Python.

This library is meant to be used by merchants that own a webshop and use GpWebPay as its payment gateway. At the moment there are code examples for using GPWebPay in a webshop with PHP, where developers can see how to sign and verify messages exchanged with the payment gateway.

With this package you can also do it in Python and you can find an example of its usage in a webshop in the demoshop repository

Configuration

Environmental variables needed:

GPWEBPAY_MERCHANT_ID = "0987654321"     # Your merchant's id from gpwebpay
GPWEBPAY_MERCHANT_PRIVATE_KEY = ""      # Your merchant's private key base64 encoded (cat gpwebpay-pvk.key | base64 -w0)
GPWEBPAY_PUBLIC_KEY = ""                # GPWebPay's public key base64 encoded (cat gpwebpay-pub.key | base64 -w0)
GPWEBPAY_RESPONSE_URL = ""              # The url for the callback

Optional:

GPWEBPAY_CURRENCY = "978"                       # If not set EUR is the default currency
GPWEBPAY_DEPOSIT_FLAG = "1"                     # Requests instant payment
GPWEBPAY_MERCHANT_PRIVATE_KEY_PASSPHRASE = ""   # If any

To use this package create a GpwebpayClient:

import base64
import os

from gpwebpay import gpwebpay

gw = gpwebpay.GpwebpayClient()

# Get your merchant's private key
private_key = os.getenv("GPWEBPAY_MERCHANT_PRIVATE_KEY")
# Decode your private key with base64
private_key_bytes = base64.b64decode(private_key)

# Call this method to request a payment to GPWebPay.
# Returns a response, redirect to response.url to go to GPWebPay's and make the payment
# The order_number needs to be unique and the amount in cents.
gw.request_payment(order_numer="123456", amount=999, key=private_key_bytes)

# Get GPWebPay's public key
public_key = os.getenv("GPWEBPAY_PUBLIC_KEY")
# Decode it with base64
public_key_bytes = base64.b64decode(public_key)

# Call this method to verify the response from GPWebPay
# You need to pass here the url you received on the callback
# Its querystring contains the data to verify the message
gw.get_payment_result(url, key=public_key_bytes)

For more details refer to the GPWebPay documentation

Tests

To run the tests:

 pytest

Development

We use poetry to manage dependencies, packaging and publishing. If you want to develop locally install poetry and run:

poetry install

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

gpwebpay-0.1.4.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

gpwebpay-0.1.4-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file gpwebpay-0.1.4.tar.gz.

File metadata

  • Download URL: gpwebpay-0.1.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.5 Linux/5.8.0-41-generic

File hashes

Hashes for gpwebpay-0.1.4.tar.gz
Algorithm Hash digest
SHA256 19362083bec744d2e8b0293e2fca2e42bcea31843b0f5ac6a75485a07028ec6f
MD5 aaf4a55d84eb024d0baaec7df3d06740
BLAKE2b-256 42832905ed918ca154ebe454821e03068b756dd3d4b52dd62164af6e13b2caba

See more details on using hashes here.

File details

Details for the file gpwebpay-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: gpwebpay-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.5 Linux/5.8.0-41-generic

File hashes

Hashes for gpwebpay-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ea908844561627185345ff222ed23c6c68177c2a75db88fa7b3e9a28f7f6e913
MD5 83e101e5ce1389374995721695479278
BLAKE2b-256 f266c2917dd0c90cd36df53271872a6afb35987e999e2600f7bfda7b5f13542b

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