基于Python的GPWebPay网关访问

gpwebpa的Python项目详细描述


GPWeb页面

BuildTestscodecovGitHub contributorsPython 3.6+License: MITCode style

使用Python访问GPWebPay网关。在

这个库是为那些拥有一个网店并使用gpwebay作为其支付网关的商家使用的。 目前,有一些代码示例可以在带有PHP的webshop中使用gpwebay,开发人员可以在其中看到如何使用 签署并验证与支付网关交换的消息。在

有了这个包,您还可以在Python中完成它,并且可以在 demoshop repository

配置

需要的环境变量:

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

可选:

^{pr2}$

要使用此包,请创建GPWebCyclient:

importbase64importosfromgpwebpayimportgpwebpaygw=gpwebpay.GpwebpayClient()# Get your merchant's private keyprivate_key=os.getenv("GPWEBPAY_MERCHANT_PRIVATE_KEY")# Decode your private key with base64key_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_bytes=key_bytes)# Get GPWebPay's public keypublic_key=os.getenv("GPWEBPAY_PUBLIC_KEY")# Decode it with base64key_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 messagegw.is_callback_valid(url,key_bytes=key_bytes)

有关详细信息,请参阅GPWebPay documentation

测试

要运行测试:

 pytest

发展

我们使用诗歌来管理依赖关系、打包和发布。 如果要在本地开发install poetry并运行:

poetry install

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何使用泛型在Java中生成通用方法?   java从ISO/IEC 197944图像数据文件创建图像   java实现RSA的代码有什么问题?   javascript如何将JsonArray从解析云检索到安卓?   在vaadin中上传和下载java文件   java ListView自定义适配器OnClick启动URL链接   java在一个hbox中提供两个元素的独立对齐   java用类名创建类   java从unix命令行运行jar文件   java FTP下载在文件#146处停止