一,alipay方式

1,国内的alipay支付:我在网上找了好多的教程,大多数都是属于国内内支付的,所以在这里我就不详细介绍了,

  操作:https://www.cnblogs.com/xuanan/p/7892052.html

 2,境外的alipay支付: 

使用python内置的模块:Alipay

alipay_client =Alipay(
pid=PID,
key=商户的key,
seller_email=商家的email
)

接口的集成:

data={
'partner': PID,
'_input_charset': "utf-8",
'notify_url':异步回调接口,
'return_url':付款后返回给用户的接口,
'out_trade_no': 订单号,
'subject': subject,
'currency': "USD(货币)",
'total_fee':价钱(美元),
'body':'Alwayshoming system service.',
'app_pay':'Y'
}

电脑网页版api:

order_string=alipay_client.create_forex_trade_url(**data)

手机网页版api:

order_string=alipay_client.create_forex_trade_wap_url(**data)

二,Paypal支付

使用paypal支付有两种操作方法,

1,是将数据封装好,然后在使用requests去请求Paypal的付款接口

   2,就是使用python支付模块:paypalrestsdk

按钮的集成:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body> <div id="paypal_button"></div>
<script> $(document).ready(function(){
init_paypal();
});
function init_paypal(){
paypal.Button.render({ env: 'production', // Or 'sandbox',
client: {
sandbox: '*****',
production: '*****'
},
commit: true, // Show a 'Pay Now' button style: {
label: 'paypal',
size: 'medium', // small | medium | large | responsive
shape: 'rect', // pill | rect
color: 'blue', // gold | blue | silver | black
tagline: false
}, payment: function(data, actions) {
/* Set up the payment here */
var create_data = {
"order_id": order_id
};
var CREATE_URL = *****;
return paypal.request({method: 'post',
url: CREATE_URL,
data: create_data,
headers: {
'X-CSRFToken': CSRF_TOKEN
}
}).then(function(res) {
return res.paymentID;
});
}, onAuthorize: function(data, actions) {
/* * Execute the payment here */
var EXECUTE_URL = *****';
// Set up the data you need to pass to your server
var datas = {
"paymentID": data.paymentID,
"payerID": data.payerID,
"order_id":order_id
};
// Make a call to your server to execute the payment
return paypal.request({method: 'POST',
url: EXECUTE_URL,
data:datas,
headers: {
'X-CSRFToken': CSRF_TOKEN
}
}).then(function (res) {
if(res.code !== 0) {
alert(res.error.message);
} else {
window.alert(res.data);
window.location.href = *****;
}
}); },
onCancel: function(data, actions) {
/*Buyer cancelled the payment*/
window.alert('Payment Cancel');
}, onError: function(err) {
/*
* An error occurred during the transaction
*/
window.alert(*****);
}
}, '#paypal_button');
} </script> </body>
</html>

       在使用paypalrestsdk集成支付接口对象

paypalrestsdk.configure({
"mode": "live", # sandbox or live
"client_id": "********",
"client_secret": "*******"})

   加入付款信息:

payment = paypalrestsdk.Payment({
"intent": "***",
"payer": {
"payment_method": "paypal"},
"redirect_urls": {
"return_url": "****",
"cancel_url": "***"},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": order.price,
"currency": "USD",
"quantity": 1}]},
"amount": {
"total": order.price,
"currency": "USD"},
"description": description}]})

    确认付款:

payment = paypalrestsdk.Payment.find(payment_id)  

三,stripe信用卡支付

详细使用方法:https://stripe.com/docs

python进行支付:

def stripe_payment(request):
if request.is_ajax():
if request.method == 'POST':
pay_data = request.data
token = pay_data['token']
order_id = pay_data['order_id']
description = pay_data['description']
price = 价钱乘以100
try:
stripe.api_key = "sk_test_QPtlnU7Sl7skmuOZWAmqyuTO"
charge = stripe.Charge.create(
amount=price,
currency='usd',
description=description,
source=token,
)
result = 'Payment ' + charge['status']
except Exception as e:
result = e.message
return Response({'code': 0, 'data': result})

  

python之支付的更多相关文章

  1. Python支付宝在线支付API

    一.蚂蚁金服开发平台申请测试账号 a. 登陆蚂蚁金服开放平台https://open.alipay.com/platform/manageHome.htm,在“开发中心”—“研发服务”下拉处选择沙箱作 ...

  2. 微信支付 python版

    需求: 微信打开商品列表页面-> 点击商品后直接显示付款页面-> 点击付款调用微信支付 说明 微信支付需要你申请了公众号(appid, key - 用于签名), 商户号(mch_id, A ...

  3. 第四百零三节,python网站在线支付,支付宝接口集成与远程调试,

    第四百零三节,python网站在线支付,支付宝接口集成与远程调试, windows系统安装Python虚拟环境 首先保证你的系统已经安装好了Python 安装virtualenv C:\WINDOWS ...

  4. python 全栈开发,Day106(结算中心(详细),立即支付)

    昨日内容回顾 1. 为什么要开发路飞学城? 提供在线教育的学成率: 特色: 学,看视频,单独录制增加趣味性. 练,练习题 改,改学生代码 管,管理 测,阶段考核 线下:8次留级考试 2. 组织架构 - ...

  5. python 全栈开发,Day102(支付宝支付)

    昨日内容回顾 1. django请求生命周期? - 当用户在浏览器中输入url时,浏览器会生成请求头和请求体发给服务端 请求头和请求体中会包含浏览器的动作(action),这个动作通常为get或者po ...

  6. s11 day 101 python Linux环境安装 与路飞项目支付功能

    from django.conf.urls import urlfrom django.contrib import adminfrom app01 import viewsurlpatterns = ...

  7. Python实现支付宝在线支付

    windows系统安装Python虚拟环境 首先保证你的系统已经安装好了Python 安装virtualenv C:\WINDOWS\system32>pip3 install virtuale ...

  8. Python支付接口汇总大全(包含微信、支付宝等)

    微信接口 wzhifuSDK- 由微信支付SDK 官方PHP Demo移植而来,v3.37下载地址 weixin_pay- 是一个简单的微信支付的接口 weixin_pay- 微信支付接口(V3.3. ...

  9. Python实现微信小程序支付功能

    由于最近自己在做小程序的支付,就在这里简单介绍一下讲一下用python做小程序支付这个流程.当然在进行开发之前还是建议读一下具体的流程,清楚支付的过程. 1.支付交互流程 当然具体的参数配置可以参考官 ...

随机推荐

  1. 尚硅谷springboot学习34-整合SpringData JPA

    SpringData简介

  2. linux 查看文件方法

    vi 文件名 #编辑方式查看,可修改cat 文件名 #显示全部文件内容more 文件名 #分页显示文件内容tail 文件名 #仅查看尾部,还可以指定行数head 文件名 #仅查看头部,还可以指定行数s ...

  3. JavaScript Array some() 方法

    some 判断数组中是否至少有一个元素满足条件 只要有一个满足就返回true 只有都不满足时才返回false 语法: array.some(function(value,index,array),th ...

  4. jquery中添加元素append,prepend,before和after方法的区别

    append:在元素内部的最后面添加元素,作为子元素. prepend:在元素内部的最前面添加元素,作为子元素. before:在元素的前边,作为兄弟元素添加. after:在元素的后边,作为兄弟元素 ...

  5. vuecli3.0安装搭建项目

    1. npm install -g @vue/cli 2. vue create wechat Linter / Formatter 可以不选 检查空格的 //选择less //标准eslint // ...

  6. 阿里巴巴 Weex

    原文链接:https://blog.csdn.net/zz901214/article/details/79168707/ 分享嘉宾:侑夕 阿里巴巴高级前端工程师(上张帅哥的图镇楼,看完,更有动力学习 ...

  7. Numpy一文全了解

    1,Numpy是一个python包,它是一个由多维数组对象和处理数组的例程集合组成的库. 2.   Numpy的操作:(1)数组的算数和逻辑运算 :(2)傅里叶变换和用于图形操作  (3)与线性代数有 ...

  8. CodeWarrior 10 自定义关键字模版

    ==============================================版本信息开始============================================ 相关作 ...

  9. oracle 按表数据新增一行

    在功能实现时,能尽量用一个sql语句直接实现业务逻辑的话,就不要去写C#代码,便于维护. 以下sql的逻辑是:给明细表新增一条数据,前提是传入的债券代码存在与债券表,否则不新增.此sql返回受影响行数 ...

  10. 迁移virtualenv环境

    记录一次将window上的virtualenv部署至LINUX服务器 前提 你已经使用virtualenv创建了一个虚拟的python运行环境,并且已经完成了你的应用的开发,现在需要将工程部署到服务器 ...