I have a simple web app using nodejs which has some products. I have setup my own cart using angularjs, and I want the simplest way to implement paypal payment. I have been breaking my head for the past two weeks over the long documentation of paypal.
我有一个简单的web应用程序使用nodejs,它有一些产品。我使用angularjs设置了自己的购物车,我想要最简单的方法来实现paypal付款。过去两周,我一直在为贝宝的长篇文档打破我的头脑。
I saw a sample curl call in developer page and implemented it using restler package in nodejs. and it returned the same token as of the curl call (so i guess it works). I want to know how to make my app work with it.
我在开发人员页面中看到了一个示例curl调用,并使用nodejs中的restler包实现了它。并且它返回了与curl调用相同的令牌(所以我猜它有效)。我想知道如何让我的应用程序使用它。
var restler = require('restler');
restler.get('https://api-3t.sandbox.paypal.com/nvp?USER=PLEASEDONTPUTYOURUSERNAMEHERE&PWD=PLEASEDONTPUTENCRYPTEDPASSWORDSHERE&SIGNATURE=PLEASEDONTPUTYOURINFORMATIONHEREf&METHOD=SetExpressCheckout&VERSION=78&PAYMENTREQUEST_0_PAYMENTACTION=SALE&PAYMENTREQUEST_0_AMT=19&PAYMENTREQUEST_0_CURRENCYCODE=USD&cancelUrl=http://www.yourdomain.com/cancel.html&returnUrl=http://www.yourdomain.com/success.html')
.on('complete',function(data){console.log(data);})
Really appreciate help with this. I am also open to any other way, but since I am not into long docs, its difficult for me to understand. Any simpler api calls to get this done? I just want to make my customers pay and then get the money to the bank. NO refunds or any other processes for now.Please help me out.
非常感谢这方面的帮助。我也对任何其他方式持开放态度,但由于我不是长文档,我很难理解。任何更简单的api调用都可以完成这个任务吗?我只是想让我的客户付钱,然后把钱汇到银行。现在没有退款或任何其他流程。请帮帮我。
1 个解决方案
#1
0
As I understand you are simply requiring a way to receive payments using PayPal.
据我了解,您只需要使用PayPal接收付款的方式。
I don't get much to play with payment gateways, but when I do, I prefer to use an external library to help me though the way, as like with you, I prefer shorter documentation. Most of my work is with Ruby but some time back I was playing with Express to make a simple eCommerce application which eventually was done in Padrino.
我没有太多的支付网关,但是当我这样做时,我更喜欢使用外部库来帮助我,就像你一样,我更喜欢更短的文档。我的大部分工作都是使用Ruby,但有一段时间我正在使用Express制作一个简单的电子商务应用程序,最终在Padrino中完成。
Following are nearly a copy paste of my old notes, hopefully the information is not outdated and is functional.
以下几乎是我的旧笔记的复制粘贴,希望这些信息不会过时且功能正常。
1: The library:
1:图书馆:
You need to get the paynode
library. It supports PayPal and some other payment gateways. I believe this information has to be in package.json
你需要获得paynode库。它支持PayPal和其他一些支付网关。我相信这些信息必须在package.json中
{ "name" : "my-shopping-cart"
// Other information
,"dependencies":
{
"paynode": "0.3.6",
// other libraries
}
}
followed by npm install
I guess
接下来是我猜的npm安装
2: The configuration
2:配置
var payflow = require('paynode').use('payflow')
var client = payflow.createClient({
level:payflow.levels.sandbox ,
user:'username@example.com' ,
password:'1279778545' ,
signature: 'AiPC9BjkCyDFQXbSkoZcgqH3hpacA0hAtGdCbvZOkLhMJ8t2a.QoecEJ'
})
3: Get the info:
3:获取信息:
Obtain the information to the server, probably though HTTP post ( I am not sure how it will be done as I am still starting to learn client side MV* frameworks ).
获取信息到服务器,可能是HTTP帖子(我不知道它将如何完成,因为我仍然开始学习客户端MV *框架)。
products = null;
total = 0;
/* Update values */
// products = getAllProducts()
// total = getTotal()
$.ajax({
type: "POST",
url: 'http://my-web-site.com/pay',
data: { products: products, total:total },
success: success,
dataType: dataType
});
4: Some routes ( pay, confirm most important )
4:一些路线(付费,确认最重要)
app.post('/pay', function(req, res){
// Store information
// Calculate sums or any similar information
request.returnurl = 'http://my-web-site.com/confirm'
request.cancelurl = 'http://my-web-site.com/cancel'
// make request and handle response
client.setExpressCheckout(request).on('success', function(response){
tokenStore.store(req.sessionHash, response.token)
res.redirect('https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='+response.token)
}).on('failure', function(response){
res.render('start.haml', {locals:{
error:response.errors[0].longmessage
}
})
})
})
app.get('/confirm', function(req, res){
// Necessary fetching - ex: user
client.getExpressCheckoutDetails({token:req.param('token')})
.on('success', function(response){
// Save the order
// orders.save(req.sessionHash, response)
res.render('confirm.haml', {
locals:{
paypalResponse:response,
orderTotal:response.paymentrequest[0].amt
}
})
})
.on('failure', function(response){
res.render('error.haml', {locals:{error:response.errors[0].longmessage}})
})
})
Most if not all code above would have come from this URL: https://github.com/jamescarr/node-shopping-cart
以上大多数代码都来自此URL:https://github.com/jamescarr/node-shopping-cart
Useful link on eBay developer page: http://go.developer.ebay.com/devzone/articles/integrating-paypal-express-checkout-your-nodejs-app
eBay开发者页面上的有用链接:http://go.developer.ebay.com/devzone/articles/integrating-paypal-express-checkout-your-nodejs-app
#1
0
As I understand you are simply requiring a way to receive payments using PayPal.
据我了解,您只需要使用PayPal接收付款的方式。
I don't get much to play with payment gateways, but when I do, I prefer to use an external library to help me though the way, as like with you, I prefer shorter documentation. Most of my work is with Ruby but some time back I was playing with Express to make a simple eCommerce application which eventually was done in Padrino.
我没有太多的支付网关,但是当我这样做时,我更喜欢使用外部库来帮助我,就像你一样,我更喜欢更短的文档。我的大部分工作都是使用Ruby,但有一段时间我正在使用Express制作一个简单的电子商务应用程序,最终在Padrino中完成。
Following are nearly a copy paste of my old notes, hopefully the information is not outdated and is functional.
以下几乎是我的旧笔记的复制粘贴,希望这些信息不会过时且功能正常。
1: The library:
1:图书馆:
You need to get the paynode
library. It supports PayPal and some other payment gateways. I believe this information has to be in package.json
你需要获得paynode库。它支持PayPal和其他一些支付网关。我相信这些信息必须在package.json中
{ "name" : "my-shopping-cart"
// Other information
,"dependencies":
{
"paynode": "0.3.6",
// other libraries
}
}
followed by npm install
I guess
接下来是我猜的npm安装
2: The configuration
2:配置
var payflow = require('paynode').use('payflow')
var client = payflow.createClient({
level:payflow.levels.sandbox ,
user:'username@example.com' ,
password:'1279778545' ,
signature: 'AiPC9BjkCyDFQXbSkoZcgqH3hpacA0hAtGdCbvZOkLhMJ8t2a.QoecEJ'
})
3: Get the info:
3:获取信息:
Obtain the information to the server, probably though HTTP post ( I am not sure how it will be done as I am still starting to learn client side MV* frameworks ).
获取信息到服务器,可能是HTTP帖子(我不知道它将如何完成,因为我仍然开始学习客户端MV *框架)。
products = null;
total = 0;
/* Update values */
// products = getAllProducts()
// total = getTotal()
$.ajax({
type: "POST",
url: 'http://my-web-site.com/pay',
data: { products: products, total:total },
success: success,
dataType: dataType
});
4: Some routes ( pay, confirm most important )
4:一些路线(付费,确认最重要)
app.post('/pay', function(req, res){
// Store information
// Calculate sums or any similar information
request.returnurl = 'http://my-web-site.com/confirm'
request.cancelurl = 'http://my-web-site.com/cancel'
// make request and handle response
client.setExpressCheckout(request).on('success', function(response){
tokenStore.store(req.sessionHash, response.token)
res.redirect('https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='+response.token)
}).on('failure', function(response){
res.render('start.haml', {locals:{
error:response.errors[0].longmessage
}
})
})
})
app.get('/confirm', function(req, res){
// Necessary fetching - ex: user
client.getExpressCheckoutDetails({token:req.param('token')})
.on('success', function(response){
// Save the order
// orders.save(req.sessionHash, response)
res.render('confirm.haml', {
locals:{
paypalResponse:response,
orderTotal:response.paymentrequest[0].amt
}
})
})
.on('failure', function(response){
res.render('error.haml', {locals:{error:response.errors[0].longmessage}})
})
})
Most if not all code above would have come from this URL: https://github.com/jamescarr/node-shopping-cart
以上大多数代码都来自此URL:https://github.com/jamescarr/node-shopping-cart
Useful link on eBay developer page: http://go.developer.ebay.com/devzone/articles/integrating-paypal-express-checkout-your-nodejs-app
eBay开发者页面上的有用链接:http://go.developer.ebay.com/devzone/articles/integrating-paypal-express-checkout-your-nodejs-app