I am new to payment gateway integration.I need to integrate Braintree Payment Gateway
with JSF Application. Can someone show my a basic example of the java class and sample payment Page. I saw some client Token how to generate it. I wrote a sample class and page like below,But i coudnt make as i dont get the idea.
page
<form id="checkout" method="post" action="/checkout">
<div id="payment-form"></div>
<input type="submit" value="Pay $15">
</form>
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
<script>
// We generated a client token for you so you can test out this code
// immediately. In a production-ready integration, you will need to
// generate a client token on your server (see section below).
var clientToken = "sZWQiOmZhbHNlLCJtZXJjaGFudElkIjoiMzQ4cGs5Y2dmM2JneXcyYiIsInZlbm1vIjoib2ZmIn0=";
braintree.setup(clientToken, "dropin", {
container : "payment-form"
});
</script>
Class
import spark.Request;
import spark.Response;
import spark.Route;
import com.braintreegateway.BraintreeGateway;
import com.braintreegateway.Environment;
public class BrainTreeController {
private static BraintreeGateway gateway = new BraintreeGateway(
Environment.SANDBOX,
"your_merchant_id",
"your_public_key",
"your_private_key"
);
post(new Route("/client_token") {
@Override
public Object handle(Request request, Response response) {
return gateway.clientToken().generate();
}
});
}
I get a error in post
Syntax error on token "post", @ expected before this token