本项目采用的 gem :
https://github.com/happypeter/alipay_dualfun
已经宣布死亡,所以,本项目代码也意义不大了。
后面我开发支付宝相关的功能,会使用这个 gem : chloerei/alipay 具体集成过程我还录制了一门视频课程: 支付宝站内集成 。
UPDATE: 2015-6-18
已经死掉的 alipay_dualfun gem 的 demo 代码
本项目采用的 gem :
https://github.com/happypeter/alipay_dualfun
已经宣布死亡,所以,本项目代码也意义不大了。
后面我开发支付宝相关的功能,会使用这个 gem : chloerei/alipay 具体集成过程我还录制了一门视频课程: 支付宝站内集成 。
UPDATE: 2015-6-18
donatecn 是 APFC 的作者写的一个 demo,使用 pay_fu + APFC + activemerchant
整个 stack 太复杂了,而且 pay_fu 项目已经死掉了。
所以我要仿照 @daqing 的 china_pay 自己写一个最简约的 gem,然后把大量变数很大的业务逻辑在具体项目自己代码中实现,这样透明度较好。
如果用户在收银台误选了“担保交易”,只要继续付款,付款结束后,一样可以跳回我的 return_url.
但是后续还有麻烦事:
#4 (comment)
所以对于 happycasts 还是不用为妙。
迁移到新的服务器,同时把 rails 版本升级:
老的 apache.conf 数据:
<VirtualHost *:80>
ServerName alidemo.happycasts.net
PassengerRuby /home/peter/.rbenv/versions/1.9.3-p125/bin/ruby
DocumentRoot /home/peter/alipay_dualfun_demo/public/
<Directory /home/peter/alipay_dualfun_demo/public/ >
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
太复杂的内容就不往这个 repo 放了,谈一个初步想法。
happycasts 用户登陆后方可购物,结算出总额之后,在向 alipay 发 request 之前,就创建该 transaction 的 record,当然 paid=false。record 中会存放 user.id=123,用来跟踪用户,同时存放 out_trade_no 用来跟踪本单交易。
这时发出向 alipay 的请求,从同步和异步通知中我们不必去取该用户的支付宝用户名,而是只跟踪用户到底对那个 out_trade_no 的交易付款了,只要 paid=true 了,我们就认为是 user123 出的钱。于是赋予 user123 相应的权利。
http://help.alipay.com/support/help_detail.htm?help_id=243730
明显 service=create_direct_pay_by_user 这个是不对的。这是及时付款功能的代号。
我用的双功能,应该是:service=trade_create_by_buyer
我出了两次这个错误,一次是因为 price=0.123 改成 price=0.12 就好了。
另一次,因为规定为“不可空”的参数,我没有提供。
本来是抄的 daqing 的 china_pay 里面封装了 @merchant @order
等各种对象,虽然灵活,但是对于我的这个功能单一的 Gem 来说,肯定是没有必要的,造成了理解上的困难。
还是 Rei 的这个简单:
https://github.com/chloerei/alipay/blob/master/lib/alipay/service.rb#L26
after I send my request, alipay show this error.
http://act.life.alipay.com/shopping/promotion/subject/new_paytype/video.htm?filename=shuangjiekou#part4
双接口就很够用啊。申请条件: https://b.alipay.com/order/productDetail.htm?productId=2012111300373136
https://b.alipay.com/order/serviceIndex.htm
功能演示的视频:video: http://act.life.alipay.com/shopping/promotion/subject/new_paytype/video.htm?filename=shuangjiekou#part4
查看 pdf:如何判定请求来自支付宝
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.