基于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条件调用   类Dog中的java构造函数Dog不能应用于给定类型   java jsch和运行“sudo su”   java将队列和堆栈相互复制   java如何在netbeans项目的文件夹中添加库   java While循环在我的代码中不存在   如何在XML中使用java方法的返回值   java是否可以在不写入文件的情况下将字符串/字节数组作为文件发布?   java为什么这些字符串不相等?   sockets客户机-服务器java编程,用户可选择   java如何在SpringMVC和hibernate中保存模型返回视图的列表   java如何修复组织。openqa。硒。WebDriverException:未知错误   Java,Ant错误:编码Cp1252的不可映射字符   JAVAlang.ClassCastException:[Ljava.lang.String;与java.lang.String不兼容   java如何使用JDK8(可选)为空字段创建自定义IntelliJ getter模板   java Tomcat6响应。sendRedirect()404错误