1Introduction

This manual describes how to install, configure and use the payment module for Shopware and Trustly.

Before you begin with the installation make sure you have all of the necessary data. You will need:

  • Trustly Username and Password
  • Trustly RSA Private Key
  • Shopware Payment Module from sellxed.com/shop
  • Entry Data to your Server and Shop

Note that you must use at least PHP version 5.6 for our plugins. PHP 8 or higher is currently not supported.

1.1Installation Process

This document contains all information necessary to install the module. Strictly follow the steps on the check list when setting up the module. This is the only way to ensure a safe usage in compliance with all security regulations.

  1. Before beginning with the installation you will need your username and password which you will receive from your integration manager.
  2. Generate a new RSA Private and RSA Public Key
  3. Configuration of the Main Module
  4. Configuration of the accepted payment methods and the respective authorization methods
  5. Conducting a test order
Installation Service

Our payment plugins should have per default the correct settings for most of our customers' preferences. That means once you have entered the required credentials in the plugin configuration to connect your account to your website, the plugin should be fully operational. Should you be willing to receive detailed information on a setting you do not know, you may contact our support team who will be able to assist you further.

Our support team is at your disposal during regular business hours at: http://www.sellxed.com/support. Furthermore, you have the option of ordering our installation service. We will make sure the plugin is installed correctly in your shop: http://www.sellxed.com/shop/de/integration-und-installation.html

.htaccess Directory Protection

In order to test the module, any kind of directory protection or IP blocking on your server must be deactivated. This is crucial as otherwise the payment feedback of Trustly might not get through to the shop.

1.2System Requirements

In general, the plugin has the same system requirements as Shopware. Below you can find the most important requirements of the plugin:
  • PHP Version: 5.4.x or higher
  • OpenSSL: Current version with support for TLS 1.2 or higher.
  • fsockopen: The PHP function fsockopen must be enabled. The plugin must be able to connect to external systems over the Internet.
  • PHP Functions: All common PHP functions must be enabled.

1.3Configuration of the Main Module

For the commissioning of the main module you will need to enter your credentials. Firstly you will need a RSA public and private key pair that you need to generate in the module and subsequently send the public key to your Trustly integration manager. Secondly you will need your username and password that you receive from Trustly after providing them with the RSA public key.

1.3.1Creating an RSA Private and Public Key for Test and Live

Via Configuration > Trustly you will find an RSA Key Generator for the live and test platform. Here you can create an RSA keypair. Generate a new keypair and download the public key to your local computer. The private key is stored securely in the module. Now you need to send the public key to your contact at Trustly. In case your certificate gets compromised you can also regenerate a keypair here.

1.3.2Configuration Username and Password

For the configuration of the main module you will need to enter your password and username which you receive from your Trustly integration manager into the backend of your shop system.

1.3.3Important Information Regarding Dealers in the Financial Services Sector

If you operate in the financial services sector make sure to set the option Mobile Phone Number to "Mobile is Required" in the backend of your shop.

1.4Configuration of the Payment Methods

Further information regarding the configuration of the payment methods and the implementation of the different settings can be found here. Once you have activated and configured the payment methods you can run a test.

1.5Activating the Account

When you have successfully completed the test runs, you can request for the activation of your account. Your integration manager is in charge of that. Enter the received Live Credentials for the Live Environment into the Main Module Switch now into the RSA Generator for the Live keys. You can download the public key for the live platform and send it to your integration manager at Trustly. Once your live certificate is configured and your live credentials are set you are able to process Trustly transactions.

2Module Installation and Update in the Shopware Shop

2.1Installation

At this time you should already be in possession of the module. Should this not be the case, you can download the necessary files in your customer account in the sellxed shop (Menu "My Downloads Downloads"). In order to install the module in your shop, please carry out the following steps:

  1. Download the plugin. The download can be found in your sellxed.com account under "My Downloads".
  2. Unzip the archive you have just downloaded.
  3. In the unzipped folder navigate to the folder "files"
  4. For some shops there are different versions of the plugin provided. If this is the case open the folder which corresponds to your shop version.
  5. Using your preferred FTP client upload entire content of this folder into the root directory of your shop. For some shops there is a specific folder containing the plugins. If that is the case upload the plugin into this folder. Make sure that the folders aren't replaced but merely merged.
  6. If you haven't yet done so, log back into your shop.

2.2Updates and Upgrades

You have direct and unlimited access to updates and upgrades during the duration of your support contract. In order to receive constant information about available updates we ask you to subscribe to our RSS feed that we publish for your module.

More information regarding the subscription of this RSS feed can be found under: http://www.sellxed.com/en/updates_upgrades.

We only recommend an update if something doesn't work in your shop, if you want to use new feature or if there is a necessary security update.

2.2.1Update Checklist

We ask you to strictly comply with the checklist below when doing an update:

  1. Always do a backup for your database and your files in your shop
  2. Use always a test system to test the update process.
  3. Wait until all the files are copied to the shop, clear the cache if there is one in your shop and then visit the configuration page of the main module so that the update process will be initialized.
Do not do updates directly in the live environment

Please test the update procedure first in your test shop. Our support team is able and willing to help you if you experience problems with the update process. However, if you decide to perform the update directly in your live shop there is the possibility of a downtime of the shop of more than two days depending on the availability of our support if you do not want to book our complementary support.

Depending on the version it could be that the database has to be migrated. We recommend you therefore, to perform the updates in times when the shop is not visited too frequently by your customers.

2.2.2Update Instructions

Please always read the update instruction. Those instructions can be found in the changelog. If there are no special remarks, you can proceed by just overwriting the files in your system.

2.2.3Updated Plugin from the TrustlyCw to the CwbTrustlyCw Version.

We plan to release this plugin in the shopware store in the near future. To make this possible we hda to apply some changes to our code. Most important a prefix for our PHP classes is required and the plugin folder had to be renamed. To update to this new version simply overwriting the existing files is not possible. This sections describes the steps required to update the module in detail.

Do not do updates directly in the live environment

Please test the update procedure first in your development system. So you can ensure the update is working correctly.

Mutliple Plugins

If you are using multiple plugins from us. You need to update all of them to the new version.

  1. Activate the maintenance mode of the shop.
  2. Make a backup for your database and your files in your shop. Without this you will not be able to revert to the old version, if anything goes wrong.
  3. Upload the new plugin files.
  4. Deactivate the existing plugin. Do not deinstall the old plugin yet.
  5. Install and activate the new plugin.
  6. If you have custom css or template files for the plugin, adapt the changes to the new plugin.
  7. If you are using the Shopware API endpoint of this plugin, update the URL to new endpoint.
  8. Verify the main and method settings.
  9. Deinstall the old plugin.
  10. Delete the files of the old plugin. The following files/folders must be removed, if they exist:
    • engine/Shopware/Plugins/Local/Frontend/TrustlyCw
    • engine/Library/Customweb
    • engine/Library/Crypt
    • engine/Library/File
    • engine/Library/Math
    • engine/Library/Mobile
    • engine/Library/Net
    • engine/Library/PhoneNumber
    • engine/Library/System
    • engine/Library/loader.php
    • engine/Library/openssl.cnf
  11. Make a test transaction to verify everything is workin correctly.
  12. Deactive the maintenance mode of the shop.

3Module Configuration in the Shopware Shop

The configuration consists of two steps. The first step is the configuration of the main module with all the basic settings (cf. Configuration of the Main Module). During the second step you can then carry out individual configurations for each payment method . This allows for full flexibility and perfect adaptation to your processes.

Create backups!

Please create a backup of the main directory of your shop. In case of problems you will then always be able to return your shop to its original state.

We furthermore recommend testing the integration on a test system. Complications may arise with third party modules installed by you. In case of questions, our support is gladly at your disposal.

3.1Configuration of the Main Module

In order to install the main module search for Trustly under Settings > Plugin Manager . Click on the + symbol in order to begin the installation process. Afterwards, click the "edit" symbol and configure the main module.

Enter the individual options which you partly may have already used for the configuration of the administration interface of Trustly. Should an option not be clear to you, you can click on the question mark and will find further information on the settings.

3.2Configuration of the Payment Method

After having configured the main module, you will find all payment methods under Settings > Payment Methods. Activate each payment method you wish to offer in your shop. You can save individual settings for each payment method (and for each shop in case of a multi-shop set-up) and thereby optimally adapt the payment methods to your existing processes. The most central options are described in more detail further below.

Figure 3.1: Configuration of the Payment Method

3.3Assigning the Payment Method to the Shipping Costs

In order for the transactions and the shipping costs to be matched correctly to the payment methods you need to assign the payment methods to the shipping methods. Go to settings > shipping costs. Open all the shipping costs and add a payment method.

Figure 3.1: Assigning the Payment Method to the Shipping Method.
Attributing Payment Methods to the Shipping Method

Depending on the amount of delivered payment methods, it may be that certain payment methods can't be attributed to a specific shipping method as not all payment methods can be displayed. This is a known bug of Shopware. Merely the first 30 payment methods are displayed. Please delete all payment methods that you don't need and then all other payments will be displayed.

3.4Direct Capturing of Transactions

The option "Capture" allows you to specify if you wish to debit payments directly or if you first wish to authorise them and then debit the payment at a later point.

Depending on your acquiring contract, a reservation is only guaranteed for a specific period of time. Should you fail to debit the payment within that period, the authorisation may therefore no longer be guaranteed. Further information on this process can be found below.

Different settings between Trustly and the module

It may be that settings saved in the payment modules overwrite settings saved in Trustly.

3.5Uncertain Status

You can specifically label orders for which the money is not guaranteed to be received. This allows you to manually control the order before shipment.

3.5.1Setting the order state

For each payment method you may select in which state the order should be set to depending on the booking state. This is the initial state of the order.

3.6Optional: Validation

Note: It can be that this option is not visible in your module. In this case just ignore this section.

With the option 'Validation' you can define the moment when the payment method should be made visible to the customer during the checkout process. This setting is relevant for modules where the usage depends on the customer's compliance with specific preconditions. For example, if a solvency check has to be carried out or if the payment method is only available in certain countries. In order for the credit check or address validation to also work with European characters, the charset of the "Blowfish mode" must be set to "UTF-8" for certain PSP settings.

You have the choice between these options:

  • Validation before the selection of the payment method: A validation verification is carried out before the customer selects the payment method. If the customer does not fulfill the requirements, the payment method is not displayed
  • Validation after selection of the payment method: The verification of the compliance occurs after the selection of the payment method and before the confirmation of the order
  • During the authorisation: The validation verification is carried out by Trustly during the authorisation process. The payment method is displayed in any case

3.6.1Usage of the Integrated Multishop Functionality of Shopware

The payment module supports the multishop feature of Shopware. No further modifications are necessary. The module automatically recognizes the shop the order belongs to. In order for the multishop functionality to work, it is, however, necessary that the individual sub-shops within Shopware have been configured correctly.

4Settings / Configuration of Payment Methods

4.1General Information About the Payment Methods

The plugin contains the most common payment methods. In case a desired payment method is not included per default, please contact us directly.

In order to be able to use a payment method, it must be activated in your account with Trustly as well as in your shop. Information about the configuration of the payment methods can be found further above.

Below you can find important information for specific payment methods that deviate from the standard process.

4.2Information on Payment Status

For each payment method you can define an initial payment status (status for authorized payments etc.). You hereby define the payment status for each state depending on the processing type of the order (captured, authorized, etc.). It's the initial status which the order assumes. Depending on the mutation carried out by you, the status can change.

Important info regarding Order Status

Never set the status to Pending Trustly or any similar pending status which is implemented by the module.

4.2.1Order status "pending" / imminent payment (or similar)

Orders with the status 'pending Trustly' are pending orders. Orders are set to that status if a customer is redirected in order to pay but hasn't returned successfully or the feedback hasn't reached your shop yet (Customer closed window on the payment page and didn't complete payment). Depending on the payment method these orders will automatically be transformed into cancelled orders and the inventory will be cleared (so long as the Cronjob is activated). How long this takes depends on the characteristics of the payment method and cannot be configured.

If you have a lot of pending orders it usually means that the notifications from your webserver to Trustly are being blocked. In this case check the settings of your firewall and ask the Hoster to activate the IPs and User Agents of Trustly.

4.2.2Order status "cancelled"

Orders with the status "cancelled" have either been set to that status automatically due to a timeout, as described above, or have been cancelled directly by the customer.

5The Module in Action

Below you will find an overview of the most important features in the daily usage of the Trustly module.

5.1Useful Transaction Information on the Order

In each order, processed via our module, you can find an overview of the most important information about the transaction as well as a transaction history.

In order to get to the transaction information, open the order and switch to the tab Transactions. Here you will find all authorization attempts and the related information.

Figure 5.1: Transaction Information in Shopware.

5.2Refunds

You can refund already captured transactions and automatically transmit them to Trustly. In order to to so, open the order. Switch to the tab Transactions. A new window will open up in which you must then switch to the tab Refunds in order to refund orders.

To refund a line item you need to enter the quantity you wish to refund. By clicking Refund, the refund is automatically transmitted to Trustly. It will than be refunded via the payment method the customer chose for the transaction.

Figure 5.1: Refunding Orders in Shopware.

Please note that you can't refund more than 100% of the original amount.

Executing a refund will not change the status of the order.

6Getting the Credit Card Data via Shopware REST API

When connecting ERP systems to Shopware it may be that further information is required via Shopware API. Our module provides you with a lot of payment information also via Shopware REST API.

Basic Information about the usage of the REST API of Shopware can be found in the Shopware Developers Guide.

The service can be called up under https://www.shop-url.com/api/CwbtrustlycwTransactions. The call of the above URL leads to the listing of all transactions. By adding the Transaction ID you can filter by the corresponding Transaction ID. The Transaction ID can be found in the order overview (Customer > Payments > Trustly )

Additionally, you can also access the transaction via the Payment ID (transmitted through Trustly). To do so, the parameter 'usePaymentId=1' has to be added as a parameter to the URL.

7Set-up a cron job to activate the timed operations

To activate the timed operations of the plugin (e.g. update service, deleting pending orders, etc.) make sure that you set up the Shopware Cron engine. Especially the update function allows you to automatically retrieve additional information or changes of your order directly via the API of Trustly. For payment methods which use a delayed authorisation process this is mandatory. Please note it could be that in order to use the update feature it may be necessary that Trustly activates additional options in your account.

The module uses the standard cron engine of Shopware. More information regarding the set up can be found here: https://community.shopware.com/Cronjobs_detail_1102.html.

8Testing

Before switching from test to live mode it is important that you test the module extensively.

Testing

Do not forget to switch the operating mode from test to live after having successfully tested the module.

8.1Test Data

In the following section you can find the test data for the various payment methods:

9Errors and their Solutions

You can find detailed information under http://www.sellxed.com/en/faq. Should you not be able to solve your problem with the provided information, please contact us directly under: http://www.sellxed.com/en/support

9.1The Referrer URL appears in my Analytics Tool

When a customer and the notification are redirected via Header Redirection, the Trustly Referrer URL might appear in your Analytics Tool thus hiding the original traffic source. However, most Analytic Tools are able to minimize this problem.

In case you are using Google Analytics as reporting tool, this step by step guide may help you to exclude the URLs: under bullet point 4.

10Compatibility with Third-Party Plugins

The plugins listed below are compatible with our payment modules and allow you to handle certain tasks in an easier way.

10.1Birthday and gender in Shopware

For certain payment service providers it is necessary to check the birthday and the gender of a customer. Shopware does not check this by default. To enable these checks go to "Configuration > Basic Settings > Frontend > Login / Registration" and check the following parameters:

  • Show Birthday Field
  • Birthday is required
  • Show "I am" select field

11Error Logging

The module will log different unexpected errors or information depending on the configured level. If there is any issue with the module, this log can help identify the cause.

11.1Log Levels

You can configure the log level in the Trustly settings.

  • Error: Logs unexpected errors only. (Default)
  • Info: Logs extended information.
  • Debug: Logs information helpful for debugging.

11.2Log Location

The log file is stored in the Shopware log directory. Please make sure the path exists and it is writable by the webserver. (Default Path: {shopRootDirectory}/logs or {shopRootDirectory}/var/log)

12Advanced Information

This section of the manual is for advanced usage of the module. The content is for advanced users with special requirements. Everything in this section is optional and not required for the daily usage of the module.

12.1Transaction Object

This section describes how to extract information from a transaction, if you need it for further processing. E.g. you require more information of the transaction for further processing an order in your ERP system.

The code snippets in this section assume your script resides in the root folder of the shop with the default shop folder structure.

Have Shopware initialized in your script, this is required for the database connection.
require __DIR__ . '/autoload.php';
use Shopware\Kernel;
$environment = 'production';
$kernel = new Kernel($environment, false);
$kernel->boot();
Register the module module classes.
$pluginPath = 'engine/Shopware/Plugins/Local/Frontend/CwbTrustlyCw';
Shopware()->Loader()->registerNamespace('Customweb', 'Customweb/');
Shopware()->Loader()->registerNamespace('CwbTrustlyCw_Helpers', $pluginPath . '/Helpers/');
Shopware()->Loader()->registerNamespace('CwbTrustlyCw_Entities', $pluginPath . '/Entities/');
Shopware()->Loader()->registerNamespace('CwbTrustlyCw_Components', $pluginPath . '/Components/');
Shopware()->Loader()->registerNamespace('Shopware\Components\Api', $pluginPath . '/Components/Api/');

require_once $pluginPath . '/Library/loader.php';
Customweb_Core_Util_Class::registerClassLoader(function ($className){
	return Shopware()->Loader()->loadClass($className);
});	
To load old transactions register a legacy class loader.
	Customweb_Core_Util_Class::registerClassLoader(function($className){
		if(strpos($className, 'TrustlyCw') === 0){
			$fileName = substr($className, strrpos($className, '_')+1).".php";
			if(file_exists('engine/Shopware/Plugins/Local/Frontend/CwbTrustlyCw/Legacy/'.$fileName)){
				require_once 'engine/Shopware/Plugins/Local/Frontend/CwbTrustlyCw/Legacy/'.$fileName;
				return true;
			}
		}
		return false;
	});
	
Now you can load the transaction and then extract the transactionObject.
Load the transaction by Id:
$transactionById =  CwbTrustlyCw_Helpers_Util::loadTransaction($transactionId);
$transactionObject = $transactionById->getTransactionObject();