【发布时间】:2016-12-19 14:43:32
【问题描述】:
我正在使用 Stripe plugin for Grails,Grails 版本 2.5.1 我无法进行任何成功的交易我总是得到There was an error processing your credit card.,如控制器所示,我注意到Charge 方法没有像截图 中显示的那样定义@
我尝试导入com.stripe.Stripe,但我得到unable to resolve class com.stripe.Stripe。
下面是动作:
def charge(String stripeToken, Double amount) {
//Stripe.apiKey = grailsApplication.config.grails.plugins.stripe.secretKey
def amountInCents = (amount * 100) as Integer
def chargeParams = [
'amount': amountInCents,
'currency': 'usd',
'card': stripeToken,
'description': 'customer@sample.org'
]
def status
try {
Charge.create(chargeParams)
status = 'Your purchase was successful.'
} catch(CardException) {
status = 'There was an error processing your credit card.'
}
redirect(action: "confirmation", params: [msg: status])
return
}
【问题讨论】:
-
您不需要导入 com.stripe.Stripe 来设置 api 密钥,因为插件会处理这个问题。我将首先检查您在 CardException 中收到的消息。它可能会提供有关交易失败原因的线索。
标签: grails stripe-payments grails-plugin