Grails Stripe plugin error -


i'm using stripe plugin grails ,grails version 2.5.1 can't make successful transaction there error processing credit card. shown in controller , noticed charge method not defined shown in screenshot enter image description here

i tried import com.stripe.stripe i'm getting unable resolve class com.stripe.stripe.

here action:

def charge(string stripetoken, double amount) { //stripe.apikey = grailsapplication.config.grails.plugins.stripe.secretkey def amountincents = (amount * 100) integer def chargeparams = [     'amount': amountincents,     'currency': 'usd',     'card': stripetoken,     'description': 'customer@sample.org' ]  def status try {     charge.create(chargeparams)     status = 'your purchase successful.' } catch(cardexception) {     status = 'there error processing credit card.' }  redirect(action: "confirmation", params: [msg: status]) return } 

try this,

in build config add:

plugins {  ...  compile "org.grails.plugins:stripe:2.8"  ... } 

in controller:

package stripesample  import com.stripe.model.charge import com.stripe.exception.cardexception;  class checkoutcontroller {      def index() {}      def charge(string stripetoken, double amount) {         def amountincents = (amount * 100) integer          def chargeparams = [             'amount': amountincents,              'currency': 'usd',              'card': stripetoken,              'description': 'customer@sample.org'         ]          def status         charge chargestatus         try {             chargestatus = charge.create(chargeparams)             println chargestatus             status = 'your purchase successful.'         } catch(cardexception) {             println status             status = 'there error processing credit card.'         }          render view: "confirmation", model:[msg: status,chargeobject:chargestatus]         return     } } 

in main layout file:

<html>     <head>         <g:javascript src="stripe-v2.js" />         <r:layoutresources/>     </head>     <body>         <g:layoutbody/>         <r:layoutresources/>     </body> </html> 

in credit card form view:

<!doctype html> <html>     <head>         <meta name="layout" content="main"/>      </head>     <body>         <h3>checkout</h3>                 <stripe:script formname="payment-form"/>                 <g:form controller="checkout" action="charge" method="post" name="payment-form">                     <div class="payment-errors"></div>                     <div class="form-row">                         <label>amount (usd)</label>                         <input type="text" size="20" autocomplete="off" id="amount" name="amount"/>                     </div>                      <stripe:creditcardinputs cssclass="form-row"/>                      <button type="submit">submit payment</button>                 </g:form>          </div>     </body> </html> 

create view in same controller folder in case checkout/confirmation.gsp

<!doctype html> <html>     <head>      </head>     <body>          <h3>checkout</h3>        <p>${msg}</p>          <p>data: </p>         <p>${chargeobject}</p>      </body> </html> 

run grails clean , then, run grails run-app

if need test sample app can clone app here: sample app


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -