帮助创建mobilpay在线支付所需xml的库

mobilp的Python项目详细描述


移动电话

mobilpy帮助您实现所需的一切 mobilPay的在线支付 解决方案。步骤:-创建帐户-获得批准-创建商家 -下载密钥(私有和公共)-复制签名(仅 字符串)

note您将拥有两个私钥:用于测试和生产。这个 公钥是相同的。

安装

要安装库,请运行:

pip install mobilpy

使用量

frommobilpyimportClient# the signature for your accountsignature='DLAN-1R5V-19EN-XXXX-NFJA'# the path to the public keypublic_key="./sandbox.DLAN-1R5V-19EN-XXXX-NFJA.public.cer"# the private_keyprivate_key="./sandbox.DLAN-1R5V-19EN-XXXX-NFJA.private.key"client=Client(signature=signature,public_key=public_key,private_key=private_key)# optional dict containing details about the customer# if they are sent, the customer will have a short checkout by skipping the second step in the payment flowbilling_details={"first_name":"","last_name":"","address":"","phone":"","email":""}# optional dict with details that you would need internally# these are returned when the webhook is calledparams={"subscription_id":"","basket_id":"",etc.}options={"order_id":""# int/string, max 64 length"currency":"RON",# string, RON or other"amount":1,# float, between 0.10 and 99999"customer_id":"",# int/string"details":"",# string, description for this transaction"billing":billing_details,# dict, OPTIONAL"params":params,# dict, OPTIONAL,# the webhook where the response from mobilPay will be sent"confirm_url":"",# the url where the user will be redirected"return_url":""}response=client.create_payment_data(**options)

response是一个dict,它有两个键:env_keydata。 这些需要在前端使用,并向mobilpay提出请求。

例如,html可能如下所示:

<formaction="http://sandboxsecure.mobilpay.ro"method="post"><inputtype="hidden"name="env_key"value="{{ env_key }}"><inputtype="hidden"name="data"value="{{ data }}"><inputtype="submit"value="Send"></form>

表单的post url是:-测试: http://sandboxsecure.mobilpay.ro-生产: https://secure.mobilpay.ro

webhook

mobilpay将对您设置为的url发出POST请求 confirm_url。mobilpy有一些方法可以帮助您解析它并提供 回应。

post=# get the post dataenv_key=post.get('env_key')data=post.get('data')client=Client(signature=signature,public_key=public_key,private_key=private_key)request_xml=client.decrypt_message(env_key,data)request_object=client.parse_request_xml(request_xml)# do some magic

为了检查交易是否成功,您需要检查 error_codeaction

transaction_successful=request_object.get('error_code')=='0'andrequest_object.get('action')=='confirmed'iftransaction_successful:# everything is ok

创建响应

你需要让mobilpay知道你的终端是否一切正常或者 奇怪的事情发生了。如果一切正常,您可以创建一个响应 像这样:

message="All good captain"response_xml=client.create_reponse(message=message)

如果出现错误:

# message that will help you debug. it will appear in your dashboardmessage="Everything is on fire"# this can be "1" (temporary error) or "2" (permanent error)error_type="1"# your internal error code. a number maybe. OPTIONALerror_code=''response_xml=client.create_reponse(message=message,error_type=error_type,error_code=error_code)

响应不需要加密。只需用xml响应。

计入

如果交易是从仪表板贷记的,则MobilPay将 新webhookPOST。您可以查看:

# if the transaction was credited from mobilpayifrequest_object.get('action')=='credit':# do something# return a reponse

待办事项

一些仍然需要做的事情: -测试 -依赖项太多:pyopenssl和pycrypto -迁移到pycryptome(不维护pycrypto) -添加对以下项的支持:不稳定,重复 -可能会添加预填的信用卡数据支付?

免责声明

此库与MobilPay没有任何关联

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

推荐PyPI第三方库


热门话题
反射Java反射:高负载下的NoSuchMethodException   java RxJava:one request>list of Integer>sequence of requests for each int>result to list   java为什么循环之前索引会增加   JavaSpring远程处理和RESTfulURL   java Hibernate搜索仅对我的实体的一部分进行索引   使用DPAD快速滚动时,java RecyclerView onCreateViewHolder调用过多   java将JSON解析到一个表中   java导航抽屉标题textview nullpointerexception   基于接口的Java链接队列   java Guice运行时依赖项参数重新注入   java展平/压缩ZSH中的深度嵌套目录   JavaSpring:Http406此请求标识的资源只能   java如何制作Android启动器图标   Java代码在windows上显示不正确(包含希腊语句子)   使用yourkit进行内存分析所用的java时间   java为什么可以序列化属性而不能序列化对象本身?