JSP and Java Servlet code to process Stripe recurring payment
I have a project that I need help with and wanted to see if you wanted to bid on it.
I need to accept recurring monthly payments for Stripe (http://stripe.com).
In order to do this, you will have to create a test account with Stripe. It is free, and there are no charges as long as you keep the account in "test" mode.
The account will use a "API Key" which when you go to this page (https://stripe.com/docs/api/java) you will see the key listed in the "Introduction" section.
* JSP page with form to collect card data
* JSP calls Servlet that calls Stripe API to get "token"
* Servlet sends token to Stripe account's Subscription plan for credit card data
* Send user to thank you JSP page
So there are 2 JSP pages, one with a sign up button for the form that calls the servlet; and a thank you JSP page.
There is one servlet that processes the form parameters, talks to Stripe, then forwards to the thank you page.
Errors are logged using system.out.println (I will replace those with log4j calls).
I will also add in my own code to store the email address+name+token in a database table, but you don't need to write that code.
Once I get your code, I know I will have to replace the string for the "api key" and the name of the "subscription id".
Please provide a readme.txt file with outline of how to implement everything like you did last time.
I need a JSP page containing a <form> with these fields.
* Email Address
* Credit Card #
* Credit Card Expiration Month
* Credit Card Expiration Year
* Credit Card CCV code
When the form is submitted, it will call the Stripe API call to validate the information.
If there are errors, the specific problem(s) will be listed in a message that gets returned back to the JSP page and displayed to the user. Each of the error "codes" (e.g. expired_card, invalid_cvc) will need to be examined to create a concatenated string of error messages to give the user feedback as to what the problem(s) are with processing the card.
If there are no errors, and a success code is returned, then a "token" is supposed to be returned back from Stripe. That "token" is then used to send to the method to process the card. Tokens are used to keep from having to store any card data on my server, which will keep me PCI compliant.
The token is then used to call the "Subscription" code which will be set up the customer to be charged on a monthly basis. You will need to log into your Stripe account and create at least one subscription plan here: https://dashboard.stripe.com/plans
If the subscription code fails, log the error in System.out.println then send the user back to the original JSP page where they clicked the form button to sign up.
Once you get a valid return code from the subscription, send the user to a separate JSP page called thankyou.jsp that can have standard text showing "Congratulation, thank you for signing up".
They also explain how to create a "custom form" (https://stripe.com/docs/tutorials/forms). I am open to that, if you think it will be faster than going the API route. But since you are s Java developer, it seemed easier/faster to use the API.
JAR file: https://github.com/stripe/stripe-java/releases/tag/v1.27.0
Java API sample code: https://stripe.com/docs/api/java
Sample code I found: