collective.pfg.payment 0.6
Extends PloneFormGen to payment form.
License: BSD

Introduction
============
This package is inteded to integrate html payment form which happens outside of Plone
as easy as possible by using forms and adapters generated by PloneFormGen.

Currently tested with
---------------------

* Plone-4.3
* Products.PloneFormGen-1.7.8

Example use case
--------------------

1. On Plone site, input some price amount on form.

2. Confirm the amount and go to payment page outside of Plone.

3. Process the payment.

4. Go back to Plone site.

General Setup
-------------

Once the package is quickinstalled, you need to configure  authentication code calculation from *Site Setup* >> *Payment Config*

**MAC Code**
    This code is provided by payment provider.

**Fields**
    Input field names which will be used for the calculation line by line.

**Separator**
    Input separator between field values if necessary.

**Capital**
    Check this if calculated authentication code need to be upper cases.

*You may configure payment settings locally to Form Folders.*

Tested HTML Interfaces and their configurations
===============================================

Verkkomakust S1 (Finland)
-------------------------

**MAC Code**
    6pKF4jkv97zmqBJ3ZL8gUw5DfT2NMQ

**Fields**

    MERCHANT_ID

    AMOUNT

    ORDER_NUMBER

    REFERENCE_NUMBER

    ORDER_DESCRIPTION

    CURRENCY

    RETURN_ADDRESS

    CANCEL_ADDRESS

    PENDING_ADDRESS

    NOTIFY_ADDRESS

    TYPE

    CULTURE

    PRESELECTED_METHOD

    MODE

    VISIBLE_METHODS

    GROUP

**Separator**
    \| (Vertical bar)

**Capital**
    Checked

Example use case
----------------

1. Create Form where payment process starts: FormFolder1

    *Edit* >> *Overrides* >> *Custom Success Action*

        traverse_to:string:formfolder2

    * formfolder2 is the next form where the confirmation happens.

2. Add *Decimal Field* with id named **AMOUNT**.

    * Plone automatically set id from title, but with lower cases. To set id upper cases, you may need to change it, for example from Contents tab.

    * Optionally if you want to send email or show results after the successful payment, add Custom Script Adapter here and describe to script body something like::

        items = dict(
            AMOUNT=request.form["AMOUNT"],
            topic=request.form["topic"]
        )
        request.SESSION.set("collective.pfg.payment", items)

    * This means that AMOUNT and topic fields are stored in session and can be displayed after the successful payment.

3. Create another Form: FormFolder2

    *Edit* >> *Overrides* >> *Custom Form Action*

        https://payment.verkkomaksut.fi/

    *View* >> *Actions* >> *Make Order Number Aware*

        Change the numbering behavior if necessary.

        *Here you may set the payment configuration locally. This will overrides global configuration.*

4. Add all of the next fields with *String Field*.

    MERCHANT_ID

    AMOUNT

    ORDER_NUMBER

    REFERENCE_NUMBER

    ORDER_DESCRIPTION

    CURRENCY

    RETURN_ADDRESS

    CANCEL_ADDRESS

    PENDING_ADDRESS

    NOTIFY_ADDRESS

    TYPE

    CULTURE

    PRESELECTED_METHOD

    MODE

    VISIBLE_METHODS

    GROUP

    AUTHCODE

* The field ids must be upper cases.

* These fields below needs to be configured

    **MERCHANT_ID**
        *Edit* >> *Default*
            13466

    **ORDER_NUMBER**
        *Edit* >> *Overrides* >> *Default Expression*
            python:here.restrictedTraverse('number')()

    **CURRENCY**
        *Edit* >> *Default*
            EUR

    **RETURN_ADDRESS**
        *Edit* >> *Overrides* >> *Default Expression*
            string:${portal_url}/formfolder3/thank-you/@@payment-succeeded

    * Assuming that FormFolder3 will be created under plone root.
    * If field values are not necessary to be sent by e-mail or displayed after successful payment, you can give different address here and FormFolder3 is not necessary.

    **CANCEL_ADDRESS**
        *Edit* >> *Overrides* >> *Default Expression*
            string:${portal_url}/formfolder1

    * Assuming that FormFolder1 is created under plone root.

    **NOTIFY_ADDRESS**
        *Edit* >> *Overrides* >> *Default Expression*
            string:${portal_url}

    **TYPE**
        *Edit* >> *Default*
            S1

    **CULTURE**
        *Edit* >> *Default*
            fi_FI

    **MODE**
        *Edit* >> *Default*
            1

    **AUTHCODE**
        *Edit* >> *Overrides* >> *Default Expression*
            python:here.restrictedTraverse('auth-code')

5. Create another Form: FormFolder3

In case e-mails need to be sent and field values displayed after the successful payment.

We use thank-you page automatically created under FormFolder3.

    To show the field values, you need to add or copy the original field which were in FormFolder1 to this FormFolder.

    * The type of field need to be the same as the original one.
    * For example, if you want to show topic and AMOUNT, String Field with id topic and Decimal Number Field with id AMOUNT need to be added under FormFolder3.

Changelog
=========


0.6 (2013-05-06)
----------------

- Moved test packages to extras_require. [taito]
- Tested with Plone-4.3. [taito]

0.5 (2013-01-06)
----------------

- Tested with Plone-4.2.3 and Products.PloneFormGen-1.7.6. [taito]
- Added testing integration to Travis CI. [taito]

0.4 (2012-11-14)
----------------

- Tested with Plone-4.2.2 and Products.PloneFormGen-1.7.4. [taito]

0.3.2 (2012-09-25)
------------------

- Updated version in metadata.xml. [taito]

0.3.1 (2012-09-24)
------------------

- Fixed action: make_order_number_aware. [taito]

0.3 (2012-09-17)
----------------

- Tested with Plone-4.2.1. [taito]

0.2.0 (2011-04-16)
------------------

- Added local payment configuration for multiple payment processors.

0.1.1 (2011-04-15)
------------------

- Capital check fixed to be updated in Payment Config page.


0.1.0 (2011-04-15)
------------------

- Initial release

Installation
============

Use zc.buildout and the plone.recipe.zope2instance
recipe to manage packages:

* Add ``collective.pfg.payment`` to the list of eggs to install, e.g.::

    [buildout]
    ...
    eggs =
        ...
        collective.pfg.payment

* Re-run buildout, e.g. with::

    $ ./bin/buildout

Credits
=========
* Finnish Association for Nature Conservation (Suomen Luonnonsuojeluliitto) who uses this package in their site: http://www.sll.fi