The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Business::iDEAL::Mollie - Backend for iDEAL payments through mollie.nl

SYNOPSIS

  use strict;
  use Business::iDEAL::Mollie;

  my $mollie = new Business::iDEAL::Mollie;
  
  # First you will have to grab the bank list (the list might
  # change, so make sure you do this).

  my $banks = $mollie->banklist;

  # Then, you probably want to feed your user the URL of
  # the right bank.

  my $resp = $mollie->fetch({
               partnerid  => 'your partner id',
               amount     => '1250',
               bank_id    => $banks->[2]{'bank_id'},
               description=> 'Acme Labs: order# foo-bar-123'
               reporturl  => 'http://your.site.tld/mollie.cgi',
               returnurl  => 'http://your.site.tld/thanks.html'
             });
  if($resp) {
     # ... probably some Database activity here 
     # with $resp->{'transaction_id'} and some redirection
     # headers with $resp->{'URL'}
  } else {
     # Do something with $mollie->error, which contains the 
     # status_line of LWP::UserAgent
  }

Meanwhile, in a nearby piece of code (mollie.cgi in this example)

  # The easy way ...

  if($q->param('transaction_id')) {
     if($mollie->is_payed({
           partnerid      => 'your partner id',
           transaction_id => $q->param('transaction_id'),
        })) {
        # Do something with the verified transaction_id
     } else {
        # Not payed, or checked more than once...
     }
  }

  # The more complicated way

  if($q->param('transaction_id')) {
     my $resp = $mollie->check({
                  partnerid      => 'your partner id',
                  transaction_id => $q->param('transaction_id'),
                }); 
     if($resp->{'payed'} eq 'true') {
        # Do something with $resp->{'amount'}, $resp->{'currency'}, etc.
     } else {
        # Log, cry, do anything here with the failed check.
     }
  }

DESCRIPTION

Business::iDEAL::Mollie provides a backend to process iDEAL payments through mollie.nl.

METHODS

The following methods can be used

new

new creates a new Business::iDEAL::Mollie object.

options

baseurl

Defaults to http://www.mollie.nl/xml/ideal, but could be set to a different URL for testing (e.g. http://menno.b10m.net/perl/ideal)

ua

Configure your own LWP UserAgent.

banklist

First of all, you need to fetch a list of bank_ids and bank_names. This list is subject to change, and mollie.nl recommends checking this list for each transaction. Returns an arrayref of hashes with bank_id and bank_name.

fetch

After you've retrieved the banklist, your users may choose the preferred bank. Now you can feed that 'bank_id', together with 'partnerid', 'amount', 'description', 'reporturl' and 'returnurl'.

This method returns the transaction_id that you should store for later reference, aswell as URL of the bank's iDEAL page that the user should be directed to.

partnerid

See http://ww.mollie.nl/ for more information on how to get a partnerid.

amount

The amount in cents. So 10 euro should be written as 1000. This module removes periods and columns by default, but don't count on this to go perfect!

bank_id

The bank_id as retrieved by the "banklist" method. Include leading zeros where needed. The bank id should contain 4 digits.

description

A description of the payment in 29 characters or less (more chars will be stripped by mollie.nl). This description will be used by the actual banks, so make sure it's clear for your users.

reporturl

The URL of your script handling the query by mollie.nl when a transaction is completed. This script should perform the "check" method.

returnurl

The URL of where to redirect your users to after the payment process is done.

check

After the user went through the payment process, mollie.nl will fire off a GET request on your "reporturl". This GET request will include the "transaction_id" that you stored during "fetch" method.

This method requires the "partnerid" aswell as the "transaction_id" you just received, and returns the status of the order.

is_payed

Simple wrapper around the "check" method. Returns a true value when the order is payed for, and a false value when this is not the case.

error

The error method will return any errors encountered (mainly, or solely LWP::UserAgent based). Note that all methods also return a message from mollie.nl, explaining the answers a little.

SEE ALSO

BUGS

Please report any bugs to http://rt.cpan.org/Ticket/Create.html?Queue=Business-iDEAL-Mollie.

AUTHOR

M. Blom, <blom@cpan.org>, http://menno.b10m.net/perl/

COPYRIGHT AND LICENSE

Copyright (C) 2006 by M. Blom

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.