Skip to content

PostFinance Checkout integration for Commerce on MODX CMS.

Notifications You must be signed in to change notification settings

digitalpenguin/Commerce_PFCheckout

Repository files navigation

PostFinance Checkout Integration for Commerce on MODX

https://checkout.postfinance.ch/en-us/doc

"PostFinance Checkout is the most practical all-in-one payment solution for Swiss online shops – a contractual partner, a plug-in and five payment options for your customers: PostFinance Card, PostFinance e-finance, TWINT, Visa and Mastercard."

Developed by Murray Wood at Digital Penguin Ltd.

**Thanks to Sebastian G. Marinescu from xvanced for sponsoring the development of this module.

Requirements

Commerce_PFCheckout requires at least MODX 2.6.5 and PHP 7.1 or higher. Commerce by modmore should be at least version 1.1.4. You also need to have an PostFinance Checkout account which provides the space id, user id and secret key.

Installation

Install via the MODX package manager. The listing name is "PostFinance Checkout for Commerce". The package namespace is Commerce_PFCheckout.

Setup the Module

Once installed, navigate to Commerce in the MODX manager. Select the Configuration tab and then click on Modules. Find Commerce_PFCheckout in the module list and click on it to make a window pop up where you can enable the module for Test Mode, Live Mode, or both.

Now the module is enabled, you can click on the Payment Methods tab on the left. Then click Add a Payment Method. Select PostFinance Checkout from the Gateway dropdown box and then give it a name e.g. PostFinance Checkout. Next, click on the availability tab and enable it for test or live modes and then click save.

After saving, you'll see an extra PostFinance Checkout tab appears at the top of the window. Here you can enter your PostFinance Checkout API credentials: Space id, User id and the Secret key

Congratulations! PostFinance Checkout should now appear as a payment method a customer can use during checkout.

Customize the Markup

On the payment page of the checkout process in Commerce, the PostFinance Checkout payment method is displayed according to a default twig template located in your MODX install at: core/components/commerce_pfcheckout/templates/frontend/gateways/postfinancecheckout/gateway.twig

You can override this default template the same way you would any other template in Commerce: https://docs.modmore.com/en/Commerce/v1/Front-end_Theming.html

Add your own custom template file at core/components/commerce/templates/your-custom-theme-name/frontend/gateways/postfinancecheckout/gateway.twig and it will take precedence over the default module template.

Important: remember to set your custom theme name in the Commerce commerce.theme (and optional custom path in commerce.themes_path) system settings, or it won't be overridden.

Setup in the PostFinance Checkout Portal

Besides the template, most configuration takes place inside PostFinance Checkout's merchant portal. You need to setup your which payment methods you want to accept, and you can customise the look of the payment page the customer is redirected to.

You will also need to get your three authentication details here:

  1. Space id
  2. User id
  3. Secret Key

Login here: https://checkout.postfinance.ch/user/login

Note: The above can be hard to find. After logging in, go to "Account", create a "Space" and copy the space_id. In the sub-menu, go to "Roles" and create a role with all the permissions. Then, go to "Application Users", and create a new application user and assign the role you just created to this user. Click on "Generate New Key" and then copy the user_id and secret_key it gives you.

Testing

https://developer.postfinancepayments.ch/documentation/testcases/