Skip to main content

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

Release files for gpwebpay 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpwebpay 0.1.4
File Size Uploaded
gpwebpay-0.1.4.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gpwebpay 0.1.4
File Interpreter ABI Platform
gpwebpay-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size:11.1 kB

Release files / gpwebpay-0.1.4.tar.gz

Download URL gpwebpay-0.1.4.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
19362083bec744d2e8b0293e2fca2e42bcea31843b0f5ac6a75485a07028ec6f
BLAKE2b-256 checksum
How to use checksums
42832905ed918ca154ebe454821e03068b756dd3d4b52dd62164af6e13b2caba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.9 CPython/3.8.5 Linux/5.8.0-41-generic

Release files / gpwebpay-0.1.4-py3-none-any.whl

Download URL gpwebpay-0.1.4-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea908844561627185345ff222ed23c6c68177c2a75db88fa7b3e9a28f7f6e913
BLAKE2b-256 checksum
How to use checksums
f266c2917dd0c90cd36df53271872a6afb35987e999e2600f7bfda7b5f13542b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.9 CPython/3.8.5 Linux/5.8.0-41-generic

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page