96
Worldpay Integration Worldpay SAP Hybris AddOn Guide v6.3 February 2017 Contains the following guides: Implementation Guide User Guide Technical Guide B2B Technical Guide OCC Technical Guide

Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Embed Size (px)

Citation preview

Page 1: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay Integration

Worldpay SAP Hybris AddOn Guide v6.3 February 2017

Contains the following guides:

Implementation Guide

User Guide

Technical Guide

B2B Technical Guide

OCC Technical Guide

Page 2: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Contents

Contents Implementation Guide .......................................................................................... 6

1.1 Introduction .......................................................................................................................... 6

1.1.1 Fundamental Concepts .................................................................................................. 6

1.1.2 Installation and Usage.................................................................................................... 7

1.1.3 Worldpay Accounts ...................................................................................................... 11

1.1.4 Worldpay Magic Values ............................................................................................... 12

1.2 Notification Endpoint ......................................................................................................... 12

1.2.1 Mocking Worldpay Notifications ................................................................................. 12

1.3 Configuring the AddOn ....................................................................................................... 13

1.3.1 Merchant Code Configuration ..................................................................................... 13

1.3.2 Checkout Flow.............................................................................................................. 16

1.3.3 Alternative Payment Methods – B2C only................................................................... 17

1.3.4 Client Side Encryption (CSE) ......................................................................................... 25

1.3.5 Hosted Payment Pages (HPP) – B2C only .................................................................... 26

1.3.6 General configuration .................................................................................................. 26

1.3.7 Configuring the Support Email ..................................................................................... 27

1.4 Extending the AddOn ......................................................................................................... 30

1.4.1 Cron Jobs to Process Order Modifications from Worldpay ......................................... 30

1.4.2 orderModificationProcessorJob .................................................................................. 30

1.4.3 CronJobs to capture Payment Method Information ................................................... 33

1.4.4 Riskscore and fraud...................................................................................................... 36

1.4.5 Notification commands................................................................................................ 40

1.4.6 Cancellations ................................................................................................................ 40

1.4.7 Refunds ........................................................................................................................ 44

1.4.8 Checkout Flow.............................................................................................................. 44

1.4.9 Customising the Worldpay AddOn .............................................................................. 45

Page 3: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay hybris Extension Guide > Contents 3

1.5 Project Customisation Points of Consideration................................................................. 46

1.6 Supported environments ................................................................................................... 47

Technical Implementation Guide ......................................................................... 47

2 High Level Architecture ...................................................................................................... 47

2.1 Hybris Commerce Suite Extensions ................................................................................... 48

2.1.1 Connector..................................................................................................................... 48

2.1.2 Front end...................................................................................................................... 48

2.1.3 Notification .................................................................................................................. 50

2.1.4 Testing .......................................................................................................................... 50

2.2 AddOn Integration with Hybris Payment Module ............................................................ 51

2.2.1 New B2C Accelerator Checkout Flow .......................................................................... 53

2.3 Order Cancellation.............................................................................................................. 62

2.4 Extended Types................................................................................................................... 63

2.5 Supported Environments ................................................................................................... 64

2.6 Limitations .......................................................................................................................... 64

2.7 Languages............................................................................................................................ 64

End User Guide.................................................................................................... 64

3 Introduction ........................................................................................................................ 64

3.1 Alternative Payment Methods Configuration ................................................................... 64

3.1.1 Configuration using hMC ............................................................................................. 64

3.1.2 Adding Payment Method Buttons using the Hybris WCMS Cockpit ........................... 67

3.2 Configuring the payment flow ........................................................................................... 73

3.2.1 Enabling debug mode for development ...................................................................... 75

3.2.2 Specific properties for Lightbox ................................................................................... 76

3.3 Cron Jobs ............................................................................................................................. 76

3.4 Order Modifications ........................................................................................................... 78

FAQ / trouble shooting ........................................................................................ 80

3.5 Checklist .............................................................................................................................. 80

3.6 Raising a request................................................................................................................. 81

B2B Technical Implementation Guide .................................................................. 83

3.7 Reader's guide .................................................................................................................... 83

Page 4: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay hybris Extension Guide > Contents 4

3.7.1 B2B Technical Implementation Guide ......................................................................... 83

3.7.2 New B2B Accelerator Checkout Flow .......................................................................... 83

3.7.3 Card Payment flow....................................................................................................... 83

3.7.4 Handling of 3D Secure.................................................................................................. 83

3.7.5 Requesting Security Code (CVV) on card payment...................................................... 84

3.8 Business processes ............................................................................................................. 84

3.8.1 Replenishment business flow ...................................................................................... 84

3.8.2 Two replenishment action's have been customized in the Worldpay B2B AddOn:.... 84

Worldpay OCC AddOn extension ......................................................................... 85

3.9 Introduction ........................................................................................................................ 85

3.9.1 Endpoints on the WorldpayCartsController ................................................................ 85

3.9.2 Endpoints on the WorldpayOrdersController.............................................................. 85

3.10 Payment flows .................................................................................................................... 86

3.10.1 Payments flow without 3D secure ............................................................................... 86

3.10.2 Payments flow with 3D secure .................................................................................... 86

3.11 Data adjustment on Worldpay communication................................................................ 86

3.12 Handling session id in a stateless environment ................................................................ 86

3.12.1 Passing client IP address through OCC to Worldpay ................................................... 86

3.13 Test template extension - yworldpayocctest .................................................................... 87

3.14 Module generation ............................................................................................................. 87

3.15 Test Data ............................................................................................................................. 88

Appendix A: SAP Hybris Software End User License Agreement ....................... 92

Page 5: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > 5

This Software End User License Agreement ("Agreement") is between you (both the i ndividual downloading and/or installing the Software and any legal entity for which the individual is acting) ("You" or "Your") and

WORLDPAY (UK) LIMITED ("WorldPay").

TAKING ANY STEP TO SET UP, DOWNLOAD OR INSTALL THE SOFTWARE MEANS THAT YOU ACCEPT ALL OF THE TERMS OF THIS LICENSE AGREEMENT. PERMISSION TO DOWNLOAD, INSTALL AND/OR USE THE

SOFTWARE IS EXPRESSLY CONDITIONED ON YOU FOLLOWING THESE TERMS. IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS AGREEMENT, YOU ARE NOT AUTHORISED TO USE THE SOFTWARE AND MUST STOP

INSTALLING IT OR UNINSTALL IT, AS APPLICABLE.

THIS SOFTWARE IS TO BE USED SOLELY IN CONNECTION WITH THE THIRD PARTY SOFTWARE AND YOU MUST SATISFY YOURSELF THAT THIS SOFTWARE IS SUITABLE FOR YOUR NEEDS AND THAT YOUR SYSTEM

SATISFIES THE REQUIREMENTS FOR THE USE OF THIS SOFTWARE AS SET OUT IN THE DOCUMENTATION.

Page 6: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 6

Implementation Guide

1.1 Introduction

Hybris is a java based eCommerce platform built on the Spring MVC framework. The purpose of

providing an AddOn for Worldpay is to aid integration of Worldpay into a Hybris implementation.

This document describes how to install and configure the AddOn to work with any Hybris

implementation.

As Hybris is built on the Spring framework this makes it highly customisable and extensible. The

AddOn also utilises this framework so can also easily be extended to add specific behaviour if required.

1.1.1 Fundamental Concepts

Hosted Payment Page (HPP) – B2C only

The plugin has been developed to support payment by redirecting to Worldpays Hosted Payment

pages, known as HPP.

The redirect payment model enables a site to reduce PCI considerations by ensuring card details

are not visible to any aspect of their Hybris installation. Worldpay hosts the pages that capture

and process the card details, all that is required of the implementer is to redirect the user to these

pages at the relevant point in their checkout flow and then process the authorisation response

returned from the hosted order pages.

The plugin supports full page redirect, iframe and lightbox.

Client Side Encryption (CSE)

Client side encryption is a way of capturing the payment details of a customer and sending the

encrypted data to the Hybris Commerce Suite to pass through Direct XML integration to Worldpay.

The payment details are encrypted in the client browser using the Worldpay CSE encryption

JavaScript library, reducing PCI DSS compliance requirements.

Card Tokenisation

Worldpay enables their clients to tokenise cards of customers so that the same payment method

can be reused for subsequent orders.

Once a payment method (Card) has been tokenised, the payment details are saved into the

customer's session cart. If the customer chooses to save the payment details doing checkout, the

payment details are stored into the customer's profile.

Page 7: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 7

If the customer at a later time chooses to remove the payment details, a delete token request is send to Worldpay.

No token delete request are sent for the tokens associated to payment details that is only stored

on the customer's cart and later orders.

This This functionality is available on the Hosted payment pages and Client Side Encryption.

Alternative Payment Methods – B2C only

Alternative Payment Methods (APM's) allow for payment types other than Credit or Debit Cards to be used through the Worldpay payment gateway such as PayPal, iDeal and Alipay.

1.1.2 Installation and Usage

Installing the Plugin into Hybris with fulfilment functionality

First ensure that the version of Hybris being used is supported for the plugin. Please view the Compatibility section for the current list of supported versions.

The plugin is supplied as a zip file with several Hybris extensions inside. Take the following steps to

include the full plugin into your Hybris application:

1. Unzip the supplied plugin zip file

2. Copy the extracted folders to the ${HYBRIS_BIN_DIR} of your hybris installation.

3. Run the ‘ant clean’ command from within your hybris bin/platform directory.

4. Remove conflicting AddOn: a. If you are installing the B2C AddOn

i. Delete the worldpayb2baddon extension ${HYBRIS_BIN_DIR}/ext-worldpay b. If you are installing the B2B AddOn

i. Delete the worldpayaddon extension from ${HYBRIS_BIN_DIR}/ext-worldpay

5. Copy the following lines into your localextensions.xml after <path

dir="${HYBRIS_BIN_DIR}"/>. The extensions do not rely on any absolute paths so it is also

possible to place the extensions in a different location (such as

${HYBRIS_BIN_DIR}/custom).

6. <path autoload="true" dir="${HYBRIS_BIN_DIR}/ext-worldpay"/>

a. <path autoload="true" dir="${HYBRIS_BIN_DIR}/ext-worldpayfulfilment"/>

7. Run the following commands to install the AddOn's on the yaccelatorstorefront (replace "yacceleratorstorefront" with your custom storefront if relevant):

Page 8: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 8

a. If you are installing the B2C AddOn: ant addoninstall -Daddonnames="worldpayaddon,worldpaynotificationaddon" -DaddonStorefront.yacceleratorstorefront="yacceleratorstorefront"

b. If you are installing the B2B AddOn: ant addoninstall -Daddonnames="worldpayb2baddon,worldpaynotificationaddon," -DaddonStorefront.yacceleratorstorefront="yacceleratorstorefront"

The worldpaysampledataaddon is optional, and can be installed by running:

ant addoninstall -Daddonnames="worldpaysampledataaddon" -DaddonStorefront.yacceleratorstorefront="yacceleratorstorefront"

c. Run the ‘ant clean all’ command from within your hybris bin/platform directory 8. Run the hybrisserver.sh to startup the hybris server.

9. Update your running system.using "ant updatesystem"

Except for setting up your hosts file, the Worldpay AddOn will work initially without any external setup needed.

There are various things to consider with regards to utilizing the AddOn fully - these are

mentioned below. The AddOn's are independent and can be installed on separate server

instances. For example, the worldpaynotificationaddon AddOn can be running on server instances

dedicated for listening to Worldpay Order Modification messages.

Installing the Plugin into Hybris with OMS functionality

First ensure that the version of Hybris being used is supported for the plugin. Please view the Compatibility section for the current list of supported versions.

As the OMS extension cannot co-exist with the fulfilment extension (i.e. any fulfilment process

generated through modulegen - yfulfilmentprocess), if the functionality has been extended, all

customisations will need to be applied in the OMS extension and the fulfilment extension removed from the installation.

The plugin is supplied as a zip file with several Hybris extensions inside. Take the following steps to

include the full plugin into your Hybris application:

1. Unzip the supplied plugin zip file

2. Copy the extracted folders to the ${HYBRIS_BIN_DIR} of your Hybris installation.

3. Remove conflicting AddOn: a. If you are installing the B2C AddOn

i. Delete the worldpayb2baddon extension ${HYBRIS_BIN_DIR}/ext-worldpay

Page 9: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 9

b. If you are installing the B2B AddOn i. Delete the worldpayaddon extension from ${HYBRIS_BIN_DIR}/ext-worldpay

4. Run the ‘ant clean’ command from within your Hybris bin/platform directory.

5. Copy the following lines into your localextensions.xml after <path

dir="${HYBRIS_BIN_DIR}"/>. The extensions do not rely on any absolute paths so it is also

possible to place the extensions in a different location (such as

${HYBRIS_BIN_DIR}/custom).

6. <path autoload="true" dir="${HYBRIS_BIN_DIR}/ext-worldpay"/>

a. <path autoload="true" dir="${HYBRIS_BIN_DIR}/ext-worldpayoms"/>

7. Run the following commands to install the AddOn's on the yaccelatorstorefront (replace "yacceleratorstorefront" with your custom storefront if relevant):

a. If you are installing the B2C AddOn: ant addoninstall -Daddonnames="worldpayaddon,worldpaynotificationaddon,ordermanagementaddon" -DaddonStorefront.yacceleratorstorefront="yacceleratorstorefront"

b. If you are installing the B2B AddOn: ant addoninstall -Daddonnames="worldpayb2baddon,worldpaynotificationaddon,ordermanagementaddon" -DaddonStorefront.yacceleratorstorefront="yacceleratorstorefront"

The worldpaysampledataaddon is optional, and can be installed by running:

ant addoninstall -Daddonnames="worldpaysampledataaddon" -DaddonStorefront.yacceleratorstorefront="yacceleratorstorefront"

c. Run the ‘ant clean all’ command from within your hybris bin/platform directory

8. Run the hybrisserver.sh to startup the hybris server.

9. Update your running system.using "ant updatesystem"

Except for setting up your hosts file, the Worldpay AddOn will work initially without any external

setup needed.

There are various things to consider with regards to utilizing the AddOn fully - these are

mentioned below. The AddOn's are independent and can be installed on separate server

instances. For example, the worldpaynotificationaddon AddOn can be running on server instances

dedicated for listening to Worldpay Order Modification messages.

Installing the Plugin using the provided recipes

The AddOn provides 3 gradle recipes to be used with the Hybris installer.

wp_b2c_acc with fulfilment functionality

Page 10: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 10

wp_b2c_acc_oms with OMS functionality

wp_b2b_acc with fulfillment functionality

The recipes are based on the b2c_acc and b2c_acc_oms and b2b_acc recipes provided by Hybris.

The recipes can be found under the “installer” folder in the extracted ZIP.

Figure 1: Recipe location

Follow these steps to use the recipes: in a Hybris installation:

1. Extract from the supplied ZIP file the folder Hybris to your ${HYBRIS_BIN_DIR} 2. Since the recipe generates the local.properties file with the properties defined in the recipe,

optionally you can add your local.properties to the customconfig folder.

In order to install the AddOn using one of the recipes, run the following commands:

#This will create a solution from the accelerator templates, and install the addons.

HYBRIS_HOME/installer$ ./install.sh -r [RECIPE_NAME] setup

#This will build and initialize the platform

HYBRIS_HOME/installer$ ./install.sh -r [RECIPE_NAME] initialize

#This will start a commerce suite instance

HYBRIS_HOME/installer$ ./install.sh -r [RECIPE_NAME] start

Assisted Services Module (ASM)

The AddOn supports payments through the storefront using the ASM, through the worldpayasm extension.

If your installation uses the ASM, make sure that you also include the worldpayasm extension in your recipe or localextensions.xml

Note: If you don't use ASM in your installation, make sure that you do

not include the worldpayasm extension. Doing so will create an unwanted

dependency on the assistedservicesfacades.

Hosts file entries – B2C only

In order for the storefront return URLs to resolve correctly on return from HPP pages the following

must be added to your hosts file:

127.0.0.1 apparel-uk.local apparel-de.local electronics.local

Page 11: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 11

If using your own site:

127.0.0.1 your-site.local

URLs

The customer-service cockpit is a separate extension and thus can be accessed at https://localhost:9002/cscockpit/index.zul

The storefront is directly extended, and can be accessed through the following urls:

https://electronics.local:9002/yacceleratorstorefront/electronics/en

https://apparel-uk.local:9002/yacceleratorstorefront/en

https://apparel-de.local:9002/yacceleratorstorefront/de

B2C only - In case the solution needs to support lightbox and iframe, it is necessary that the URLs

set up in the implementation are Top Level Domains. It means that a .local domain will not work

and the Lightbox or Iframe will raise an error. To solve it, your url's need to be like:

https://electronics.myshop.com:9002/yacceleratorstorefront/electronics/en

https://apparel-uk.myshop.com:9002/yacceleratorstorefront/en

https://apparel-de.myshop.com:9002/yacceleratorstorefront/de

And your DNS or hosts file need to resolve those URL.

1.1.3 Worldpay Accounts

To integrate properly with Worldpay, you need to have an account set up to integrate with. For

this, the following steps needs to be completed with your Worldpay Implementation Manager:

Worldpay account Creation of merchant codes

URL needs to be provided for the Hybris Commerce Suite Order Notification Endpoint

Other configuration can be carried out through the Worldpay Merchant Interface:

Setting up action notification emails from Worldpay (if required) Setting up MAC (Message Authentication Code) for each merchant (if required) Setting account contact details

Page 12: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 12

While setting up the merchant configuration, please note the limit per transaction, usually £5,000

GBP. If the solution needs a higher limit, please contact with your Worldpay Implementation

Manager.

1.1.4 Worldpay Magic Values

In order to trigger different refused decline codes through the Worldpay sandbox, you can use

magic values, which are specified on the link below:

http://support.worldpay.com/support/kb/gg/pdf/sandbox-magic-values.xls

1.2 Notification Endpoint

An endpoint to receive Worldpay notifications must be configured in the Worldpay merchant profile page:

The shipped configured endpoint is:

<yourstorefront>/worldpay/merchant_callback?site=<yoursiteUid>

It is set up in OrderModificationController in

the com.worldpay.worldpaynotificationaddon.controllers.order.notification package inside

the worldpaynotificationaddon extension. As the code to receive order notification messages is

separated in its own AddOn, it is possible to install this on just a subset of nodes in your Hybris Commerce Suite installation.

For security reasons, it is highly recommended to restrict access to the notification endpoint to

only allow the Worldpay IP range. One of many solutions is to add a filter in the gateway, only

whitelisting the Worldpay IP range accessing the nodes running the notificationaddon.

1.2.1 Mocking Worldpay Notifications

A mock to simulate notifications being sent from Worldpay has been produced and is included

within the AddOn. This makes it possible to test various scenarios on environments that are not

configured for getting notifications from Worldpay.

Page 13: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 13

The mock can be accessed from the URL:

https://electronics.local:9002/worldpayresponsemock/responses

After placing an order, access the mock tool, and put in the Worldpay ordercode in the ordercode

field. The Worldpay ordercode is the same as the id of the paymentTransaction attached to the

order.

The responses configured in the mock will be sent to the endpoint, explained above.

The folder that contains the mock is ext-worldpaytest in the shipped zip file. If the mock is going to

be used:

1. Add in your localextensions.xml <extension name="worldpayresponsemock"/> 2. In hybris/bin/platform, run "ant all"

If the order has been submitted using the CSE/Direct flow, it is not necessary to mock the

authorised response as the response comes synchronously from Worldpay.

1.3 Configuring the AddOn

1.3.1 Merchant Code Configuration

There are three types of merchant codes which can be configured:

Web (ECOM) - Used for purchases made via the Web channel Mobile (ECOM) - Used for purchases made via the Mobile channel Customer Service (MOTO) - Used for purchases made via the Customer Services channel (Customer

not present transaction)

MOTO stands for Mail Order/Telephone Order

Configuration Details

The configuration is defined in xml files in the "worldpayapi/resources/merchants" folder. In this

folder, two files are shipped with the addon: merchants.xml and merchants -dev.xml. The

merchants.xml file makes sure that all files in the folder matching the regex "merchants-*.xml" are

imported, and the merchants-dev.xml contains a set of default merchants.

Once you have received details about your merchants, you will need to configure this in the xml

files mentioned. This can be achieved in many ways, the simplest being editing the merchants-

dev.xml file. For more advanced configurations, we recommend using spring profiles (see

http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-

definition-profiles-xml ).

Page 14: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 14

Switching MOCK/TEST/PRODUCTION environment:

In your local.properties set the value of the following property to change between environments. By default, in the worldpayapi extension it is configured to TEST

# Valid values for environment are MOCK, TEST and PRODUCTION

worldpay.config.environment=TEST

The actual endpoints are configured in the following properties:

worldpay.config.endpoint.MOCK=http://electronics.example.com:9001/worldpayresponsemock/mock

worldpay.config.endpoint.TEST=https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp

worldpay.config.endpoint.PROD=https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp

You will need to modify the value of "worldpay.config.endpoint.MOCK" to match the environment you have set up to run the mock.

Channel to Merchant Mapping

The AddOn provides the functionality to select a set of merchant codes for an specific site. To

achieve this, you need to define the various merchant codes in your merchants.xml

< util:map id = "worldpayMerchantConfigurationSite1" value-type = "com.worldpay.config.merchant.WorldpayMerchantConfigData" >

< entry key = "web" value-ref = "webMerchantConfigurationSite1" />

< entry key = "mobile" value-ref = "mobileMerchantConfigurationSite1" />

< entry key = "customerService" value-ref = "customerServiceMerchantConfiguration" />

</ util:map >

Page 15: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 15

< util:map id = "worldpayMerchantConfigurationSite2" value-type = "com.worldpay.config.merchant.WorldpayMerchantConfigData" >

< entry key = "web" value-ref = "webMerchantConfigurationSite2" />

< entry key = "mobile" value-ref = "mobileMerchantConfigurationSite2" />

< entry key = "customerService" value-ref = "customerServiceMerchantConfiguration" />

<entry key="asm" value-ref="customerServiceMerchantConfigurationASM"/>

</

</ util:map >

In local.properties, you can configure which sites use which merchant codes, using the UID of the

site:

worldpaymerchantconfig.[UID of site]=worldpayMerchantConfigurationSite1

worldpaymerchantconfig.[UID of site]=worldpayMerchantConfigurationSite2

Merchant Details per Channel

< bean id = "customerServiceMerchantConfiguration" class = "com.worldpay.config.merchant.WorldpayMerchantConfigData" >

< property name = "code" value = "MERCHANT1MOTO" />

< property name = "password" value = "password3" />

< property name = "macValidation" value = "true" />

< property name = "macSecret" value = "passwordMac3" />

< property name = "installationId" value = "1043270" />

< property name = "statementNarrative" value = "Statement Narrative Text MERCHANT1MOTO" />

< property name = "orderContent" value = "Order Content MERCHANT1MOTO" />

</ bean >

Configuration properties

Name Description

code Merchant Code

Page 16: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 16

Name Description

password Merchant password set up in the Worldpay merchant interface

macValidation Defines if MAC validation should be used.

macSecret Merchant MAC (Message Authentication Code) password set up in the Worldpay merchant interface

installationId Identification of the installation

statementNarrative Text that is displayed on the shopper’s statement.

orderContent HTML order content

includedPaymentTypes Payment types accepted through this channel/merchant

excludedPaymentTypes Payment types excluded from this channel/merchant

If CSE is used, an additional property needs to be added to the merchant configuration:

Name Description

csePublicKey Public key generated using the Worldpay Merchant Interface

Further explanation of these fields can be found by contacting your Implementation Manager

Assisted services

If your application uses the assisted services module, you will need to configure a specific

merchant using the key "asm" as seen in the merchants.xml example above. This merchant has to

be compatible with the payment flow used by the storefront. Typically a different merchant is

used as you would want to run the storefront with a different setup (such as disabling 3D secure)

when placing orders as an agent.

1.3.2 Checkout Flow

In agreement with the use of Worldpays Hosted Payment Pages the following properties should be

set in local.properties to hide the Accelerator's Checkout Flow options and default to HOP. B2C

only

storefront.show.checkout.flows= false

site.pci.strategy=HOP

Page 17: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 17

Also, the debug information on the HPP page (displaying Merchant Code and the callback URLs)

can be enabled/disabled setting the following property: (B2C only)

hop.debug.mode= true | false

The AddOn modifies the AccountOrderDetailsShippingComponent

and OrderConfirmationShippingComponent to display more detailed information about the

payment details of the selected order from the order confirmation page and the customer's order history page. If they are not available, they are not displayed.

To install this modified component into the specific contentCatalog, run the following impex,

changing <YOUR_CONTENT_CATALOG> to the appropiate contentCatalog name:

$contentCatalog=<YOUR_CONTENT_CATALOG>

$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[ default =$contentCatalog]),CatalogVersion.version[ default =Staged])[ default =$contentCatalog:Staged]

# This update modifies the existing AccountOrderDetailsShippingComponent jspInclude component (with payment

details in order history) by setting a new page existing in the worldpayb2caddon

INSERT_UPDATE JspIncludeComponent;$contentCV[unique= true ];uid[unique= true ];name;page

;;AccountOrderDetailsShippingComponent;Account Order Details Shipping Info Component;/WEB-

INF/views/addons/worldpayaddon/responsive/pages/account/worldpayAccountOrderDetailShippingInfo.js

p ;;OrderConfirmationShippingComponent;Order Confirmation Shipping Info Component;/WEB-

INF/views/addons/worldpayaddon/responsive/pages/account/worldpayAccountOrderDetailShippingInfo.jsp

1.3.3 Alternative Payment Methods – B2C only

These are non-card payment methods which have to be configured in the system. The APM configuration is stored in the WorldpayAPMConfiguration item type.

APM Configuration Attributes

Attribute Type Required Description Notes

code String Yes This is the APM code which

matches Worldpay APM codes

(i.e. SOFORT-SSL)

See here for

Worldpay payment

method codes

Page 18: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 18

Attribute Type Required Description Notes

name String (localised)

Yes This is the localised APM

name. The property will be

used on the order

confirmation / history page as well as in the CS Cockpit

description String (localised)

No Brief APM description.

autoCancelPendingT

imeoutInMinutes Integer Yes Timeout in minutes before the

order is auto-cancelled. If

Worldpay Authorise

notification is not received

within this time interval, the order will be cancelled.

This is likely to

happen because the

user has selected a

delayed payment

method which

required further user

action and the action

has not been take on

time.

Default value: 2880

minutes (2 days) bank Boolean Yes Indicates whether the apm

supports bank transfer To enable APMs that

support bank transfer,

at least one active

BankConfiguration

should be linked to the APM.

Default value: False

countries Set<CountryModel>

No Set of countries for which the

APM is available

The Country is related

to the user's shipping

address currencies Set<Currency

Model>

No Set of currencies for which the

APM is available

currencyRanges Set<Worldpa

yCurrencyRa

ngeModel>

No Set of currency ranges for which the APM is available

automaticRefunds Boolean Yes The APM can be refunded automatically

These fields should be

set according to the

Page 19: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 19

Attribute Type Required Description Notes

bankTransferRefunds

Boolean Yes The APM can be refunded via a bank transfer

abilities of the specific

APM. Please contact

your Worldpay

implementation

manager for more

details.

Bank Configuration Attributes

Attribute Type Required Description Notes

code String Yes This is the bank code which

matches Worldpay Shopper Bank Code (i.e. SNS_REGIO )

See here for

Worldpay

shopper bank codes

apm WorldpayAPMConfiguration Yes This is the apm the configuration relates to

name String (localised) No The name of the bank

description String (localised) No The description of the bank

active Boolean Yes Indicates whether this bank is active for apm

Default value: False

APM Availability Rules

The configuration properties such as countries, currencies and currencyRanges define whether an

APM can be used or not as payment method.

There are three rules which all have to be true in order to have an APM available to use for payment.

Country Rule

This rule inspects the country of the shipping address and evaluates the rules. The rules are

described as follows:

Countries Set Shipping Country Result

Empty N/A TRUE

Not empty Not in the Countries Set FALSE

Page 20: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 20

Countries Set Shipping Country Result

Not empty In the Countries Set TRUE

If the project requirement is to use the Billing address country, the Country rule can be

implemented to match this requirement.

Currency Rule

This rule inspects the Cart's currency and evaluates the rule. The rules are described as follows:

Currencies Set Cart's Currency Result

Empty N/A TRUE

Not empty Not in the Currencies Set FALSE

Not empty In the Currencies Set TRUE

Currency Ranges Rule

This rule inspects the Cart's total and evaluates the rule. The rules are described as follows:

Currency Range Set

Cart's Currency Currency Range

Boundaries Cart's Total Result

Empty N/A N/A N/A TRUE

Not empty Not in the Currency Range Set

N/A N/A TRUE

Not empty In the Currency Range Set No Min, No Max N/A TRUE

Not empty In the Currency Range Set Min and Max < Min OR >Max FALSE

Not empty In the Currency Range Set Min and Max >= Min AND <=Max

TRUE

Currency Ranges are stored in the WorldpayCurrencyRange item type which has the following

attributes:

Attribute Type Required Description

currency CurrencyModel Yes This is the Currency for the defined range

min Double No This is the minimum amount for the defined range

Page 21: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 21

Attribute Type Required Description

max Double No This is the maximum amount for the defined range

Bank Transfer Rule

This rule inspects the APM's bank configuration and evaluates the rule. The rules are described as follows:

APM's Bank Indicator Bank Configuration Set Result

False Not checked TRUE

True Does not contain active banks FALSE

True Contains active banks TRUE

Modifying APM Availability Rules

Rules are executed by the APM Availability Service which is defined in worldpayapi-spring.xml as

follows:

worldpayapi-spring.xml

<alias name="defaultAPMAvailabilityService" alias="apmAvailabilityService" />

<bean id="defaultAPMAvailabilityService" class="com.worldpay.service.apm.impl.DefaultAPMAvailabilityService">

<property name="apmAvailabilityStrategyList">

<list>

<ref bean="apmAvailabilityCountryStrategy"/>

<ref bean="apmAvailabilityCurrencyStrategy"/>

<ref bean="apmAvailabilityRangeStrategy"/>

<ref bean="apmAvailabilityBankStrategy"/>

</list>

</property>

</bean>

The service runs the strategies defined in the apmAvailabilityStrategyList and exits as soon as a

strategy returns a false result. The service is extensible and strategies can be added, removed or modified.

Page 22: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 22

All strategies implement the APMAvailabilityStrategy interface and receive the WorldpayAPMConfigurationModel and the CartModel in input.

The following class diagram describes the implementation for the APM availability rules.

Alternative Payment Methods CMS implementation

All templates, pages, components, etc. belong to a specific content catalogue.

The page templates for the billing address pages listed below contain the PaymentButtons content

slot.

WorldpayPaymentAndBillingCheckoutPageTemplate WorldpayCSEPaymentAndBillingCheckoutPageTemplate WorldpayIframePaymentAndBillingCheckoutPageTemplate WorldpayLightboxPaymentAndBillingCheckoutPageTemplate

Page 23: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 23

The following components for PaymentButtons are allowed: WorldpayCCComponent and the WorldpayAPMComponent.

WorldpayCCComponent extends the SimpleCMSComponent and only contains 1 extra attribute: a

localised image used to represent the pay-by-card option.

WorldpayAPMComponent also extends the SimpleCMSComponent but contains 2 additional attributes: a localised image to represent the APM and the configuration for the APM.

worldpayb2caddon-items.xml

<itemtype code="WorldpayCCComponent" autocreate="true" generate="true"

extends="SimpleCMSComponent" jaloclass="com.worldpay.jalo.WorldpayCCComponent">

<attributes>

<attribute type="localized:Media" qualifier="media">

<persistence type="property" />

</attribute>

</attributes>

</itemtype>

<itemtype code="WorldpayAPMComponent" autocreate="true" generate="true"

extends="SimpleCMSComponent" jaloclass="com.worldpay.jalo.WorldpayAPMComponent">

<attributes>

<attribute qualifier="apmConfiguration" type="WorldpayAPMConfiguration">

<persistence type="property"/>

</attribute>

<attribute type="localized:Media" qualifier="media">

<persistence type="property" />

</attribute>

</attributes>

The WorldpayCCComponent uses a Hybris renderer to populate the model (by default this will automatically populate the jsp with the Component's attributes). This is set up via spring:

worldpayb2caddon-web-spring.xml

<bean id="WorldpayCCComponentRenderer" parent="addOnJspIncludeCMSComponentRenderer"/>

Page 24: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 24

<bean id="WorldpayCCComponentRendererMapping" parent="addonCmsComponentRendererMapping">

<property name="typeCode" value="WorldpayCCComponent"/>

<property name="renderer" ref="WorldpayCCComponentRenderer"/>

</bean>

The WorldpayAPMComponent uses a custom controller which extends the

GenericCMSAddOnComponentController - which allows the Component's attributes to be

available on the jsp (similar to how the WorldpayCCComponent works using the renderer). This is

configured using spring annotations:

WorldpayAPMComponentController

@Controller("WorldpayAPMComponentController")

@RequestMapping(value = "/view/WorldpayAPMComponentController")

public class WorldpayAPMComponentController extends GenericCMSAddOnComponentController {...}

For the front-end to show the payment button components we have added the following to the

worldpayChoosePaymentDetailsPage.jsp:

worldPayChoosePaymentDetailsPage.jsp

<cms:pageSlot position="PaymentButtons" var="button" element="div" class="cms-payment-button">

<cms:component component="${button}"/>

</cms:pageSlot>

The components themselves are represented by the 2 following jsps:

worldpayapmcomponent.jsp

worldpaycccomponent.jsp

These contain simple radio buttons that are added in the PaymentDetailsForm along with a

localised media.

At this point we have only checked to see if the components should display the apm on the front

end, for backend validation we use the: PaymentDetailsFormValidator to do the same check as the

GenericCMSAddOnComponentController (same rules as above):

PaymentDetailsFormValidator

@Component("paymentDetailsFormValidator")

public class PaymentDetailsFormValidator implements Validator {

Page 25: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 25

...

if (!errors.hasErrors() && !CREDIT_CARD_PAYMENT_METHOD.equals(form.getPaymentMethod())) {

final WorldpayAPMConfigurationModel apmConfiguration = apmConfigurationLookupService.getAPMConfigurationForCode(form.getPaymentMethod());

if (!apmAvailabilityService.isAvailable(apmConfiguration, cartService.getSessionCart())) {

errors.rejectValue(FIELD_PAYMENT_METHOD, "worldpay.paymentMethod.notAvailable", "Payment method is not available");

}

}

...

}

1.3.4 Client Side Encryption (CSE)

The AddOn can be configured to use CSE for submitting orders to Worldpay. For this, a new Page

Template has been added for desktop and mobile using a different front-end template.

template/cms-content.impex

INSERT_UPDATE

PageTemplate;$contentCV[unique=true];uid[unique=true];name;restrictedPageTypes(code);velocityTempl

ate[translator=de.hybris.platform.commerceservices.impex.impl.FileLoaderValueTranslator];active[default=false];frontendTemplateName

;;WorldpayCSEPaymentAndBillingCheckoutPageTemplate;Worldpay CSE Payment Page

Template;WorldpayPaymentPage;$jarResourceCmsCockpit/structure-

view/structure_WorldpayCSEPaymentAndBillingCheckoutPageTemplate.vm;;addon:/$addonExtensionName/pages/checkout/multi/worldpayChooseCSEPaymentDetailsPage

template/cms-content-mobile.impex

INSERT_UPDATE

PageTemplate;$contentCV[unique=true];uid[unique=true];name;restrictedPageTypes(code);active[default=

true];velocityTemplate[translator=de.hybris.platform.commerceservices.impex.impl.FileLoaderValueTranslator];frontendTemplateName

;;WorldpayMobileCSEPaymentAndBillingCheckoutPageTemplate;Worldpay Mobile CSE Payment Page

Template;WorldpayPaymentPage;;$jarResourceCmsCockpit/structure-

view/mobile/structure_WorldpayCSEPaymentAndBillingCheckoutPageTemplate.vm;addon:/$addonExtensi

onName/pages/checkout/multi/worldpayChooseCSEPaymentDetailsPage

CSE is enabled by changing the page template of the payment page as described in the end user guide. APM's will still use the redirect payment flow if CSE is enabled.

Page 26: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 26

As CSE uses the Worldpay Direct XML integration method, the AUTHORISE is handled

synchronously by Worldpay. The merchant interface can be configured to still send asynchronous

AUTHORISE notifications, but these are not required for normal operation. The rest of the notifications work in the same way as in the redirect flow.

1.3.5 Hosted Payment Pages (HPP) – B2C only

The HPP’s are available to be used in the plugin. In Desktop, there are 2 new templates to select from, iframe and Ligthbox:

template/cms-content.impex

INSERT_UPDATE

PageTemplate;$contentCV[unique=true];uid[unique=true];name;restrictedPageTypes(code);velocityTempl

ate[translator=de.hybris.platform.commerceservices.impex.impl.FileLoaderValueTranslator];active[default

=true];frontendTemplateName

;;WorldpayLightboxPaymentAndBillingCheckoutPageTemplate;Worldpay Lightbox Payment Page

Template;WorldpayPaymentPage;$jarResourceCmsCockpit/structure-

view/structure_WorldpayLightboxPaymentAndBillingCheckoutPageTemplate.vm;;addon:/$addonExtension

Name/pages/checkout/multi/worldpayChooseLightboxPaymentDetailsPage

;;WorldpayIframePaymentAndBillingCheckoutPageTemplate;Worldpay iFrame Payment Page

Template;WorldpayPaymentPage;$jarResourceCmsCockpit/structure-

view/structure_WorldpayIframePaymentAndBillingCheckoutPageTemplate.vm;;addon:/$addonExtensionN

ame/pages/checkout/multi/worldpayChooseIframePaymentDetailsPage

In Mobile there is 1 more template to select, iframe:

template/cms-content-mobile.impex

INSERT_UPDATE

PageTemplate;$contentCV[unique=true];uid[unique=true];name;restrictedPageTypes(code);active[default=

true];velocityTemplate[translator=de.hybris.platform.commerceservices.impex.impl.FileLoaderValueTranslator];frontendTemplateName

;;WorldpayMobileIframePaymentAndBillingCheckoutPageTemplate;Worldpay Mobile iFrame Payment Page

Template;WorldpayPaymentPage;;$jarResourceCmsCockpit/structure-

view/mobile/structure_WorldpayIframePaymentAndBillingCheckoutPageTemplate.vm;addon:/$addonExtensionName/pages/checkout/multi/worldpayChooseIframePaymentDetailsPage

The HPP installation needs to be enabled in the merchant configuration.

1.3.6 General configuration

The AddOn by default changes the paymentProvider of the store to Worldpay and associates the

store to a specific checkout group.

Page 27: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 27

These properties are changed with below impex template when the AddOn is installed and the system is updated (with core data for your store) or initialised:

stores/template/store.impex

$paymentProvider=Worldpay

$checkoutGroup=worldpayCheckoutGroup

# Base Store

UPDATE BaseStore;uid[unique=true];paymentProvider;checkoutFlowGroup

;$storeUid;$paymentProvider;$checkoutGroup

Extension properties

Extension Properties Description

worldpaycscock

pit CSCockpit

prefix worldpay.cscockpit.prefix should be changed in your environment

specific local.properties. This is the URL prefix supplied to the

CSCockpit HOP page (i.e. https://localhost:9002/cscockpit)

NOTE: Using the cscockpit via different urls than the one

configured will result in the return-urls from Worldpay not

working.

worldpayresponsemock

Modification

Controller Mapping

worldpayresponsemock.order.notification.endpoint should be

changed in your environment specific local.properties if you want to use the mock.

It has to match the mapping of the

com.worldpay.worldpaynotificationaddon.controllers.order.notif

ication.OrderModificationController

1.3.7 Configuring the Support Email

In the HMC, there is a toolbar action that sends the current configuration of the AddOn to Worldpay.

Page 28: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 28

Additionally it is now possible to send the support email from HAC. A new Worldpay tab with

subtab 'Support email' is added.

When selecting the 'Support Email' subtab a preview of the generated support email body will be

displayed, along with a 'Send Email' button. Click the button to send the email. Once the email is

send a message with the configured email receiver is displayed.

Page 29: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 29

The following properties should be configured in order to use this functionality:

Property Description Example

worldpay.support.email.address The address the

mail will be sent to. [email protected]

worldpay.support.email.display.name Display name for

the email client

Worldpay Plugin Support

worldpay.support.email.subject Subject for the

email

Worldpay Support for [StoreFrontName - CompanyName]

customer.support.email.address Sender's email

address

[email protected]

customer.support.email.display.name Sender's display

name

Awesome Shop123

customer.support.email.address.reply.to Email address to

send reply to

[email protected]

For this functionality to work, it is expected that the SMTP server is configured.

The support email service uses a list of appenders to build the body of the email. To add more

information to the support email, create an appender which

implements com.worldpay.support.appender.WorldpaySupportEmailAppender and add it to the list of appender.

Below is the configuration for the email service used by the AddOn.

worldpayapi-spring.xml

<alias name="defaultWorldpaySupportEmailService" alias="worldpaySupportEmailService"/>

<bean id="defaultWorldpaySupportEmailService" class="com.worldpay.support.impl.DefaultWorldpaySupportEmailService">

<property name="emailAppenders">

<list>

<ref bean="hybrisVersionAppender"/>

<ref bean="currentTimeAppender"/>

<ref bean="userDisplayNameAppender"/>

<ref bean="merchantConfigurationAppender"/>

Page 30: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 30

<ref bean="configuredFlowsAppender"/>

<ref bean="paymentTransactionAppender"/>

<ref bean="extensionListAppender"/>

<ref bean="clusterInformationAppender"/>

</list>

</property>

</bean>

To extend the list of appenders, use listMergeDirective as shown below.

Example of List Merge Directive

<bean id="myCustomAppenderListMergeDirective" depends-on="worldpaySupportEmailService" parent="listMergeDirective">

<property name="add" ref="myCustomAppender"/>

<property name="listPropertyDescriptor" value="emailAppenders" />

</bean>

1.4 Extending the AddOn

1.4.1 Cron Jobs to Process Order Modifications from Worldpay

Once an order modification is captured in the Hybris Commerce Suite, a series of Cron Job's have

been created to process the messages. These include mission critical jobs to capture responses to

move orders through the fulfilment process as well as various monitoring and housekeeping jobs

to notify Agents and Support of stuck orders or clean up processed data.

1.4.2 orderModificationProcessorJob

Each order modification from Worldpay is stored in the database. It is recommended that the job

is run every minute for it to process all the pending modifications that the system has received.

Once a modification has been processed, the corresponding order is looked up and an event is

sent to launch the associated order process. Then the order modification is marked as processed.

In case an error has occurred while processing the order modification, the modification is marked

as defective.

Configuration

Property Description

Page 31: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 31

Property Description

typeOfPaymentTransactionToProcessSet This is a Set of

de.hybris.platform.payment.enums.PaymentTransactionType

entries. Currently AUTHORIZATION, CAPTURE and CANCEL are

supported by the plugin in the fulfilment flavour and the OMS

flavour also supports SETTLED and REFUNDED. The cron job will

only process the notification types found in this Set.

This will allows developers to create fine-grained cron jobs

to target specific transaction types if they wish so. For

example, there could be a dedicated cron job which

processes AUTHORIZATION messages only (which are

usually more frequent) having it's own scheduled interval,

and a second cron job to process all other messages.

Impex

projectdataOrderModificationCronjob.impex

UPDATE

GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]

$activateTriggers=$config-worldpayOrderSync.notification.received.trigger.activate

INSERT_UPDATE

OrderModificationCronJob;code[unique=true];job(code);sessionLanguage(isoCode)[default=en];typeOfPaymentTransactionToProcessSet(code)

;orderModificationProcessorJob;orderModificationProcessorJobPerformable;;CAPTURE,AUTHORIZATION,CANCEL

INSERT_UPDATE

Trigger;cronJob(code)[unique=true];second;minute;hour;day;month;year;relative;active[default=$activateTriggers];maxAcceptableDelay

;orderModificationProcessorJob;0;1;-1;-1;-1;-1;true;;-1

cleanUpProcessedOrderModificationsCronJob

This job is in charge of cleaning up old order modifications that have been already successfully

processed. By default the job runs daily and cleans up processed order modifications older than 5

days:

Page 32: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 32

Configuration

Property Description

daysToWaitBeforeDeletion Indicates how old (in days) the Order Modification message has to be before it's cleaned up (deleted) from the system

Impex

The job and trigger is created with the following impex script:

projectdataOrderCleanUpCronjob.impex

UPDATE

GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]

$activateTriggers=$config-worldpayOrderSync.notification.cleanup.triggers.activate

INSERT_UPDATE

CleanUpProcessedOrderModificationsCronJob;code[unique=true];job(code);sessionLanguage(isoCode)[default=en];daysToWaitBeforeDeletion

;cleanUpProcessedOrderModificationsCronJob;cleanUpProcessedOrderModificationsJobPerformable;;5

INSERT_UPDATE

Trigger;cronJob(code)[unique=true];cronExpression;relative;active[default=$activateTriggers];maxAcceptab

leDelay

;cleanUpProcessedOrderModificationsCronJob;0 0 0 * * ?;true;;-1

notifyUnprocessedOrderModificationsCronJob

If order modifications records haven't been processed after a certain time (configured maximum

days limit - by default 7), a ticket per modification is created and assigned to the customer service agents for manual review. By default the job runs daily.

Configuration

Property Description

Page 33: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 33

Property Description

unprocessedTimeInDays Indicates how old (in days) the Order Modification message can be unprocessed

before a ticket is created. The message is not removed from the system,

facilitating the support resources to inspect it and understand why the message has not beed processed.

Impex

projectdataOrderNotificationCronjob.impex

UPDATE

GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]

$activateTriggers=$config-worldpayOrderSync.notification.unprocessed.trigger.activate

INSERT_UPDATE

NotifyUnprocessedOrderModificationsCronJob;code[unique=true];job(code);sessionLanguage(isoCode)[def

ault=en];unprocessedTimeInDays

;notifyUnprocessedOrderModificationsCronJob;orderModificationUnprocessedModificationsNotifierJobPerformable;;7

INSERT_UPDATE

Trigger;cronJob(code)[unique=true];cronExpression;relative;active[default=$activateTriggers];maxAcceptab

leDelay

;notifyUnprocessedOrderModificationsCronJob;0 0 0 * * ?;true;;-1

1.4.3 CronJobs to capture Payment Method Information

In any XML Redirect integration, a job must be run to capture the details of the payment method

that was used by the customer.

apmOrderTimeoutCronJob – B2C only

This job processes all the orders in PAYMENT_PENDING status that reached their timeout date set

by paymentInfoTimeoutPreparationCronJob. It sets Payment Transaction Entries of those orders in

the REVIEW status and wakes up the process. The new payment transaction entries status causes

Page 34: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 34

the Authorisation Failed Notification being sent to the customer and moving the process into the FAILED state.

Impex

projectdataAPMOrderTimeoutCronjob.impex

UPDATE

GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]

$activateTriggers=$config-worldpayAPMOrder.timeout.triggers.activate

INSERT_UPDATE CronJob;code[unique=true];job(code);sessionLanguage(isocode)[default=en]

;apmOrderTimeoutCronJob;apmOrderTimeoutJobPerformable;

INSERT_UPDATE

Trigger;cronJob(code)[unique=true];cronExpression;relative;active[default=$activateTriggers];maxAcceptab

leDelay

;apmOrderTimeoutCronJob;0 0/15 * * * ?;true;;-1

paymentInfoInquiryCronJob

This Cron Job captures details of the actual payment method used for the order (Card or APM) as

well as triggers operational workflow parameters for APM's.

Since with many APM's a series of actions need to be completed for payment to be fulfilled, if

these actions don't happen an auto-cancellation feature is necessary to ensure a properly

completed order fulfilment workflow. Each APM can provide an auto cancellation timeout value

(which is stored in minutes) for orders that haven't been processed. This job uses the timeout

configured against the APM to set a timeout date for each order found in the system

in PAYMENT_PENDING status. If no configured timeout is found for a specific APM, no timeout date will be set and therefore a default timeout (configured to 2 weeks) is used.

The job works in two steps. First, it retrieves payment transactions of pending orders without

timeout date. Next, for each payment transaction an Order Inquiry is sent to Worldpay to obtain

the payment type of the payment associated with the transaction. The Payment type is saved and

payment is converted accordingly - either to a WorldpayAPMPaymentInfo, if it is an APM, or to

a CreditCardPaymentInfo. During creation of the WorldpayAPMPaymentInfo the timeoutDate is

set if the timeout value is found in the corresponding APM configuration. The timeout date is

Page 35: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 35

calculated from the creation date of the payment transaction plus the timeout value configured for the APM.

Please contact Worldpay to obtain the recommended timeout for each APM

The job also handles paymentTransactions that haven't received any notification from Worldpay

within a given timeframe. The paymentTransactionEntries related to those paymentTransactions

will be marked as REJECTED, and the reference fulfilment process will be re-triggered to cancel the

customers order.

Configuration

Property Description

worldpay.apm.minutes.before.inquiring.timeout The amount of minutes for an APM payment

transaction to wait for a notification from

Worldpay before inquiring about auto cancel

timeout.

worldpay.APM.days.before.stop.inquiring.timeout The amount of days before rejecting

paymentTransactionEntries that have not

recieved a notification from Worldpay and

stop inquiring about the transaction.

Both properties take their default value from spring-configuration (below), but the spring-values

can be overruled by the values set in local.properties.

worldpaynotificationaddon-spring.xml

<bean id="paymentInfoInquiryJobPerformable" class="com.worldpay.cronjob.PaymentInfoInquiryJobPerformable" parent="abstractJobPerformable">

<property name="orderInquiryService" ref="orderInquiryService"/>

<property name="worldpayPaymentTransactionDao" ref="paymentTransactionDao"/>

<property name="worldpayMerchantService" ref="worldpayMerchantService"/>

<property name="configurationService" ref="configurationService"/>

<property name="paymentTransactionRejectionStrategy" ref="paymentTransactionRejectionStrategy"/>

<!-- Custom configuration -->

<property name="defaultBlanketTimeInDays" value="5"/> <property

name="defaultWaitInMinutes" value="15"/>

</bean>

Page 36: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 36

If the defaultBlanketTimeInDays is smaller (in time) than the defaultWaitInMinutes, the blanket

timeout rule won't take effect until the defaultWaitInMinutes has passed. For instance, if the

defaultBlanketTimeInDays is one day, and the defaultWaitInMinutes is 2880 (2 days), no payment transactions will be rejected before they're two days old.

Impex

projectdataPaymentInfoInquiryCronjob.impex

UPDATE

GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]

$activateTriggers=$config-worldpayPaymentInfo.timeout.preparation.triggers.activate

INSERT_UPDATE CronJob;code[unique=true];job(code);sessionLanguage(isocode)[default=en]

;paymentInfoInquiryCronJob;paymentInfoInquiryJobPerformable;

INSERT_UPDATE

Trigger;cronJob(code)[unique=true];cronExpression;relative;active[default=$activateTriggers];maxAcceptableDelay

;paymentInfoInquiryCronJob;0 0/10 * * * ?;true;;-1

1.4.4 Riskscore and fraud

The AddOn is set up to capture and persist risk scores (from Risk Management Module or

RiskGuardian) from Worldpay and display these in various business tools.

The AddOn also provides a way to change the order-flow depending on the values of the risk scores. The way this is done is to take control of the step:

1. fraudCheck in order-process.xml:

order-process.xml

<action id="fraudCheck" bean="fraudCheckOrderInternalAction">

<transition name="OK" to="sendOrderPlacedNotification"/>

<transition name="POTENTIAL" to="manualOrderCheckCSA" />

</action>

2. By re-aliasing the fraudCheckOrderInternalAction bean and configuring the providerName to reference Worldpay:

worldpayapi-spring.xml

Page 37: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 37

<bean id="fraudCheckOrderInternalAction"

class="com.worldpay.fulfilmentprocess.actions.order.WorldpayFraudCheckOrderInternalAction" parent="worldpayAbstractFraudCheckAction">

<property name="fraudService" ref="fraudService"/>

<property name="providerName" value="worldpay"/>

<property name="configurationService" ref="configurationService"/>

</bean>

3. By re-aliasing the fraudService so it contains only the worldpayFraudServiceProvider as a provider.

worldpayapi-spring.xml

<alias alias="fraudService" name="worldpayFraudService"/>

<bean id="worldpayFraudService" class="de.hybris.platform.fraud.impl.DefaultFraudService">

<property name="providers">

<list>

<ref bean="worldpayFraudServiceProvider"/>

</list>

</property>

</bean>

4. The worldpayFraudServiceProvider has a list of symptoms:

worldpayapi-spring.xml

<bean id="worldpayFraudServiceProvider" class="de.hybris.platform.fraud.impl.DefaultHybrisFraudServiceProvider">

<property name="providerName" value="worldpay"/>

<property name="symptomList">

<list>

<ref bean="worldpayRiskScoreFraudSymptom"/>

<ref bean="worldpayRiskGuardianFraudSymptom"/>

</list>

</property>

Page 38: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 38

</bean>

5. The symptoms defined are:

WorldpayRiskGuardianFraudSymptom takes care of symptoms from the

worldpayRiskGuardian system and worldpayRiskScoreFraudSymptom takes care of the

default returned risk score value.

WorldpayFraudCheckOrderInternalAction will take a configuration value that can be updated in local.properties.

worldpayapi-spring.xml

<bean id="worldpayRiskGuardianFraudSymptom" class="com.worldpay.fraud.symptoms.WorldpayRiskGuardianFraudSymptom">

<property name="symptomName" value="WorldpayRiskGuardianFraudSymptom"/>

</bean>

<bean id="worldpayRiskScoreFraudSymptom" class="com.worldpay.fraud.symptoms.WorldpayRiskScoreFraudSymptom">

<property name="symptomName" value="WorldpayRiskValueFraudSymptom" />

</bean>

6. The threshold to mark an order as fraudulent is defined as:

worldpayapi/project.properties.template

worldpayapi.fraud.scoreLimit=80

These customisations are easily configured by adding or removing symptoms to the

worldpayFraudServiceProvider, or modifying the value of the scoreLimit used

in WorldpayFraudCheckOrderInternalAction.

Manual Fraud Order Review by CS Agent

The following is the incorrect OOTB behaviour which has been fixed in the AddOn.

DefaultCsOrderraudController in cscockpit sends the CSAOrderVerified/CleanUp (proceed/reject)

event to the the wrong process: the proper definition of the order process is "order-process", the

controller is configured to send events to "placeorder" process. Hence the order process is never

Page 39: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 39

woken up. In hybris Commerce Suite 5.6, this behaviour is Out of the box and required changing the processName property to "order-process".

cscockpit-spring-widgets.xml

<property name="processName" value="placeorder"/>

DefaultOrderFraudController

private void sendProcessEvent(OrderModel orderModel, String eventName) {

Iterator var4 = orderModel.getOrderProcess().iterator();

while(var4.hasNext()) {

OrderProcessModel process = (OrderProcessModel)var4.next();

if(process.getProcessDefinitionName().equals(this.processName)) {

String eventCode = process.getCode() + "_" + eventName;

this.getBusinessProcessService().triggerEvent(eventCode);

}

}

}

Customer IP Address

Another fraud information used by Worldpay is the customer's IP address. In the redirect flow the

IP is captured by Worldpay so it does not need to be sent in the request XML. In the direct / CSE

flow, the correct customer IP needs to be sent in the request XML. As the hybris installation may

be set up behind a load balancer that transfers the customer's IP address to a header attribute and

replaces the address of the request to that of the load balancer. As the header attribute name

depends on the load balancer in place, a strategy is available to retrieve the customer IP from the

configured header:

<alias name="defaultWorldpayCustomerIpAddressStrategy" alias="worldpayCustomerIpAddressStrategy"/>

<bean id="defaultWorldpayCustomerIpAddressStrategy"

class="com.worldpay.strategy.impl.DefaultWorldpayCustomerIpAddressStrategy">

<property name="headerName" value="X-Forwarded-For"/>

<!-- Possible headers that may contain the customer IP if load balancer is

<property name="headerName" value="Proxy-Client-IP"/>

Page 40: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 40

<property name="headerName" value="WL-Proxy-Client-IP"/>

<property name="headerName" value="HTTP_CLIENT_IP"/>

<property name="headerName" value="HTTP_X_FORWARDED_FOR"/>

-->

</bean>

1.4.5 Notification commands

The AddOn is set up to accept all Worldpay notification commands, but only

processes "AUTHORISED", "CAPTURED", "REFUSED", "REFUNDED", "SETTLED" and "REFUND_WE

BFORM_ISSUED". To process updates for other messages you will need to extend the

method processOrderNotificationMessage in the class DefaultOrderNotificationService.

It is recommended to do this by adding a dependency to the worldpayapi in your own project extension and re-aliasing the orderNotificationService spring bean like so:

<alias alias="orderNotificationService" name="myOrderNotificationService"/>

<bean id="myOrderNotificationService"

class="com.myproject.core.services.impl.DefaultOrderNotificationService" parent="defaultOrderNotificationService" />

1.4.6 Cancellations

Introduction

To Void a payment transaction (reversal with credit cards) a separate void process has been

defined, to take care of cancelling orders at Worldpay. This proces s is started when the

CancelFinishedEvent is triggered. This can, among other places, be done by clicking the "Cancel

Order" button in the CS Cockpit.

The process is defined as follows:

worldpay-void-process.xml

<?xml version="1.0" encoding="utf-8"?>

<process xmlns="http://www.hybris.de/xsd/processdefinition" start="sendVoidCommand"

name="worldpay-void-process" processClass="com.worldpay.voidprocess.model.WorldpayVoidProcessModel">

<action id="sendVoidCommand" bean="worldpayCancelOrderAction">

Page 41: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 41

<transition name="OK" to="end"/>

<transition name="NOK" to="waitForManualRetry"/>

</action>

<wait id="waitForManualRetry" then="sendVoidCommand">

<event>${process.code}_VOID_PAYMENT</event>

</wait>

<end id="end" state="SUCCEEDED">Success</end>

</process>

There is only one action in this process, which will send a CancelOrRefund request to Worldpay.

Further logic can be added by customising the process.

The worldpay-void-process is started by the ImmediateCancelRequestExecutor through

the OrderCancelNotificationServiceAdapter interface, which is implemented

by WorldpayOrderCancelNotificationServiceAdapter, which publishes the CancelFinishedEvent.

The process is only triggered for complete cancellations of orders.

The bean immediateCancelRequestExecutor has been aliased

by worldpayImmediateCancelRequestExecutor in the worldpayfulfilment extension:

worldpayfulfilment-spring.xml

<alias name="worldpayImmediateCancelRequestExecutor" alias="immediateCancelRequestExecutor"/>

<bean id="worldpayImmediateCancelRequestExecutor"

class="de.hybris.platform.ordercancel.impl.executors.ImmediateCancelRequestExecutor"

scope="prototype">

<property name="modelService" ref="modelService"/>

<property name="orderCancelRecordsHandler" ref="orderCancelRecordsHandler"/>

<property name="completeCancelStatusChangeStrategy" ref="setCancellledStrategy"/>

<property name="notificationServiceAdapter" ref="worldpayOrderCancelNotificationServiceAdapter"/>

</bean>

Please note that only a "notificationServiceAdapter" is provided by the AddOn. From Hybris

documentation in https://wiki.hybris.com/display/release5/Order+Cancel+Service+-+Technical+Description:

Page 42: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 42

OrderCancelPaymentServiceAdapter

This interface is used to recalculate an order after the cancel operation has been finished. It is

used by classes: ImmediateCancelRequestExecutor, WarehouseResponseExecutor. Order

Cancel Service does not provide a default implementation of this interface. Users should

supply their own implementation and plug it in using Spring configuration for the

aforementioned classes. If not provided, orders are not automatically recalculated by Order

Cancel Service after cancel operation is finished (order recalculation can be then performed

externally to Order Cancel Service)

OrderCancelWarehouseAdapter

This interface is used to forward cancel requests to a warehouse. It is used by

class: WarehouseProcessingCancelRequestExecutor. A mock implementation

(DefaultWarehouseAdapterMock) is provided by default. Users should supply their own

implementation and plug it in using Spring configuration for the aforementioned class.

Cancellation of captured orders

Hybris does not allow cancellation of captured orders. In order to completely avoid wrongful

cancellations of captured orders, the worldpayOrderCancelDenialStrategy has been added to the

candelDenialStrategies list of defaultOrderCancelService:

worldpaycscockpit-spring.xml

<bean id="worldpayOrderCancelDenialStrategy" class="com.worldpay.ordercancel.impl.denialstrategies.WorldpayOrderCancelDenialStrategy">

<property name="reason">

<bean class="de.hybris.platform.ordercancel.DefaultOrderCancelDenialReason">

<property name="code" value="4"/>

<property name="description" value="Order cannot be cancelled as there are captured transaction entries."/>

</bean>

</property>

</bean>

<bean id="worldpayCancelOrderServiceListMergeDirective" depends-on="defaultOrderCancelService"

parent="listMergeDirective">

<property name="add" ref="worldpayOrderCancelDenialStrategy"/>

Page 43: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 43

<property name="listPropertyDescriptor" value="cancelDenialStrategies" />

</bean>

Cancellation of APM's – B2C only

As APM's are auto-captured in Worldpay, it is not possible to cancel any order containing an APM

payment transaction. This consequently means that out of the box with our AddOn, orders won't

be cancellable until the authorised notification has been processed. This is because the system

won't have information about the payment type before this time.

This has been implemented by adding the worldpayApmOrderCancelDenialStrategy to the

candelDenialStrategies list of defaultOrderCancelService:

worldpaycscockpit-spring.xml

<bean id="worldpayApmOrderCancelDenialStrategy" class="com.worldpay.ordercancel.impl.denialstrategies.WorldpayApmOrderCancelDenialStrategy">

<property name="reason">

<bean class="de.hybris.platform.ordercancel.DefaultOrderCancelDenialReason">

<property name="code" value="5"/>

<property name="description" value="Order cannot be cancelled as payment was made through an

APM or is still unknown."/>

</bean>

</property>

</bean>

<bean id="worldpayApmCancelOrderServiceListMergeDirective" depends-on="defaultOrderCancelService" parent="listMergeDirective">

<property name="add" ref="worldpayApmOrderCancelDenialStrategy"/>

<property name="listPropertyDescriptor" value="cancelDenialStrategies" />

</bean>

This can of course be changed on project, but a process has to be setup to handle void of

payments in the event of cancellations happening. In the event of the customer using an APM, you

want to be sure that the customer is aware the order is cancelled as they may already have

actioned payment.

Backoffice support

The AddOn customises the backoffice customersupport perspective by including the action:

Page 44: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 44

worldpaycancelorderaction o Overrides the hybris out of the box cancelorderaction by offering customised

business rules.

1.4.7 Refunds

The AddOn provides refunds functionality integrated with a customised return-process

Backoffice support

The AddOn customises the backoffice customersupport perspective by including the action:

worldpaycreatereturnrequestaction Overrides the hybris out of the box create return request action by offering different

business rules regarding return requests for orders paid with: Card: A return request can only be created when the order transaction contains a

non-pending CAPTURE transaction entry. APM: A return request can only be created if the APM supports automatic refunds

and the order transaction contains a non-pending SETTLED transaction entry.

1.4.8 Checkout Flow

Checkout flows are used by the Hybris Accelerator to control the screen web flow.

The default checkout group holds the information about different checkout steps, validation

results and progress bar configuration.

The new checkout flows defined in worldpayaddon provide customised payment, HOP and

summary steps . For B2C (adaptive and responsive) and B2B.The worldpayB2CCheckoutGroup and

worldpayB2CResponsiveCheckoutGroup are defined in b2c-multi-step-checkout-spring.xml and

worldpayB2BCheckoutGroup is defined in b2b-multi-step-checkout-spring.xml. The checkout

process can be adapted on project-basis requirements by modifying the flow defined in the beans

mentioned. The step definitions, validators, validation results and redirects in the checkout flow

can also be found in the corresponding configuration files.

Storefronts are generally mapped with a checkout group, based on checkout steps and flows they

require. By default, storefronts generated from the template extension will be using

defaultCheckoutGroup. Whenever a new checkout flow group is created, it is required to map it to

desired base stores. This can be achieved by running the impex script below manually or by a system update with project data for selected basestores: stores/template/store.impex

worldpayaddon/resources/worldpayaddon/import/stores/apparel-

de/store.impex$checkoutGroup=worldpayCheckoutGroup

$worldpayCheckoutGroup=worldpayB2CCheckoutGroup

Page 45: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 45

$worldpayResponsiveCheckoutGroup=worldpayB2CResponsiveCheckoutGroup

# Base Store

UPDATE BaseStore;uid[unique=true];checkoutFlowGroup

;$storeUid;$worldpayCheckoutGroup

#% if:

"responsive".equalsIgnoreCase(Config.getParameter("commerceservices.defa

ult.desktop.ui.experience"));

UPDATE BaseStore;uid[unique=true];checkoutFlowGroup

;$storeUid;$worldpayResponsiveCheckoutGroup

1.4.9 Customising the Worldpay AddOn

Order Code generation strategy

To use a different order code strategy you can simply re-alias the

worldpayGenerateMerchantTransactionCodeStrategy bean, below is the default:

worlpayapi-spring.xml

<alias name="defaultWorldpayGenerateMerchantTransactionCodeStrategy" alias="worldpayGenerateMerchantTransactionCodeStrategy" />

<bean id="defaultWorldpayGenerateMerchantTransactionCodeStrategy"

class="com.worldpay.core.services.strategies.impl.WorldPayGenerateMerchantTransactionCodeStrategy"/

>

The customisation is not part of the supplied AddOn. If any customisation is required by the

integrator, it can be achieved by extending the default hybris implementation of

the PaymentService, in de.hybris.platform.payment.impl.DefaultPaymentServiceImpl and the

method getNewPaymentTransactionEntryCode.

Authenticated Shopper Id strategy

The AuthenticatedShopperId is a required field by Worldpay when using and creating tokens. The

AddOn supplies the worldpayAuthenticatedShopperIdStrategy for this purpose, and by default the

CustomerId is used. If the CustomerId is not set, the originalUID is used instead.

To use a different authenticated shopper Id strategy you can simply re-alias the worldpayAuthenticatedShopperIdStrategy bean, below is the default:

Page 46: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Implementation Guide 46

worldpayapi-spring.xml

<alias name="defaultWorldpayAuthenticatedShopperIdStrategy" alias="worldpayAuthenticatedShopperIdStrategy"/>

<bean id="defaultWorldpayAuthenticatedShopperIdStrategy" class="com.worldpay.strategy.impl.DefaultWorldpayAuthenticatedShopperIdUsingCustomerIdStrategy"/>

Token Event Reference Creation strategy

To use a different token event reference creation strategy you can simply re-alias the

worldpayTokenEventReferenceCreationStrategy bean, below is the default:

worldpayapi-spring.xml

<alias name="defaultWorldpayTokenEventReferenceCreationStrategy" alias="worldpayTokenEventReferenceCreationStrategy"/>

<bean id="defaultWorldpayTokenEventReferenceCreationStrategy" class="com.worldpay.service.payment.impl.DefaultWorldpayTokenEventReferenceCreationStrategy">

<property name="cartService" ref="cartService"/>

</bean>

1.5 Project Customisation Points of Consideration

The Worldpay AddOn is an Accelerator for your project, however its important to understand

exactly what is delivered for your project scoping.

Supported User Experience : Desktop, Mobile as Adaptive and Responsive Storefronts are

supported.

Supported Payment Flows : HPP (Iframe, Lightbox and Full page redirect), CSE and saved card using tokenisation.

Supported Checkout Flows : Registered / Guest

Worldpay order notification messages persisted and processed via Cron Jobs

Accelerator : Hybris B2C Accelerator 6.2, Hybris B2C Responsive Accelerator 6.2, Hybris B2B

Accelerator 6.2

Fraud : Data Capture and Manual Fraud workflow

Page 47: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 47

Database : hSQL / MySQL 5.7 tested

1.6 Supported environments

The AddOn has been developed and tested with the following versions and databases:

Hybris 6.2

Java 1.8

MySQL

HSQL

Browsers:

Firefox

Chrome

Internet Explorer 10, 11

Technical Implementation Guide

All Worldpay Payment Commands are executed asynchronously and therefore will respond

initially in a pending state. Once the transaction has completed, Worldpay pushes notifications via

the Order Notifier back to a configured endpoint on a Hybris Commerce Suite node. The endpoint

URL is configured in the merchant account in the Worldpay Merchant Account Interface Tool. The

Endpoint (exposed by installing the worldpaynotificationaddon functionality) serialises these notifications as WorldpayOrderModification records into the Hybris Commerce Suite database.

2 High Level Architecture

The following diagram outlines at a high level, the system components (Worldpay, Issuing Bank

and Hybris) together with the high-level interactions that fulfil the functionality delivered by the

Worldly AddOn.

Page 48: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 48

2.1 Hybris Commerce Suite Extensions

The Worldpay Hybris AddOn is shipped in 4 separate modules ext-worldpay, ext-

worldpayfulfilment, ext-worldpayoms and ext-worldpaytest.

The Worldpay AddOn extends the Hybris Commerce Suite providing integration with Worldpay

Hosted Order Page, Payment API, Notification, Fraud, CSE and tokenisation functionalities.

2.1.1 Connector

worldpayapi

Worldpay API Gateway Plugin point for the Hybris Commerce Suite Payment Service.

Related Documentation

Payment Extension

2.1.2 Front end

worldpayb2caddon

AddOn for the Hybris B2C Accelerator. This adds a new Checkout Flow that is optimised for Worldpay HPP, CSE/Direct both supporting tokenisation functionality.

Related Documentation

Page 49: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 49

Configurable Checkout AddOn Concept

worldpayb2baddon

AddOn for the hybris B2B Accelerator. This adds a new Checkout Flow that is optimised for Worldpay

CSE/Direct supporting tokenisation functionality.

Related Documentation

Configurable Checkout AddOn Concept B2B Checkout and Order Process

worldpayaddoncommons

Commons extension for B2C and B2B AddOn's.

worldpaycscockpit

Adds Worldpay Hosted Order Page and usage of Tokenisation functionality to the Hybris Customer Service Cockpit.

Related Documentation

Customer Service Module

worldpaysampledataaddon

AddOn that adds sample data on the electronics and apparel sites. Contains several APM

configurations, adds some countries, currencies and delivery zones. Also adds CMS components to

the payment and billing page for the electronics and apparel content catalogs enabling the

different APMs.

The data provided here could serve as an example of how to import different APMs and how to

configure the different components in the payment and billing page:

projectdata_worldpayAPMs.impex

INSERT_UPDATE

WorldpayAPMConfiguration;code[unique=true];name[lang=en];description[lang=en];currencies(isocode);countries(isocode);currencyRanges(currency(isocode),min,max)

;SOFORT-SSL;SOFORT;Sofort;EUR;AT,BE,FR,DE;EUR:1:2000

Page 50: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 50

;CHINAUNIONPAY-SSL;China Union Pay;China Union Pay;GBP,EUR,USD

;ALIPAY-SSL;Alipay;Alipay;GBP,EUR,USD,SGD;CN;GBP:1:5000,EUR:1:6000,USD:1:8000,SGD:1:10000

worldpayfulfilment

Adds Worldpay related functionalities and customisations to payment integrations for the Hybris

Accelerator Order Fulfilment Process.

Related Documentation

yacceleratorfulfilmentprocess Extension

worldpayoms

Adds Worldpay related functionalities and customisations to payment integrations for the hybris Order Management System.

Related Documentation

Order Management for SAP Hybris Commerce

worldpayaddonbackoffice

Extension that includes configuration files so items created in the AddOn are organised and visible in the backoffice hybris application.

Next Generation Cockpit Framework

2.1.3 Notification

worldpaynotificationaddon

Simple Accelerator Storefront AddOn providing an HTTP endpoint to receive and process

Worldpay Order Notification messages.

Related Documentation

AddOn Concept

2.1.4 Testing

worldpayresponsemock

The AddOn contains an extension that offers two functionalities:Direct/redirect responses mock

Page 51: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 51

Acting as the Gateway itself and replying to Direct and Redirect requests. The mock replies with pre-fabricated happy-flow responses to authorize and capture requests.

To enable the mock, set the following properties:

worldpayapi/project.properties

worldpay.config.environment=MOCK

worldpay.config.endpoint.MOCK=www.example.com/worldpayresponsemock/mock

Order notification mock

The Worldpay Order Notification System requires the Hybris Commerce Suite to expose an

internet facing Webservice endpoint. To facilitate development and test automation, the AddOn

ships a test harness to mockup notification system responses in development environments. This

is an optional installed Hybris extension with a simple Web front-end that can be used to simulate

order notifications updates from Worldpay. Write in the Order Code (requestId, found in the hMC

or in the logs) and send the response you wish generated.

2.2 AddOn Integration with Hybris Payment Module

The Worldpay extension plugs directly into the Hybris Payment Module by providing Worldpay

connectivity to authorization, capture, refund, void and subscription commands. The Worldpay

implementations of these commands then use the Core Connector Library to communicate with

the Worldpay Service Gateway.

The following class diagram shows the points in which Worldpay plugs into the Hybris Payment Service.

Page 52: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 52

It is important to note, with the Worldpay integration, confirmation of the result of executing the

command comes asynchronously via Worldpay posting to the Order Notification AddOn.

Therefore Commands will return Payment Transaction Entries with a pending status.

Page 53: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 53

2.2.1 New B2C Accelerator Checkout Flow

Facades & Services

The Accelerator Service Layer and Facades have been extended to support functionality including XML Redirect Hosted Order Payment, Pay As Order and a XML Direct using Client-side encryption.

HOP - Redirect Flow

The following diagram depicts the modifications made by the Worldpay B2C Accelerator AddOn which adds a Worldpay compatible Checkout Flow to replace the standard B2C Accelerator flow.

Page 54: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 54

Payment & Billing Address Page

This page has been customised to:

Display a list of available payment methods (such as Cards and Alternative Payment Methods) which are CMS driven.

Display Terms & Conditions checkbox which is a required field in order to proceed the Hosted Order Page.

JavaScript library added to handle the User Experience.

Order Summary Page

This page has been removed from the vanilla Accelerator HOP flow. This is because the

authorisation happens on the Worldpay Hosted Order Page and there is no need to ask the User

to place the order. The order is placed at the end of the HOP page callback.

Order Confirmation Page

Small customisation to hide Payment Details in the event of the Notification not yet being

received. Once the application has received the notification, it will show either the payment

details about the credit/debit card used (obfuscated) or the Alternative Payment Method used to place the order.

Tokenisation

When the customer chooses to save their card details in the Payment and Billing page, the request

sent to Worldpay contains an instruction to tokenise the card. The corresponding authorisation

order modification message will contain the token information.

Client Side Encryption Flow

The following diagram shows how the Client Side Encryption (CSE) payment flow has been

implemented in the AddOn. This flow is only available for credit/debit card payments.

Page 55: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 55

The only difference from the redirect-flow is that the user is no longer taken to the Hosted Order Page for filling in their card details. Card details are instead encrypted on the customer's browser

and the encrypted payload is submitted to the Merchants Web storefront by a form post on the Card Details page. This encrypted data is then passed on to Worldpay using Direct Xml integration.

Tokenisation

When the customer chooses to save their card details in the Card Details page, the direct reques t

sent to Worldpay contains an instruction to tokenise the card. The direct response will contain the token information. The AddOn will store this information in the payment info associated to the

order.

The response from Worldpay may contain a tokenEvent with the value "NEW" or "MATCH". NEW

means that is a new card tokenised and stored by Worldpay, whereas MATCH means that the card

has already been tokenised and the customer is not using an already saved card. In this case, the

AddOn will look for an already tokenised and saved card associated to the customer and will

attach the found one to the order and payment transaction. If there is no such payment info

associated to the customer, a new one with the token information will be created.

Notifications

All Worldpay Payment Commands are executed asynchronously and therefore will respond

initially in a pending state. Once the transaction has completed, Worldpay pushes notifications via

the Order Notifier back to a configured endpoint on a Hybris Commerce Suite node. The endpoint

URL is configured in the merchant account in the Worldpay Merchant Account Interface Tool. The

Endpoint (exposed by installing the worldpaynotificationaddon functionality) serialises these

notifications as WorldpayOrderMofication records into the Hybris Commerce Suite database.

Tokenisation

When the application receives the notification with the token information in the Redirect Flow, the AddOn will store this information in the payment info associated to the order.

The response from Worldpay may contain a tokenEvent with the value "NEW" or "MATCH". NEW

means that is a new card tokenised and stored by Worldpay, whereas MATCH means that the card

has already been tokenised and the customer is not using an already saved card. In this case, the

AddOn will look for an already tokenised and saved card associated to the customer and will

attach the found one to the order and payment transaction. If there is no such payment info

associated to the customer, a new one with the token information will be created.

To illustrate the flow of a typical payment capture request for a credit/debit card payment use-

case from Hybris Commerce Suite to Worldpay and then back into Hybris Commerce Suite, the following diagram is shown:

Page 56: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 56

Page 57: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 57

To illustrate the flow of a typical payment capture request for an Alternative Payment

Method (APM) payment use-case from Hybris to Worldpay and then back into Hybris, the

following diagram is shown:

Page 58: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 58

Page 59: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 59

Notification States

The following state diagram describes the states, transitions and possible attribute values of a WorldpayOrderModification record in the Hybris Commerce Suite database.

Notification Cleanup

WorldpayOrderModification's can build up over time, therefore two types of cleanup Cron Job's

have been provided with the AddOn.

Cleanup of processed notifications o A scheduled Cron Job will retrieve the Modification records which have been processed

after a certain amount of time (configurable) and remove them from the system. Cleanup of unprocessed notifications

o A scheduled Cron Job will retrieve Modification records which have been sitting unprocessed for a certain amount of time (configurable) and raise a Ticket for each of them.

Order Fulfilment Process

To help accelerator development of best practice payment fulfilment workflows, reference Order

Fulfilment Processes have been supplied with the AddOn. Depending on whether you use Hybris

Order Management System or the Accelerator Fulfilment Process you can add the worldpayoms or the worldpayfulfilment extension into your installation.

Page 60: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 60

When an order is placed in the Hybris Commerce Suite, it is sent to the process engine for

execution by the order fulfilment process. There, the order is processed by a number of actions

each having a different purpose. When all the actions have been executed, the order reaches its final state (be it error or success).

Given the asynchronous nature of Worldpay Order Modification messages, a number of WAIT

states have been added to the reference process. Since every payment transaction entry is

created in a pending state (exception for APM's), the WAIT will pause the fulfilment process until

the confirmation of the said payment transaction has been confirmed (or denied). There is one

WAIT for every Order Modification message we handle in the AddOn (AUTHORIZATION and

CAPTURE). When the AUTHORIZATION message has been processed the Order Fulfilment

Process continues until the takePayment step.

When an Order Modification message is received from Worldpay, the application persists the

Modification message in the database and returns an acknowledgement (OK) response to the

Order Notifier. A Cron Job (Order Modification Processor Job) is responsible to go through the

unprocessed Order Modifications and process them. Different type of messages require different

processing but for all of them, once processed, an event is triggered which the WAIT is waiting for.

Once the WAIT receives the event, the Order Fulfilment process continues.

In the special case of APM, the order process will wait for the CAPTURE modification message,

when it reaches the application, the transaction entry is created in a non-pending state. The order

process will not issue a CAPTURE command to Worldpay when the payment was made through an APM.

The following diagrams show the parts of the Hybris Order Process where the WAIT states have

been added:

Page 61: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 61

Every order for which the authorisation notification has not been received from Worldpay will

have the PAYMENT_PENDING status set and will stay in the waitFor_AUTHORIZATION wait state

until such notification has been received. Depending on the outcome of the notification, the order

processing will continue (authorisation successful) or will fail (authorisation not successful).

Return process

There is a customised return-process available if the chosen AddOn installation contains the OMS

functionality. The modifications applied to this return-process adds a new waiting step for the REFUND notification.

worldpayoms/resources/worldpayoms/process/return-process.xml

Page 62: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 62

(...)

<action id="captureRefundAction" bean="captureRefundAction">

<transition name="OK" to="waitFor_REFUNDED"/>

<transition name="NOK" to="waitForFailCaptureAction"/>

</action>

<!-- New WAIT to be kicked off when the transaction is Refunded by worldpay -->

<wait id="waitFor_REFUNDED" then="successCaptureAction" prependProcessCode="false">

<event>${process.code}_REFUND_FOLLOW_ON</event>

</wait>

(...)

The action captureRefundAction is also customised:

worldpayoms-spring.xml

<alias name="worldpayCaptureRefundAction" alias="captureRefundAction"/>

<bean name="worldpayCaptureRefundAction"

class="com.worldpay.worldpayoms.fulfilmentprocess.actions.order.WorldpayCaptureRefundAction" parent="abstractAction">

<property name="paymentService" ref="paymentService"/>

<property name="refundAmountCalculationService" ref="refundAmountCalculationService"/>

</bean>

2.3 Order Cancellation

The Worldpay AddOn enables the Call Centre Agents to cancel orders. Cancelling an order in

Hybris sends a CANCEL request to Worldpay to reverse ring fenced funds on the customers

payment method.

If the order was paid through an APM, or the payment method has not yet been communicated by

the Worldpay Notification System, the order cannot be cancelled with the out of the box handling

of the AddOn. If the Hybris installation is customised to handle multiple payments for the same

order and one of these is an APM, the order will not be cancellable. This functionality can of

course be changed on project once business rules have been realised.

In case of fraud review, the "Reject" action in the CSCockpit will place the order in a

WaitForCleanUp state. By default hybris cancels the order through the

Page 63: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > Technical Implementation Guide 63

cleanUpFraudOrderCronJob triggering the "VoidCommand" action, which is customized to send a CANCEL request to Worldpay.

Risk Guardian

Risk Guardian is an advanced fraud detection tool that can be activated on a Production Worldpay

Merchant Account. Extra fraud score information is returned with the Authorisation Response which is then captured against the Payment Transaction.

Out of the box the information is captured and displayed (in Customer Service tools) and orders

with fraud scores greater than a configured threshold (project.properties) are held for review.

2.4 Extended Types

The Worldpay AddOn extends the Hybris Commerce Suite data model in a few area's

(predominantly payment).

The main customisations are to introduce the concept of Pending Payment transactions, Fraud

Report information and to support a more generic Payment type accommodating Worldpay's support for 200+ Alternative Payment Methods.

Page 64: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 64

2.5 Supported Environments

Third party compatibility

2.6 Limitations

The Worldpay Payment Service API has different field length restrictions to the Hybris Accelerator

/ Commerce Suite. Email for example has a maximum length of 30 characters but Hybris accepts

255. The AddOn does not add any extra logic to check the length of these fields and this is

expected to be customized on a project-by-project basis.

2.7 Languages

The provided AddOn only provides localization in English. The translations for other languages can

be added by the integrator in the corresponding properties files on a project basis.

End User Guide

3 Introduction

This guide covers the possible customisations that can be applied to a running system with the

Worldpay Hybris Commerce Suite AddOn.

How to configure Alternative Payment Method's (APM's) How to configure the payment flow.

The guide assumes the reader already has familiarity with Hybris business tools which

predominantly are the Hybris Management Console (hMC) and Hybris WCMS Cockpit.

3.1 Alternative Payment Methods Configuration

3.1.1 Configuration using hMC

The available APMs in the system can be configured using the hMC. As shown on the image below,

after logging in, the user can open the "Worldpay" group and click on the "Alternative Payment

Method" section.

The section will allow users to search, edit and create new APM configuration entries.

Page 65: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 65

Configuration Attributes

Attribute Required Description Notes

code Yes This is the APM code which

matches Worldpay APM codes (i.e. SOFORT-SSL)

See

http://support.worldpay.com/supp

ort/bg/xml/kb/3dsecure/rlt213.ht

m for Worldpay payment method codes

name Yes This is the localised APM

name. The property will be

used on the order

confirmation / history page as well as in the CS Cockpit

description No Localised APM description. Currently a content placeholder

allowing projects to describe the APM.

autoCancelPendingTi

meoutInMinutes

Yes Timeout in minutes before

the order is auto-cancelled.

If Worldpay Authorise

notification is not received

within this time interval, the order will be cancelled.

This is likely to happen because the

user has selected a delayed

payment method which required

further user action and the action

has not been take on time.

Default value: 2880 minutes (2 days) countries No Set of delivery countries for

which the APM is available.

See APM Availability Rules

currencies No Set of currencies for which

the APM is available See APM Availability Rules

Page 66: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 66

Attribute Required Description Notes

currencyRanges No Set of currency ranges for

which the APM is available

capturing the minimum and

maximum order values supported by the APM

See APM Availability Rules

APM Availability Rules

The configuration properties such as countries, currencies, currencyRanges and bank define whether an APM can be used or not as payment method.

There are four rules which all have to be true in order to have an APM available to use for payment.

Country Rule

This rule inspects the country of the shipping address and evaluates the rules. The rules are

described as follows:

Countries Set Shipping Country Result

Empty N/A TRUE

Not empty Not in the Countries Set FALSE

Not empty In the Countries Set TRUE

Currency Rule

This rule inspects the Cart's currency and evaluates the rule. The rules are described as follows:

Currencies Set Cart's Currency Result

Empty N/A TRUE

Not empty Not in the Currencies Set FALSE

Not empty In the Currencies Set TRUE

Currency Ranges Rule

This rule inspects the Cart's total and evaluates the rule. The rules are described as follows:

Page 67: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 67

Currency Range

Set Cart's Currency

Currency Range

Boundaries Cart's Total Result

Empty N/A N/A N/A TRUE

Not empty Not in the Currency Range

Set

N/A N/A TRUE

Not empty In the Currency Range Set No Min, No Max N/A TRUE

Not empty In the Currency Range Set Min and Max < Min OR >Max FALSE

Not empty In the Currency Range Set Min and Max >= Min AND

<=Max TRUE

Bank Transfer Rule

This rule inspects the APM's bank configuration and evaluates the rule. The rules are described as

follows:

APM's Bank Indicator Bank Configuration Set Result

False Empty FALSE

False Contains active banks FALSE

True Empty FALSE

True Does not contain active banks FALSE

True Contains active banks TRUE

3.1.2 Adding Payment Method Buttons using the Hybris WCMS Cockpit

To provide direct links to APM's on your Hybris "Billing & Payments Page", you can use the Hybris

WCMS Cockpit to add buttons for your preferred payment types.

Using the Hybris WCMS provides the flexibility for you to promote different APM's for different

Storefront's (i.e. different countries or brands).

APM buttons will also not render 'Available', if currency, delivery or order threshold restrictions configured against the APM apply.

Additionally you can take advantage of Hybris Personalisation rules to hide or show APM's

according to other personalisation rules such as customer segmentation.

Page 68: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 68

Step by Step Adding a new APM Button

Find the CMS Page named Worldpay Payment and Billing Checkout Page in the Website view of the WCMS Cockpit.

Unlock the Payment Buttons Slot and Click the Add Component Symbol ( + )

Page 69: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 69

In the New Item Wizard choose the Worldpay APM Component

If the APM has been pre-configured you can pre-select by typing in the APM Name or using the Search Wizard ( [ ... ] )

Page 70: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 70

Alternatively you can create an APM inline in the WCMS Cockpit. This is essentially an alternative approach to using the hMC.

Page 71: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 71

Back on the APM Component, you should can also configure the icon that will appear on the payment page

It is possible to configure different icons for different languages

Page 72: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 72

Pay By Card

There is also a Worldpay CC Component to enable you to add a Pay By Card button and set the image to represent credit cards.

Live Edit AddOn Support

If you have the liveeditaddon installed you can also perform all the above operations direct on the payment page in Quick Edit mode

Page 73: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 73

3.2 Configuring the payment flow

To select the payment flow to be used for checkout, it is only necessary to change the page

template of the "Worldpay Payment And Billing Checkout Page" and "Worldpay Mobile Payment Page" for the desired catalogues.

To configure the flows, find the CMS Page named Worldpay Payment and Billing Checkout Page in the Website view of the WCMS Cockpit.

Page 74: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 74

Click the edit button (pencil icon) of the page and then the three dots next to the Page Template.

Page 75: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 75

This will open up an editorArea where it is possible to select the desired template. The table below

shows the uid's of the templates related to the Worldpay AddOn.

Template uid Flow

WorldpayPaymentAndBillingCheckoutPageTemplate Hosted Order Page (redirect)

WorldpayCSEPaymentAndBillingCheckoutPageTemplate Client Side Encryption (direct xml)

WorldpayIframePaymentAndBillingCheckoutPageTemplate iframe (redirect)

WorldpayLightboxPaymentAndBillingCheckoutPageTemplate lightbox (redirect)

3.2.1 Enabling debug mode for development

The property "debug" in the menu "Administration" allows the developers to see extra information when integrating the Lightbox or Iframe. By default, the value is false.

Page 76: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 76

3.2.2 Specific properties for Lightbox

The following properties allow the CMS Agent to configure the look and feel for the Lightbox:

Property name Effect Value format Default

lightboxMaskOpacity The custom opacity (%) of the lightbox. Possible

values: 0-

100

80

lightboxMaskColor The custom colour (hex value) for the Close button. Hex colour #000023

accesibility Controls user access to content outside of the

lightbox. When set to true, the user can access

content in the lightbox only. Access to the parent

webpage is prevented.

True/False false

3.3 Cron Jobs

Multiple Cron Jobs are in place to handle payment fulfilment workflows and to perform

housekeeping operations :

Cronjob Recommended

Trigger Description

HMC

configuration

local.properties/

HAC configuration

Page 77: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 77

Cronjob Recommended Trigger

Description HMC configuration

local.properties/

HAC

configuration

orderModificationProcessorJob

Every minute Processes incoming

order notifications

from Worldpay. When

Order Notifications are

received by the

worldpayordernotificat

ion endpoint, they are

stored in the hybris

Commerce Suite

database until this job

picks them up. If a

modification is

successfully processed,

it is marked as

processed. The job by

default picks up

AUTHORISATION,

CAPTURE and CANCEL

notifications which are

the notification

supported out of the

box by the AddOn.

typeOfPayment

TransactionToProcessSet

cleanUpProcessedOr

derModificationsCronJob

Daily Cleans up successfully

processed order

modifications. The

amount of days to wait

before a modification is

cleaned up is configurable

on the job (default is 5 days).

daysToWaitBeforeDeletion

notifyUnprocessedO

rderModificationsCronJob

Daily Creates customer service

tickets for order

modifications that have

not been processed for a

configurable amount of days (defaults to 7 days).

unprocessedTim

eInDays

Page 78: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 78

Cronjob Recommended Trigger

Description HMC configuration

local.properties/

HAC

configuration

apmOrderTimeoutCronJob

Every 15 minutes

Finds orders where an

APM has been used and

no notification has been

received (typically

because customers have

not completed payment)

and queues for cancellation.

Time-out

specified on each APM.

paymentInfoInquiry

CronJob Every 10

minutes Inquires about the

payment method used

for a transaction if no

notification has been

received for a

configurable amount of

minutes (defaults to 15).

Also cancels transactions

where the payment

method is still unknown

after a configurable

amount of days (defaults to 5).

worldpay.apm.mi

nutes.before.inquiring.timeout

worldpay.APM.d

ays.before.stop.inquiring.timeout

3.4 Order Modifications

Order notifications received from Worldpay are Serialized as a JSON-string on the type Worldpay Order Modification.

Field Description

Processed Indicates whether the notification has been processed by the

orderModificationProcessorJob. Unsetting this flag forces the transaction to be re-processed.

Notified Indicates if a ticket was created relating to this order notification.

Defective Will be set to "true" if an error occurred in any of the steps/jobs for this notification.

Defective

reason

Specifies the reason for the notification being marked as defective

Page 79: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 79

Field Description

Defective count

The amount of total order modifications received with the same defective reason. When an

order modification is processed as defective, previous defective records with the same

defective reason are removed.

<action id="captureRefundAction" bean="captureRefundAction">

<transition name="OK" to="waitFor_REFUNDED"/>

<transition name="NOK" to="waitForFailCaptureAction"/>

</action>

<!-- New WAIT to be kicked off when the transaction is Refunded by worldpay -->

<wait id="waitFor_REFUNDED" then="successCaptureAction" prependProcessCode="false">

<event>${process.code}_REFUND_FOLLOW_ON</event>

</wait>

Page 80: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 80

FAQ / trouble shooting

To gain the best and easiest knowledge and understanding of the workings of the plugin, we

recommend installing it on a fresh install of Hybris with only the b2caccelerator. This can be done

easily by using one of the recipes provided with the plugin.

3.5 Checklist

1. Carefully read through all the documentation supplied with the plugin. 2. Ensure the version of the plugin is corresponding to your hybris version. 3. Carefully follow the implementation guide and verify that the desired functionalities are installed

correctly. 4. Follow the step by step guide below to verify, that the merchant configurations in hybris

(merchants.xml) matches the configuration in the Worldpay merchant interface. 1. To check your configured merchants:

1. Go to the Hybris Administration Console (HAC) 2. Go to Console → Scripting Languages 3. Execute statements of the pattern:

"worldpayMerchantConfiguration.[channel].[property]" where: 1. [channel] can be: "web", "mobile" or "customerService" 2. [property] can be "code", "password", "macValidation", "macSecret",

"csePublicKey", "installationId", "statementNarrative" or "orderContent"

Page 81: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 81

5. Ensure that the communication with Worldpay (including receiving order modifications) is not in any way blocked or modified by your local infrastructure.

1. Be mindful that your hybris nodes have to be able to reach the Worldpay test or production system.

2. The node which has the worldpaynotificationaddon installed has to be reachable from the Worldpay test or production system.

3.6 Raising a request

When raising a support request, please follow the steps below.

1. Sending the support email to Worldpay. 1. Set up the support email functionality as described in the Implementation guide - configure

the support email. 2. Click the Worldpay logo in the HMC as shown below.

Page 82: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 82

2. Providing a detailed description of the error you're getting

1. Include the whole stacktrace if available. 2. Include the full log of the communication with Worldpay (by default outgoing and incoming

messages are printed to the tomcat log in ${HYBRIS_LOG_DIR}/tomcat/console*) 3. Include screenshots of the error (of the whole browser - including the address-field). 4. Include the hybris support zip. The zip can be obtained by following the steps below

1. Go to the hybris Administration Console (HAC) 2. Go to Platform → Support 3. Click "Select all" and download the zip.

Page 83: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 83

B2B Technical Implementation Guide

3.7 Reader's guide

This technical implementation guide will cover the use of Worldpay as a payment provider in a B2B context.

3.7.1 B2B Technical Implementation Guide

The Worldpay B2B AddOn supports a payment scheme using Worldpay client side encryption (CSE) and

tokenizing of cards.

3.7.2 New B2B Accelerator Checkout Flow

The Worldpay B2B AddOn implements some changes to the OOB hybris B2B checkout flow, changes in

business processes in handling orders and finally additional request for security code on card payment. For reference see the OOB B2B checkout and and order process is described

here: https://help.hybris.com/6.2.0/hcd/8ac2500f8669101493e69e1392b970fd.html

3.7.3 Card Payment flow

The figure below shows the different steps on the checkout page in the responsive ui experience. It is

possible to checkout using card or account payment. The AddOn only changes the semantic of the card

payment flow, the account payment is left untouched.

One of the main difference is when to execute payment operations. In the OOB solution all card payments are initiated with an authorisation after the card details are entered. This is also the case for replenishment orders that are scheduled for later and for quotes that are requested and the price is not yet determined.

The AddOn handles this by moving the authorisation of the payment transaction until the order scheme is

known and selected after the final review of the order.

If the customer is buying now by placing the order then the payment transaction is authorised.

If the customer schedules a replenishment, the authorisation is handled by the generated hybris

cronjob, that are triggered according to the schedule. This authorisation is handled by a separate

merchant configuration.

If the customer requests a quote, the authorisation only happens if and when the quote is agreed

upon and the quote is accepted.

3.7.4 Handling of 3D Secure

The Worldpay B2B AddOn handles 3D secure in two of the three B2B card payme nt flows. The supported

scenarios are:

Place an order immediately from the order review step on the checkout page. The "buy now"

scenario.

Accept a quotes after a price negotiation.

The unsupported scenario is:

Page 84: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 84

A scheduled replenishment order created from a cronjob (no customer is present here for the 3D secure challenge).

The sequence diagram shows the interactions between the customers browser, a hybris installation with

the Worldpay B2B AddOn installed, Worldpay and the card issuer.

The 3D secure flow is started in the WorldpaySummeryCheckoutController /placeOrder endpoint in the buy now scenario and in the WorldpayQuotesController /quote/acceptQuoteOrder endpoint for the accept

quote scenario. In both cases the result is the same: a redirect to a page that auto summits a form to the

card issuer. This form is implemented in the jsp page autoSubmit3DSecure.jsp. Besides the data needed by

the card issuer the form contains a return url where the flow will continue after 3D secure.

3.7.5 Requesting Security Code (CVV) on card payment

The Worldpay B2B AddOn requests security code from the customer in the following scenarios on credit

card payment:

When entering card details.

When using a saved card the security code must always be entered on the final review ste p on the

checkout page. This happens before the customer desides between: placing the order now, scheduling a replenishment order or requesting a quote.

When accepting a quote where the payment type is credit card.

There is no customer present when replenishment orders are authorised within the generated cronjob,

hence it is not possible to supply a security code in this scenario.

There is no validation of the security code within the AddOn, this is handled entirely by Worldpay.

3.8 Business processes

3.8.1 Replenishment business flow

When the "CartToOrderCronJob" runs in order to generate a new Order from the replenishment Cart, it

triggers a business process: replenishmentOrderProcess.xml. In the Worldpay B2B AddOn this process has been customized in a worldpayReplenishmentOrderProcess.xml in order to fix a known concurrency issue

in the OOB process when including the assistedservicefacades extension in the setup. The only change in

the process flow is to remove the newly cloned Cart before executing the confi rmation Action which

triggers a new business process to send a confirmation mail to the customer.

3.8.2 Two replenishment action's have been customized in the Worldpay B2B

AddOn:

cloneCartAction - customized in WorldpayCloneCartAction:

The out-of-box CloneCartAction creates a new Cart from the cartToOrderCronJob and uses a single KeyGenerator to set both the code and guid of the newly created Cart. The Worldpay B2B AddOn uses the code of a Cart to generate a Worldpay order-code and for this to work, the code of the Cart needs to be on

the normal orderCodeGenerator form. The customized WorldpayCloneCartAction enables specifying

separate KeyGenerator for the code and guid.

Page 85: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 85

authorizePaymentAction - customized in WorldpayAuthorizePaymentAction:

The WorldpayAuthorizePaymentAction uses the WorldpayDirectOrderFacade to authorize the payment against Worldpay. The authorize is done using a special replenishment Merchant (see Worldpay Hybris

R6.2 Plugin 2.0 - Implementation Guide for configuration)

Worldpay OCC AddOn extension

3.9 Introduction

The worldpayoccaddon facilitates Worldpay payment on shopping cart, placing orders with Worldpay payments, and handling the 3D secure authentication protocol when placing such an order.

It supports this using Worldpays client side encryption (CSE) in a B2C context.

The worldpayoccaddon is an OCC AddOn that depends on the worldpayapi extension for Worldpay

payments operations.

This functionality is supplied by the two controllers WorldpayCartsController and

WorldpayOrdersController.

All REST endpoints supplied by this extension supports URL encoded parameters and a body payload of

either XML or JSON.

For documentation on the full hybris OCC interface see:

Related Documentation

OCC API documentation, version v2

3.9.1 Endpoints on the WorldpayCartsController

Method Path Parameters

POST /users/{userId}/carts/{cartId}/worldpaypaymentdetails The hybris OOB PaymentDetails is

extended with a cseToken

3.9.2 Endpoints on the WorldpayOrdersController

Method Path Parameters

POST /users/{userId}/worldpayorders cartId - the id of the used shopping cart

securityCode - the security code for the used

credit card

Page 86: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 86

Method Path Parameters

POST /users/{userId}/worldpayorders/3dresponse cartId - the id of the used shopping cart

paRes - the 3D protocols payer authentication

response

merchantData - the merchant data used in the 3D

protocol, this contains the Worldpay order code

3.10 Payment flows

The section gives an overview of the Worldpay payment flows.

For a good walk-through of the customer buying process using OCC see:

Related Documentation

Customer Buying Process Scenarios

3.10.1 Payments flow without 3D secure

Please contact [email protected] for the payment flow

3.10.2 Payments flow with 3D secure

Please contact [email protected] for the payment flow

3.11 Data adjustment on Worldpay communication

The section covers some special cases of data management in the hybris Worldpay communication

3.12 Handling session id in a stateless environment

Worldpay requires that identical session id's are supplied when an order is supplied more than once. In the 3D secure scenario the order is submitted once on authorise and once when the pa response is

validated in the second call.

OCC is a REST API that is stateless by design, so in this context there is no session id on the request.

To solve this issue we hash the OAuth 2 token and apply this as a session id, hence 3D secure

authentication has to be handled within the same OCC login session.

3.12.1 Passing client IP address through OCC to Worldpay

In order to secure that the correct customer IP address is passed to Worldpay the web shop implementer is responsible for parsing it through to OCC in a http header property.

This is handled by a strategy, where the used header property name can be configured. The spring

definition of this strategy is listed below.

It contains a list of alternative heater properties that can be used.

Page 87: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 87

If this strategy is not used, the OCC AddOn would only have the calling web shops IP address to pass to Worldpay.

Due to load balancers and similar components the strategy is also used in an accelerator storefront context.

worldpayapi-spring.xml

<alias name="defaultWorldpayCustomerIpAddressStrategy"

alias="worldpayCustomerIpAddressStrategy"/>

<bean id="defaultWorldpayCustomerIpAddressStrategy"

class="com.worldpay.strategy.impl.DefaultWorldpayCustomerIpAddressStrate

gy">

<property name="headerName" value="X-Forwarded-For"/>

<!-- Possible headers that contain the customer IP

<property name="headerName" value="Proxy-Client-IP"/>

<property name="headerName" value="WL-Proxy-Client-IP"/>

<property name="headerName" value="HTTP_CLIENT_IP"/>

<property name="headerName" value="HTTP_X_FORWARDED_FOR"/>

-->

</bean>

3.13 Test template extension - yworldpayocctest

The Worldpay OCC AddOn's endpoints are tested using the Spock test framework as supplied with the Hybris template extension ycommercewebservicestest.

These tests are all located in the template extension yworldpayocctest

The tests are released together with the Worldpay OCC AddOn in the template extension yworldpayocctest. This template extension is a self contained test template with no dependencies to

ycommercewebservicestest. By creating the Worldpay OCC test extension as a template, it is possible to generate a custom OCC test

extension using the tests created for Worldpay.

Using the yworldpayocctest template

The fact that yworldpayocctest is part of the commercewebservices module makes it possible to generate a custom Worldpay OCC test extension together with the Hybris OCC extension and Hybris OCC test

extension.

3.14 Module generation

To generate a module containing the Worldpay OCC test extension, execute the following ant command from the hybris platform directory (substitute the bold myocc and com.example to match your

organisation)

ant -d modulegen -Dinput.module='commercewebservices' -Dinput.name='myocc' -

Dinput.package='com.example'

This will generate an OCC module with the following extensions in the hybirs/bin/custom/myocc directory:

Page 88: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 88

myocc, OCC extension generated from ycommercewebservices

myocchmc, HMC extension generated from ycommercewebserviceshmc

myocctest, OCC Spock test extension generated from ycommercewebservicestest

myoccworldpaytest, OCC Spock test extension generated from yworldpayocctest

Add the generated module to your hybris installation. E.g. by adding the following line to

localextensions.xml:

localextensions.xml

<path autoload="true" dir="${HYBRIS_BIN_DIR}/custom"/>

To execute the tests in myoccworldpaytest execute the following ant command:

ant all integrationtests -Dfailbuildonerror=yes -

Dtestclasses.packages=com.example.worldpay.test.groovy.webservicetests.v

2.spock.AllSpockTests

Extension generation

To generate a Worldpay OCC test extension execute the following command from the hybris platform

directory (substitute the bold myoccworldpaytest and com.example to match your organisation)

ant extgen -Dinput.template='yworldpayocctest' -Dinput.name='myoccworldpaytest' -

Dinput.package='com.example'

Add the generated extension to your hybris installation. E.g. by adding the following line

to localextensions.xml:

localextensions.xml

<extension name='myoccworldpaytest' />

To execute the tests in myoccworldpaytest execute the following ant command:

ant all integrationtests -Dfailbuildonerror=yes -

Dtestclasses.packages=com.example.test.groovy.webservicetests.v2.spock.AllSpockTests

3.15 Test Data

The yworldpayocctest template extension only contains the basic oauth 2 client configuration to get

connected to the OCC API. The essential data is listed below.

essentialdataOAuthClientDetails.impex

Page 89: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 89

essentialdataOAuthClientDetails.impex

INSERT_UPDATE

OAuthClientDetails;clientId[unique=true];resourceIds;scope;authorizedGrantTypes;

authorities;clientSecret;registeredRedirectUri

;client-

side;hybris;basic;implicit,client_credentials;ROLE_CLIENT;secret;http://localhos

t:9001/authorizationserver/oauth2_implicit_callback;

;mobile_android;hybris;basic;authorization_code,refresh_token,password,client_cr

edentials;ROLE_CLIENT;secret;http://localhost:9001/authorizationserver/oauth2_ca

llback;

;trusted_client;hybris;extended;authorization_code,refresh_token,password,client

_credentials;ROLE_TRUSTED_CLIENT;secret; ;

Client side encryption (CSE) test

In order to be able to test CSE in an OCC context where payment details are added to cart, we have to

simulate a running browser where the Worldpay CSE javascript is executed.

The utility method below uses Geb to simulate the browser.

Geb - browser automation tool

http://www.gebish.org/manual/current/

The browser accesses the cseTest.html page below, whose only task it is to load the Worldpay CSE

javascript and supply a javascript function (generateCseToken) to execute the card encryption function.

When the paged is loaded, generateCseToken is called and the resulting CSE token is obtained and passed

back to the calling Spock test.

AbstractWorldpaySpockTest.groovy

protected getCseToken(cvc, cardHolderName, cardNumber, expiryMonth, expiryYear)

{

def cseToken

def browser = new Browser(driver: new FirefoxDriver())

browser.go "file://" + (String) config.HTML_PATH + "/cseTest.html"

cseToken = browser.js.generateCseToken("1#10001#c745fe13416ffc5f9283f4 ...",

cvc,

cardHolderName,

cardNumber, expiryMonth,

expiryYear)

browser.close() return cseToken

}

Page 90: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 90

cseTest.html

<!DOCTYPE html>

<html lang="en"> <head>

<meta charset="UTF-8">

<title>CSE Test Form</title> <script type="text/javascript"

src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>

<script type="text/javascript" src="https://payments.worldpay.com/resources/cse/js/worldpay-cse-1.0.1.min.js"></script>

<script type="text/javascript" >

function generateCseToken(publicKey, cvc, cardHolderName, cardNumber, expMonth, expYear) { Worldpay.setPublicKey(publicKey);

var data = { cvc: cvc,

cardHolderName: cardHolderName,

cardNumber: cardNumber, expiryMonth: expMonth,

expiryYear: expYear

}; var encryptedData = Worldpay.encrypt(data, this.errorHandler);

return encryptedData; }

function errorHandler(errorCodes) { for (var index in errorCodes) {

var errorCode = errorCodes[index].toString();

alert(errorCode); }

}

</script> </head>

<body></body>

</html>

3D secure test

In order to test the 3D secure flow you need to be able to simulate the following steps after a place order

has been called on the WorldpayOrdersController.

1. Redirect the customers browser to the card issuer (in our case the Worldpay 3D secure simulator) supplying the pa request, the merchantData, and a returning term url.

Page 91: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > End User Guide 91

Again Geb and a html page is used to simulate this. The html page auto submits the supplied data

in the form to the Worldpay 3D secure simulator.

2. Now the browser is located on the Worldpay 3D secure simulator, where the utility function chooses the outcome of the simulation

and clicks the simulators button to proceed.

3. The simulator posts to the term url. This hits the Worldpay3DResponseMockController method shown below,

which returns a page where the pa response can be obtained and passed back to the call ing Spock

test.

The below test method illustrates how the three steps have been implemented.

AbstractWorldpaySpockTest.groovy

protected handleThreeDSecureInBrowser(issuerUrl, paRequest, merchantData, authorisationResponse) {

def browser = new Browser(driver: new FirefoxDriver())

def termUrl = getDefaultHttpsUri() + "/worldpayresponsemock/3dresponse"

def autoSubmitUrl = "file://" + (String) config.HTML_PATH +

"/threeDSecureTest.html?" +

"IssuerUrl=" + URLEncoder.encode(issuerUrl, "UTF-8") +

"&PaReq=" + URLEncoder.encode(paRequest, "UTF-8") +

"&MD=" + URLEncoder.encode(merchantData, "UTF-8") +

"&TermUrl=" + URLEncoder.encode(termUrl, "UTF-8")

browser.go autoSubmitUrl

// The threeDSecureTest.html page auto submits and forwards to the

// worldpay 3D simulator page (the issuer url)

browser.$("form").paResMagicValues = authorisationResponse

// On the worldpay 3D simulator we select the given authorisationResponse and click the submit button browser.getPage().$(org.openqa.selenium.By.className("lefty")).click()

// We are now on a mock endpoint in the worldpayresponcemock extension which collects the Pa response

def paRes = browser.getPage().$(org.openqa.selenium.By.className("PaRes")).value()

browser.close()

return paRes

}

Page 92: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > SAP Hybris Software End User License Agreement 92

Worldpay3DResponseMockController.java

@RequestMapping (method = POST) public String mockWorldpayResponse(final ModelMap model, final HttpServletRequest request) {

String paRes = request.getParameter("PaRes"); String merchantData = request.getParameter("MD");

model.put("paRes", paRes); model.put("merchantData", merchantData);

return "pages/threeDSecureResponse";

}

Appendix A: SAP Hybris Software End User License

Agreement

This Software End User License Agreement ("Agreement") is between you (both the individual downloading and/or installing the Software and any legal entity for which the individual is acting) ("You" or "Your") and

WORLDPAY (UK) LIMITED ("WorldPay").

TAKING ANY STEP TO SET UP, DOWNLOAD OR INSTALL THE SOFTWARE MEANS THAT YOU ACCEPT ALL OF THE TERMS OF THIS LICENSE AGREEMENT. PERMISSION TO DOWNLOAD, INSTALL AND/OR USE THE

SOFTWARE IS EXPRESSLY CONDITIONED ON YOU FOLLOWING THESE TERMS. IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS AGREEMENT, YOU ARE NOT AUTHORISED TO USE THE SOFTWARE AND MUST STOP

INSTALLING IT OR UNINSTALL IT, AS APPLICABLE.

THIS SOFTWARE IS TO BE USED SOLELY IN CONNECTION WITH THE THIRD PARTY SOFTWARE AND YOU MUST SATISFY YOURSELF THAT THIS SOFTWARE IS SUITABLE FOR YOUR NEEDS AND THAT YOUR SYSTEM

SATISFIES THE REQUIREMENTS FOR THE USE OF THIS SOFTWARE AS SET OUT IN THE DOCUMENTATION.

Page 93: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > SAP Hybris Software End User License Agreement 93

1. DEFINITIONS

1.1 "Documentation" means written documentation, specifications and help content made generally available by WorldPay to aid in installing and using the Software, or otherwise provided by WorldPay to

you in connection with the Software.

1.2 "Software" means hybris Extension, the data supplied with such software and the associated media and

any upgrades or updates of such software provided by WorldPay to you.

1.3 “Third Party Software” means the third party software with which the Software is designed to be used,

as described in the Documentation.

2. SOFTWARE LICENSE

2.1 Limited License. Subject to this Agreement's restrictions, WorldPay grants to You a limited, revocable,

non-exclusive, non-transferable, royalty-free license (without the right to sublicense):

(a) to install a single copy of the Software on the equipment containing the Third Party Software, solely for the purpose of using the Software in connection with the Third Party Software and WorldPay’s own

products, as described in the Documentation ("Authorised Use");

(b) to use the Documentation in support of Your Authorised Use; and

(c) to make one copy of the Software solely for backup purposes, provided that all titles and trademark,

copyright and restricted rights notices are reproduced on the copy.

2.2 Ownership. WorldPay or its licensor retains all right, title and interest in and to all patent, copyright, trademark, trade secret and other intellectual property rights in the Software and Documentation, and any

derivative works thereof. You do not acquire any other rights, express or implied, beyond the limited

license set forth in this Agreement.

2.3 No Support. WorldPay has no obligation to provide support, maintenance, upgrades, modifications or

new releases for the Software or Documentation under this Agreement.

3. RESTRICTIONS

3.1 You undertake not to:

(a) rent, lease, sub-license, loan, translate, merge, adapt, vary or modify the Software or Documentation;

(b) make alterations to, or modifications of, the whole or any part of the Software , nor permit the Software or any part of it to be combined with, or become incorporated in, any other software other than the Third

Party Software as described in the Documentation;

(c) disassemble, decompile, reverse-engineer or create derivative works based on the whole or any part of

the Software nor attempt to do any such thing;

Page 94: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > SAP Hybris Software End User License Agreement 94

(d) provide or otherwise make available the Software in whole or in part (including but not limited to program listings, object and source program listings, object code and source code), in any form to any

person other than your employees without the prior written consent of WorldPay.

4. WARRANTY DISCLAIMER

THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT ANY REPRESENTATIONS OR WARRANTIES, AND YOU AGREE TO USE THEM AT YOUR SOLE RISK. TO THE FULLEST EXTENT PERMISSIBLE BY LAW, WORLDPAY EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND WITH RESPECT TO THE

SOFTWARE AND DOCUMENTATION, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING ANY

WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, SATISFACTORY QUALITY,

ACCURACY, TITLE OR NON-INFRINGEMENT OF THIRD PARTY RIGHTS.

5. LIMITATION OF LIABILITY

IN NO EVENT WILL WORLDPAY OR ITS AFFILIATES BE LIABLE IN CONNECTION WITH THIS AGREEMENT OR ITS SUBJECT MATTER, UNDER ANY THEORY OF LIABILITY, FOR ANY INDIRECT, INCIDENTAL, SPECIAL,

CONSEQUENTIAL OR PUNITIVE DAMAGES, OR DAMAGES FOR LOST PROFITS, REVENUE, BUSINESS, SAVINGS, DATA, USE, OR COST OF SUBSTITUTE PROCUREMENT, EVEN IF ADVISED OF THE POSSIBILITY OF

SUCH DAMAGES OR IF SUCH DAMAGES ARE FORESEEABLE. IN NO EVENT WILL WORLDPAY’S LIABILITY FOR

ALL DAMAGES EXCEED THE AMOUNTS ACTUALLY PAID BY YOU TO WORLDPAY FOR THE SOFTWARE. THE PARTIES ACKNOWLEDGE THAT THE LIABILITY LIMITS AND RISK ALLOCATION IN THIS AGREEMENT ARE

REFLECTED IN THE SOFTWARE PRICE AND ARE ESSENTIAL ELEMENTS OF THE BARGAIN BETWEEN THE

PARTIES, WITHOUT WHICH WORLDPAY WOULD NOT HAVE PROVIDED THE SOFTWARE OR ENTERED INTO

THIS AGREEMENT.

6. TERMINATION

This Agreement is effective until terminated. WorldPay may terminate this Agreement at any time upon Your breach of any provision. If this Agreement is terminated, You will stop using the Software,

permanently delete it from the equipment where it resides, and destroy all copies of the Software and Documentation in Your possession, confirming to WorldPay in writing that You have done so. Sections 2.2,

2.3, 3, 4, 5 and 7 will continue in effect after this Agreement's termination.

7. GENERAL TERMS

7.1 Law. This Agreement and all matters arising out of it are governed by the laws of England and Wales, and the parties irrevocably consent to the exclusive jurisdiction of the courts of England. Application of the

United Nations Convention on Contracts for the International Sales of Goods is expressly excluded.

7.2 Severability and Waiver. If any provision of this Agreement is held to be illegal, invalid or otherwise unenforceable, that provision will be enforced to the extent possible or, if incapable of enforcement,

deemed to be severed and deleted from this Agreement, and the remainder will continue in full force and

effect. The waiver by either party of any default or breach of this Agreement will not waive any other or

subsequent default or breach.

Page 95: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay SAP Hybris AddOn Guide > SAP Hybris Software End User License Agreement 95

7.3 No Assignment. You may not assign, sell, transfer, delegate or otherwise dispose of this Agreement or any rights or obligations under it, whether voluntarily or involuntarily, by operation of law or otherwise,

without WorldPay’s prior written consent. Any purported assignment, transfer or delegation by You will be

null and void. Subject to the foregoing, this Agreement will be binding upon and will inure to the benefit of the parties and their respective successors and assigns. You agree, represent and warrant that You will not

export the Software or any underlying technology in contravention of any applicable U.S. or foreign export

laws and regulations.

7.4 Entire Agreement. This Agreement constitutes the entire agreement between the parties and supersedes all prior or contemporaneous agreements or representations, whether written or oral, concerning its subject matter. This Agreement may not be modified or amended without WorldPay’s prior

and express written consent, and no other act, document, usage or custom will be deemed to amend or

modify this Agreement.

Page 96: Worldpay SAP Hybris AddOn Guide · Worldpay SAP Hybris AddOn Guide > Implementation Guide 7 If the customer at a later time chooses to remove the payment details, a delete token request

Worldpay hybris Extension Guide > Contact us 96

Email: [email protected]

Worldpay Support Centre: http://www.worldpay.com/global/support/guides/corporate-gateway-guides

© Worldpay 2017. All rights reserved.

Worldpay, the logo and any associated brand names are all trademarks of the Worldpay group of companies.

1.