I try to add a PayPal button in my grails 3 app.
I haven't found any howto's for grails 3 so I tried one for grails 2
(https://grails.org/wiki/PayPal%20Plugin).
Step 1) Install the plugin.
In grails 2:
grails install-plugin paypal
This is not working in grails 3. However there is an install command, but this doesn't accept paypal as parameter.
So I added
dependencies {
.
.
.
compile 'com.paypal.sdk:paypal-core:1.6.9'
compile 'com.paypal.sdk:buttonmanagersdk:2.6.106'
}
to my build.gradle.
Is this the wrong way to add the paypal plugin ?
Step 2) configure constants.
In grails 2 edit Config.groovy:
environments {
production {
grails.paypal.server = "https://www.paypal.com/cgi-bin/webscr"
grails.paypal.email = "example#business.com"
grails.serverURL = "http://www.grails.org"
}
development {
grails.paypal.server = "https://www.sandbox.paypal.com/cgi-bin/webscr"
grails.paypal.email = "testpp_1211202427_biz#g2one.com"
grails.serverURL = "http://812.99.101.131"
}
}
Config.groovy is not used in Grails 3 so I added the following to application.yml
environments:
development:
grails.paypal.server : https://www.sandbox.paypal.com/cgi-bin/webscr
grails.paypal.email : example#business.com
grails.serverURL : http://www.grails.org
Do i have to configure this elsewhere ?
Step 3) Create the PayPal button.
This should be the same in grails 2 and 3
add:
<paypal:button
itemName="name"
itemNumber="theNumber"
transactionId="theTransactionId"
amount="1337,00"
discountAmount="0"
buyerId="theId"
/>
To the gsp file.
Do i have to include the paypal taglib (it's not included in the example) ?
When I test my app I got
<paypal:button
itemName="name"
itemNumber="theNumber"
transactionId="theTransactionId"
amount="1337,00"
discountAmount="0"
buyerId="theId"
/>
in my html.
What do I have to do to get my PayPal button working ?
regards Kai
Related
In a fresh grails 4.0.4 application the settings of
grails:
views:
gsp:
codecs:
expression: none
seem to be ignored when deployed as a war file in a Tomcat 8.5.39. (JVM 11.0.7+10-post-Ubuntu-2ubuntu218.04)
Adding this
<head>
...
<script>
var foo = ${[a:23, b:42, c:666] as grails.converters.JSON};
</script>
</head>
to the generated grails-app/views/index.gsp shows up as
var foo = {"a":23,"b":42,"c":666};
when running grails run-app or even grails prod run-app(!), but is encoded as
var foo = {"a":23,"b":42,"c":666};
in the packaged (grails prod war) deployed war file.
The build.gradle was unmodified, except for changing
compile "org.grails.plugins:cache"
to this
compile("org.grails.plugins:cache") {
exclude module:'groovy-all'
}
Is this a bug or am I using the codecs settings wrong? Maybe there is a plugin overwriting this settings (like here https://github.com/grails/grails-core/issues/10722) but i cannot find any other yml files. Any help is appreciated!
It works like a charm in Grails 4.0.3. Seems it is broken in Grails 4.0.4 ...
Maybe the problem came with the new Groovy Page Compiler Task. The config file (aka application.yml) variable here is never used. But that's only an assumption after quick investigation with too little coffee ;-)
Workaround or my preferred way (still working in Grails 4.0.4)
Some helper TagLib like this:
import grails.converters.JSON
class FooTagLib {
static defaultEncodeAs = [taglib:'none']
static namespace = "foo"
def json = { attrs, body ->
out << raw(attrs.data as JSON)
}
}
Usage:
var foo = <foo:json data="[a:23, b:42, c:666]"/>
I want to use fontawesome plugin in grails.
I have added in build config compile :font-awesome-resources:4.0.3.1 to add plugin.I have added
customBootstrap
{
dependsOn 'font-awesome'
resource url: 'css/bootstrap.css'
resource url: 'js/bootstrap.js' resource url: 'css/bootstrap-fixtaglib.css'
}
in applicationresource.groovy but when i run the application get error
ERROR resource.ResourceProcessor - Unable to load resources Message: No such property: pluginManager for class: org.springframework.web.context.support.XmlWebApplicationContext.Please provide solution.
I am not sure whether this is a configuration issue with migration from earlier grails versions or if font-awesome has not been migrated completely to grails 2.4.x. But I encountered this as well.
As a short (dirty) workaround, you can replace the code that causes the problem directly on the plugin.
File (replace X with your project name):
~/.grails/2.4.2/projects/X/plugins/font-awesome-resources-4.0.3.1/grails-app/conf/FontAwesomePluginResources.groovy
Replace lines 3 and 4 with:
def pluginManager = grails.util.Holders.pluginManager
def lesscssPlugin = pluginManager.getGrailsPlugin('lesscss-resources') || pluginManager.getGrailsPlugin('less-resources')
And give it a go.
My problem is simple - the ${appName} property substitution in Config.groovy does not appear to be working for me.
I have a config item called path.to.resources = ${appName}/videos, but when I read that from my controller using grailsApplication.config.path.to.resources, I get ${appName}/videos instead of myAppName/videos.
I'm using Grails 2.0.4 and STS
Try this
path.to.resources = "${appName}/videos"
I am trying to deploy Grails 2.2.3 project to a production and having issue with URL.
I setup reverse proxy in Apache and have http://example.com -- as example.
I set following property in Config.groovy:
grails.serverURL = "http://example.com/"
and set in the application.properties following:
app.context=/
However all of my resources and links always reference to
http://example.com/AppName/...
How do I remove application name ("AppName") from resource and links reference?
Example of resources:
<r:require modules="bootstrap"/>
<g:javascript library="jquery"/>
Example of environments Config.groovy:
environments {
development {
grails.logging.jul.usebridge = true
}
production {
grails.logging.jul.usebridge = false
grails.serverURL = "http://example.com/"
grails.app.context = "/"
}
}
I think Grails application must have some sort of property that could be set!? Otherwise it seems like a pain the neck.
Please help!
P.S: If I access any resource directly (manually remove AppName from URL) I get the right stuff such as css, js and image.
Update:
I set following in application.properties:
app.context=/
serverURL=http://example.com/
and created absolute URL in grails:
<g:createLink controller="Sample" absolute="true"/>
and it creates proper URL!!! However resources use relative path and start with AppName/... It seems like a curse, I just can't get rid of that AppName.
Update:
If I run prod run-app then all URLs come out properly, however the moment I deploy to Tomcat 7, AppName appears in URLs again.
There are other options, but probably the shortest approach is to deploy it like ROOT.war.
Just change the default war filename in the BuildConfig.groovy:
grails.project.war.file = "target/ROOT.war"
Set the right grails.serverURL property for you and you're done.
Hope it helps.
How to get grails plugin version from app?
Details: my app is also a grails plugin.
When I set version, using
grails set-version 0.5
I can't get value using grailsApplication.metadata['app.version']
because value is updated in my FooBarGrailsPlugin.groovy class
The application.properties file remains unchanged.
Tks.
When I run set-version, my class change from:
class FooBarGrailsPlugin {
def version = 0.1
}
to
class FooBarGrailsPlugin {
def version = 0.5
}
The following code will print out the name and version of all plugins installed in an app
applicationContext.getBean('pluginManager').allPlugins.each {plugin ->
println "${plugin.name} - ${plugin.version}"
}