Giter Club home page Giter Club logo

payhost's Introduction

PayHost

This library is merely a Merchant integration helper in PHP

Requirements: PHP 5.3 because of namespaces.

Setup

Add a composer.json file to your project:

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

Then provided you have composer installed, you can run the following command:

$ 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

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

Then you need to use the relevant classes, for example:

use PayGate\PayHost\Helper;

Usage

We start by mapping all our front end html inputs to their respective sections in the PayHost wsdl:

$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.

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

Initiate the Helper class, passing in the input map array:

$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.

We'll call this new array $filteredPost for now.

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

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

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

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

We now have a valid XML to pass to PHP's SoapClient.

eg.

$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();
}

payhost's People

Contributors

hanno-paygate avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.