mPAY24 Logo

mPAY24 PHP API

Documentation

Open the mPAY24 payment window in 5 steps!

LICENSE/DISCLAIMER

Copyright 2011 mPAY24 GmbH

Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work except in compliance with the Licence.
You may obtain a copy of the Licence at:
http://ec.europa.eu/idabc/eupl.html

Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and limitations under the Licence.

ABSTRACT

The target of this guide is to help you open the mPAY24 payment page in five simple steps, using the mPAY24 PHP API.

*Please note, that you still need to implement the mPAY24 Confirmation-Interface as explained in chapter 4.2.6.1 of the "Specification of the mPAY24 Interfaces" in order to have your system process the result of the payment transaction!* The mPAY24 PHP API will also help you with this, but in order to fully understand how payment transactions work and therefore avoid some common pitfalls with the implementation, you are strongly encouraged to refer to the specification! There is also a complete and ready to test "example shop" available at mPAY24.

Prerequisites

In order for the mPAY24 PHP API to work, your installation will have to meet the following prerequisites:

* PHP >= 5
* cURL
* DOM
* Mcrypt

Please refer to http://www.php.net/phpinfo or consult your systems administrator in order to find out if your system fulfills the prerequisites.

STEP 1

a. create a PHP file, preferably in a folder dedicated to testing the mPAY24 PHP API within the DocumentRoot, for example: ../DocumentRoot/mPAY24_PHP_API/index.php
b. copy the files supplied by mPAY24 into this same directory.


c. ...and implement some functionality. First of, we need to include the file "MPay24Shop.php" in our script and initialize our own class. Let's just use the name "MyShop" for the moment. MyShop extends the MPay24Shop class supplied from the MPay24Shop.php file. We'll leave this class empty for this step.



STEP 2

Out of the ten abstract methods within the MPay24Shop class, you will have to implement functionality into at least two of the methods to initialize the mPAY24 payment page. We initialize also two variables, which are responisble for the the mandatory tags from the MDXI(see chapter 4.2.9 of the specification for details). We start out by inserting all the functions into our class like this:



STEP 3

a. to carry out a payment transaction, mPAY24 will need to know the amount to be paid, as well as a transaction identifier (see chapter 4.2.2 and chapter 4.2.9 of the mPAY24 specification for details), which will come in handy especially later, when we begin to obtain the result of the payment. You can refer to the "allowed properties for a transaction" for further reference. Now, create a transaction by filling the createTransaction method with life:



b. in order to initialize the mPAY24 payment page, you need to supply mPAY24 with a MDXI XML (see chapter 4.2.9 of the specification for details). The MDXI XML contains all the information mPAY24 needs to authorize and/or bill, which is at least the TID specified by your system as well as the amount. The ORDER object helps you create such a XML file. We create the MDXI by utilizing the - right, you guessed it - createMDXI method.



Please read the specification as well as "How to work with the ORDER object" to utilize the MDXI XML to it's full power.

STEP 4

We do not need to create a constructor for our MyShop class, as it is sufficient to use the parent constructor of the MPay24Shop class. The parent constructor expects 3 mandatory variables:
1. the mPAY24 merchantID - please supply your test system merchantID, starting with the digit 9.
2. your SOAP password supplied by mPAY24. Please note, that this is *not* the same password used for login at www.mpay24.com or test.mpay24.com!
3. a boolean to define whether to use the productive- or test systems
* TRUE to use the mPAY24 test systems, what is exactly we like to do for now...
* FALSE to use the mPAY24 productive systems
4. optional: in case you are behind a proxy, you can set it's IP address...
5. ... and port.
6. You can also set whether log files are going to be created or not with another boolean variable:
* TRUE to write log files
* FALSE is the default value - in this case no log files are written

Insert the declaration before the end of the if(isset($_POST["submit"])) control structure. If you are not behind a proxy, just set the two variables to NULL. If you are unsure whether or not you are behind a proxy, please contact your systems administrator or ISP.



STEP 5

Last but not least, we need to call the pay() method and parse it's PaymentResponse object. The PaymentResponse object contains a GeneralResponse object holding the response from the mPAY24 systems.



Navigate your browser to the file with your code and use the test details from chapter five of the mPAY24 specification to conduct your first test transaction. Of course, you cannot finish the transaction as the Success-, Error- and Confirmation-URLs still have to be implemented (see "How to work with the confirmation"). Please read the FAQ within Appendix B of the specification and find our contact details within Appendix C in case you have any questions.