2017 © Pedro Peláez
 

library payhost-helper

Merchant integration helper in PHP

image

paygate/payhost-helper

Merchant integration helper in PHP

  • Thursday, October 12, 2017
  • by hannoa
  • Repository
  • 4 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 8 Versions
  • 14 % Grown

The README.md

PayHost

This library is merely a Merchant integration helper in PHP, (*1)

Requirements: PHP 5.3 because of namespaces., (*2)

Setup

Add a composer.json file to your project:, (*3)

{
  "require": {
      "paygate/payhost-helper": "1.0.2"
  }
}

Then provided you have composer installed, you can run the following command:, (*4)

$ composer.phar install

That will fetch the library and its dependencies inside your vendor folder. Then you can add the following to your .php files in order to use the library, (*5)

require_once __DIR__.'/vendor/autoload.php';

Then you need to use the relevant classes, for example:, (*6)

use PayGate\PayHost\Helper;

Usage

We start by mapping all our front end html inputs to their respective sections in the PayHost wsdl:, (*7)

$inputMap = array();

The values in the array should be the html input names on the form, while the keys remain untouched as these are what the Helper class looks for., (*8)

For an example of the array contents, look at the public $inputMap property in Helper.php., (*9)

Initiate the Helper class, passing in the input map array:, (*10)

$Helper = new Helper($inputMap);

At the moment, all the sanitizing of the inputs received from the form is not being done by the helper. One could use PHP's filter_var_array to create a new array containing the sanitized values., (*11)

We'll call this new array $filteredPost for now., (*12)

Then call setWebPaymentRequestMessage or setCardPaymentRequestMessage depending on your needs, and pass in the array created before:, (*13)

$SinglePaymentRequest = $Helper->setWebPaymentRequestMessage($filteredPost);

Once the request object has been built, create valid XML from it by calling:, (*14)

$xml = Helper::generateValidXmlFromObj($SinglePaymentRequest, 'SinglePaymentRequest');

We now have a valid XML to pass to PHP's SoapClient., (*15)

eg., (*16)

$SoapClient = new SoapClient("https://www.secure.paygate.co.za/payhost/process.trans?wsdl", array('trace' => 1)); //point to WSDL and set trace value to debug

try {
    /*
     * Send SOAP request
     */
    $result = $SoapClient->__soapCall('SinglePayment', array(
        new SoapVar($xml, XSD_ANYXML)
    ));
} catch (SoapFault $sf){
    /*
     * handle errors
     */
    $err = $sf->getMessage();
}

The Versions

12/10 2017

dev-master

9999999-dev

Merchant integration helper in PHP

  Sources   Download

The Requires

  • php >=5.3.0

 

by Hanno Avenant

12/10 2017

1.0.3

1.0.3.0

Merchant integration helper in PHP

  Sources   Download

The Requires

  • php >=5.3.0

 

by Hanno Avenant

12/10 2017

1.0.2

1.0.2.0

Merchant integration helper in PHP

  Sources   Download

The Requires

  • php >=5.3.0

 

by Hanno Avenant

03/07 2017

v1.0.1

1.0.1.0

Merchant integration helper in PHP

  Sources   Download

The Requires

  • php >=5.0.0

 

by Hanno Avenant

03/07 2017

v1.0.0

1.0.0.0

Merchant integration helper in PHP

  Sources   Download

The Requires

  • php >=5.0.0

 

by Hanno Avenant

03/07 2017

v0.5

0.5.0.0

Merchant integration helper in PHP

  Sources   Download

The Requires

  • php >=5.0.0

 

by Hanno Avenant

03/07 2017

v0.4

0.4.0.0

Merchant integration helper in PHP

  Sources   Download

The Requires

  • php >=5.0.0

 

by Hanno Avenant

03/07 2017

v0.3

0.3.0.0

Merchant integration helper in PHP

  Sources   Download

The Requires

  • php >=5.0.0

 

by Hanno Avenant