Kamal Fariz Mahyuddin on Ruby on Rails, Ember.js and other web development geekery.

You should follow me on twitter here.

iPay88 ActiveMerchant Adapter

Today I’m releasing an ActiveMerchant adapter for iPay88. iPay88 is a popular payment processor in Malaysia. You can grab the code off GitHub or you could also grab the bitfluent-activemerchant gem to start using it today. Hopefully upstream will merge it into the official repository soon.

Accepting iPay88 Payments with Ruby on Rails

It’s pretty easy to start using the adapter in your app. The following examples are all on Ruby on Rails 2.3.8.

  1. Add the gem to config.gem (or Bundler if you like)

  2. Add an initializer to set your iPay88 Merchant Key (they’ll give this to you after a long arduous signup process which includes tons of paper work, bank statements, company registration, a visit to their office in Cheras and faxing. YES, FAXING!)

  3. Assuming you have an OrdersController, add pay and return actions. OrdersController#pay will be the page where you’ll craft a special form to POST to iPay88 to kickoff the payment process. OrdersController#return will be the page iPay88 will return to after the payment process is completed. iPay88 will actually POST to this action hence the route specifying POST for return - this was surprising to me. This is where you will check the status of the payment and display to the user a success or fail/retry page.

  4. Now if you visit http://localhost:3000/orders/1/pay and view source, you’ll see a form with a bunch of hidden inputs. You might want to add a submit button. My preferred method is to use a little bit of Javascript to hide the submit button and submit the form programmatically on page load. This way, if the user has JS turned off, they can still submit the form manually.

    Throw in a "Processing …" header and spinner and you’re almost there!

  5. Hopefully the user is able to perform the payment after enduring a million popup windows that is iPay88’s horrible user experience.

  6. Finally, the user is returned to your app via OrdersController#return. Check if the payment was successful and you are done!


The iPay88 adapter development was sponsored by Freeform. It was built to support iPay88 as a payment option for The Tongue in Chic Store. Show your thanks by buying something nice from the store!

Fork me on GitHub