Skip to content

Implement into existing modules

manuelvanrijn edited this page May 11, 2012 · 14 revisions

Implement into existing modules

Here's a list with examples how to use this gem in combination with some API/Frameworks. Feel free to extend this list with your own examples.

PHP

Based on the ideal.class.php file provided by Mollie on their website, you have to provide additional arguments when testing with Mollie Bank.

Example:

<?php
  require_once('ideal.class.php');
  $partner_id = '00000';

  $devHostList = array('localhost', '127.0.0.1');
  if(!in_array($_SERVER['HTTP_HOST'], $devHostList)){
    // working localy so use Mollie Bank
    $iDEAL = new iDEAL_Payment($partner_id, 'localhost', '4567');
  }
  else {
    // production
    $iDEAL = new iDEAL_Payment($partner_id);
  }
  /// etc.

Also you have to skip the ssl check (if used), because this isn't supported by Mollie Bank

Ruby on Rails

Global

Add the mollie-bank to your Gemfile

gem 'mollie-bank'

Change you config.ru so it will run the mollie-bank when you start the rails server. For example, change this:

# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment',  __FILE__)
run YourRailsApplicationName::Application

into:

# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment',  __FILE__)
if ENV['RACK_ENV'] == "development"
  require 'mollie-bank'

  # - Make sinatra play nice
  use Rack::MethodOverride
  disable :run, :reload

  map "/" do
    run YourRailsApplicationName::Application
  end

  map "/mollie-bank" do
    run MollieBank::Application
  end
else
  run YourRailsApplicationName::Application
end

At this point you can access the "Mollie Bank" through http://localhost:3000/mollie-bank/ because we mapped /mollie-bank to the Mollie Bank application.

All xml communication should now be rerouted to http://localhost:3000/mollie-bank/xml/ideal in development mode.

List of Plugins/Frameworks/Modules etc.

  1. ideal-mollie gem

ideal-mollie gem

If you are using the ideal-mollie gem, you have to add two additional lines to you're config.ru file

map "/mollie-bank" do
  IdealMollie.send(:remove_const, 'MOLLIE_URL')
  IdealMollie.const_set('MOLLIE_URL', 'http://localhost:3000/mollie-bank/xml/ideal')
  run MollieBank::Application
end
Clone this wiki locally