Tips on Oracle Application Express, PL/SQL, with a focus on Linux and web based technologies

Thursday, 11 February 2016

Accepting payments with Stripe in APEX, Part 1

I've just been investigating a payment gateway for an APEX application. I already knew about the recent startup Stripe, and their fees seemed just as good (if not better) than the other well-known contenders - I figured there would be a good place to start.

Now, I haven't actually worked with the others, but so far, I'm very impressed with the system/API available. From my little bit of research, all the card information will be stored on Stripe's servers, so we need not deal with storing and encrypting customers card information. With that, we are left with this general workflow:

Include a form for customers to enter there card information

The form gets submitted to Stripe's servers

Returned is a token. We use this to then complete the charge

For this first part, I'll be focusing on the form. In particular, Stripe provides a form for us that we can re-use. Check out the documentation on the form here - https://stripe.com/docs/tutorials/checkout. Keep in mind, you can just as easily develop your own form if you have your own design in mind.

So, if you add that to a static region on your page, you will see a nice checkout button and form:

What would then happen after submitting the payment information, is the form would get submitted, with some additional parameters being sent in the POST request. Being on APEX, this won't do since the whole page is wrapped around a form - resulting in this being an embedded form (unsupported).

Looking at the documentation some more, they have a more advanced example giving us more control over what happens once the Pay button is selected.

We still need to leave a reference to checkout.js on our page, so for now this can live in our region where the pay button will live. The next part will be to add a regular APEX button to our region - with the action being Defined by a Dynamic Action.

Then, we need a dynamic action for when the button is clicked - with the true action being to execute a block of JavaScript code (the handler could be set up on page load, but just chucked it in one spot for simplicity)

4 comments:

Yes - my recommendation is to write a stored procedure to handle the post/get and bind to it from Apex. It is easier to manage. Either way you go payment sites use HTTPS so you will need to register the SSL certificate in your Oracle DB and insure your user id has ACL permissions to the url (then you can post/get all you want with the proper credentials)

I integrated a lot of payment systems in the past, starting at HTMLDB 1.6. My recommendation is the same as Jb Williams to use APEX as a front end only, do everything in a dedicated package, including all the calls, url_redirects, url_http, etc.

Hello Learco, I just saw your reply to the post. I am really new in this world of Payments online; Do you have some blog where you have something based in your knowledge about online payment? This is my personal email: geova.kelly.c@gmail.com thanks in advance!

About Me

Thanks for stopping by! Just a little bit about me - my name is Trent Schafer. I am Australian, but in May 2017 I've decided for go on a work adventure over to Canada, where I am currently working for Insum Solutions. I'm always interested in learning new things, and this blog is a place where I try and share what I can. If you're over on Twitter, feel free to give me a follow - I am @trentschafer.