developer:soap-1.2:howto:pearsoap

Soap API v1.2

PHP PEAR::SOAP Guide

This guide provides information on using the PEAR::Soap library with the USAePay SOAP API. The SOAP API provides an advanced interface to USAePay that allows merchants and resellers to access a wide range of functionality. This API requires a little more expertise than our simpler PHP Library for the Transaction API. If you are only looking to process transactions it is recommended that you use the PHP Library instead.

The official Pear repository includes a fairly full-featured Soap library written in PHP. Since it is written in PHP, it does not require any special privileges to install on your web server. See PEAR::Soap for more information.

Using PEAR::Soap

Step 1: Including the Soap library

If you have installed the PEAR::Soap library in the standard location, you should be able to use the code below. Otherwise, make sure to either add the library to your include path or provide the full path to the library files.

<?php
 
require_once 'SOAP/Base.php';
require_once 'SOAP/Client.php';
 
?>

Step 2: Instantiating $client

The first step is to instantiate the SOAP_Client object. In the soap example provided on this site, we use $client for this object.

<?php		
  //for live server use 'www' for test server use 'sandbox'
  $wsdl='https://www.usaepay.com/soap/gate/3213EA2A/usaepay.wsdl';
 
  // instantiate SOAP_Client object as $client
  $client = new SOAP_Client($wsdl);
 
?>

Step 3: Building Security $token

The ueSecurityToken object is used to securely identify the merchant to the gateway. To build a token, you will need the merchant's Source Key and Pin. The source key is created by the merchant in the Merchant Console under the Settings - Sources screen. Many of the methods in the SOAP API require the use of a PIN and it is recommended that you always use a PIN. The merchant assigns the PIN when creating the source key.

<?php
  $sourcekey = 'yQbOFkmykeygoeshere3Lc9PH1l14';
  $pin = '1234'; 
 
  // generate random seed value
  $seed=mktime() . rand();
 
  // make hash value using sha1 function
  $clear= $sourcekey . $seed . $pin;
  $hash=sha1($clear);
 
  // assembly ueSecurityToken as an array
  $token=array(
    'SourceKey'=>$sourcekey,
    'PinHash'=>array(
       'Type'=>'sha1',
       'Seed'=>$seed,
       'HashValue'=>$hash
     ),
     'ClientIP'=>$_SERVER['REMOTE_ADDR'];
  );
?>

Examples

The majority of examples listed in the documentation as PHP5 will work with either the built-in Soap client, or the Pear Library. In cases where different syntax is required for the Pear library, a separate example is required.

Additional Help

For questions please email devsupport@usaepay.com

developer/soap-1.2/howto/pearsoap.txt · Last modified: 2010/02/12 12:05 by epouchak

Page Tools