Security Grails支付网关集成
各位 我希望在我的Grails2.3.10网站上集成一个支付网关。刚刚开始触及表面,做同样的事情需要什么。我主要关注三件事 a。如何向网关发送正确的信息 B获得批准后,我如何将其存储在系统中,然后使用该信息授予对“安全”内容的正确访问权限。 C是否使用“角色”(如“PaidUser”)保护内容,还是使用其他方式保护控制器 任何关于示例实现的帮助/需要处理的问题/只是供我阅读和学习的在线信息指针都是非常受欢迎的。 多谢各位 按照以下步骤操作:--- 1) 第一步是通过编辑安装插件 grails app/conf/BuildConfig.groovy。在插件部分添加类似于以下内容的条目: grails.project.dependency.resolution={Security Grails支付网关集成,security,grails,integration,payment-gateway,Security,Grails,Integration,Payment Gateway,各位 我希望在我的Grails2.3.10网站上集成一个支付网关。刚刚开始触及表面,做同样的事情需要什么。我主要关注三件事 a。如何向网关发送正确的信息 B获得批准后,我如何将其存储在系统中,然后使用该信息授予对“安全”内容的正确访问权限。 C是否使用“角色”(如“PaidUser”)保护内容,还是使用其他方式保护控制器 任何关于示例实现的帮助/需要处理的问题/只是供我阅读和学习的在线信息指针都是非常受欢迎的。 多谢各位 按照以下步骤操作:--- 1) 第一步是通过编辑安装插件 grails a
plugins {
...
compile ":paypal:0.6.8"
}
}
2) 要进行配置,只需编辑grails app/conf/Config.groovy.:-
环境{
production {
grails.paypal.server = "https://www.paypal.com/cgi-bin/webscr"
grails.paypal.email = "merchant@grails.asia"
grails.serverURL = "http://store.grails.asia"
}
development {
grails.paypal.server = "https://www.sandbox.paypal.com/cgi-bin/webscr"
grails.paypal.email = "merchant_test_grails@paypal.com"
grails.serverURL = "http://localhost:8080/sample"
}
}
3) 创建域类:---
类别ProductItem{
String name
BigDecimal price
static constraints = {
name(blank:false, nullable:false, unique: true)
price(blank:false, nullable:false)
}
}
导入org.grails.paypal.Payment
类别产品采购{
SystemUser user
ProductItem item
Payment payment
boolean completed = false
}
4) 创建购买/购买过滤器。例如,使用以下代码创建过滤器grails app/conf/myfilters/PurchaseFilters.groovy:
类购买过滤器{
def filters = {
all(controller:'paypal', action:'buy') {
before = {
}
after = { Map model ->
def user = SystemUser.get(request.payment.buyerId)
def item = ProductItem.findByName(request.payment.paymentItems[0].itemName)
new ProductPurchase( user:user, payment:request.payment, item:item).save()
}
afterView = { Exception e ->
}
}
}
}
6) 创建购买完成筛选器。例如,使用以下代码创建过滤器grails app/conf/myfilters/PurchaseCompletedFilters.groovy:
类PurchaseCompletedFilters{
def filters = {
all(controller: 'paypal', action: '(success|notifyPaypal)') {
before = {
}
after = { Map model ->
def payment = request.payment
if(payment && payment.status == org.grails.paypal.Payment.COMPLETE) {
def purchase = ProductPurchase.findByPayment(payment)
if ( !purchase.completed ) {
purchase.completed = true
}
}
}
afterView = { Exception e ->
}
}
}
}
7) 在gsp中创建购买按钮:----
/
这可能有助于回答您的问题:我尝试了Stripe(没有插件)。这是一个好的、简单的解决方案,但价格昂贵。
/<paypal:button
itemName="${item.name}"
itemNumber="${item.name}"
discountAmount="${0}"
amount="${item.price}"
buyerId="${user.id}"/>