IPG Fiserv: 4 Simple Step to Integrate on PHP

Introduction

In today’s digital landscape, integrating payment gateways is essential for any online business. IPG Fiserv stands out as a reliable choice for secure transactions. This comprehensive guide will walk you through the process of installing IPG Fiserv on PHP. Whether you’re a seasoned developer or new to the world of payment gateways, this step-by-step guide will make the process seamless.

Setting the Stage: Understanding IPG Fiserv

Before we dive into the installation process, let’s take a moment to understand what IPG Fiserv is. IPG Fiserv, short for Internet Payment Gateway by Fiserv, is a robust platform that facilitates secure online transactions. It acts as a bridge between your website and the payment processing networks, ensuring that customer payments are processed efficiently and securely.

Preparing Your Environment

Ensuring Compatibility

Before you begin the installation, it’s crucial to confirm that your environment is compatible with IPG Fiserv. Check for the necessary PHP version and ensure that your server meets the specified requirements.

Acquiring API Credentials

To integrate IPG Fiserv with PHP, you’ll need some essentials.

  • Stroe ID (example: 10012345678)
  • User ID (example: 10012345678)
  • Password
  • Client Certificate p12 (example: WSstoreID._.userID.p12)
  • Client Certificate Installation Password
  • Client Certificate Private Key (example: WSstoreID._.userID.key)
  • Client Certificate Private Key Password
  • Client Certificate PEM File
  • Trust Anchor as concatenated PEM File (tlstrust.pem) {OPTIONAL}
  • Trust Anchor as PKCS#7 File (tlstrust.p7b) {OPTIONAL}

NOTE: Store ID, User ID, Password, Client Certificate p12, Client Certificate Installation Password, Client Certificate Private Key and Client Certificate PEM File is provided by IPG FISERV. Kindly contact to support to get all these details.

SPECIAL NOTE: If you want to obtain your self PEM and PRIVATE Keys. You can use openssl commands to generate these files.

After getting all these essentials things, below are the steps to integrate step by step guide.

Step-by-Step Guide to Installing IPG Fiserv on PHP

Step 1: Create a IPG folder, to store files in one place.

Step 2: Add the PRIVATE KEY & PUBLIC KEY to that folder.

Step 3: Create a config.php inside the folder and add your necessary details in that file such as USER ID, STORE ID, PASSWORD etc.

<?php

define('USER_ID', 'WS10012345678._.1');
define('USER_PASSWORD', 'Ac=2C:l9iK');
define('CERTIFICATE_PASSWORD', 'Y4Pl(<c8wr');

?>

Step 4: Create an index.php inside the folder and write your PHP CURL CODE inside the file. Below is the example

<?php
include('config.php');

try {

// storing the SOAP message in a variable – note that the plain XML code
// is passed here as string for reasons of simplicity, however, it is
// certainly a good practice to build the XML e.g. with DOM – furthermore,
// when using special characters, you should make sure that the XML string
// gets UTF-8 encoded (which is not done here):

$body = '<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
        <SOAP-ENV:Header />
        <SOAP-ENV:Body>
            <ipgapi:IPGApiOrderRequest
            xmlns:v1="http://ipg-online.com/ipgapi/schemas/v1"
            xmlns:ipgapi="http://ipg-online.com/ipgapi/schemas/ipgapi">
            <v1:Transaction>
                <v1:CreditCardTxType>
                    <v1:Type>sale</v1:Type>
                </v1:CreditCardTxType>
                <v1:CreditCardData>
                    <v1:CardNumber>4111111111111111</v1:CardNumber>
                    <v1:ExpMonth>12</v1:ExpMonth>
                    <v1:ExpYear>27</v1:ExpYear>
                    <v1:CardCodeValue>222</v1:CardCodeValue>
                </v1:CreditCardData>
                <v1:Payment>
                    <v1:ChargeTotal>22.00</v1:ChargeTotal>
                    <v1:Currency>484</v1:Currency>
                </v1:Payment>
            </v1:Transaction>
            </ipgapi:IPGApiOrderRequest>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>';
// initializing cURL with the IPG API URL:
$ch = curl_init("https://test.ipg-online.com/ipgapi/services");
// setting the request type to POST:
curl_setopt($ch, CURLOPT_POST, 1);


// setting the content type:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
// setting the authorization method to BASIC:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// supplying your credentials:
curl_setopt($ch, CURLOPT_USERPWD, USER_ID.":".USER_PASSWORD);
// filling the request body with your SOAP message:
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);


// telling cURL to verify the server certificate:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

// setting the path where cURL can find the certificate to verify the
// received server certificate against:
curl_setopt($ch, CURLOPT_CAINFO, "tlstrust.pem");

// setting the path where cURL can find the client certificate:
curl_setopt($ch, CURLOPT_SSLCERT, "WS10012345678._.1.pem");
// setting the path where cURL can find the client certificate’s
// private key:

curl_setopt($ch, CURLOPT_SSLKEY, "WS10012345678._.1.key");
// setting the key password:
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, CERTIFICATE_PASSWORD);

ob_start();

$response = curl_exec($ch);

$xmlResponse = ob_get_clean();

$clean_xml = str_ireplace(['SOAP-ENV:', 'SOAP:', 'ipgapi:'], '', $xmlResponse);


$xml = simplexml_load_string($clean_xml);

echo "<pre>";
print_r($xml); 


curl_close($ch);

} catch (Exception $e) {
    echo $e->getMessage();
}

?>

NOTE: If you dont have created the trusted.pem and don’t know how to deal it with. So, to avoid this just set curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true) to curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false) and comment the curl_setopt($ch, CURLOPT_CAINFO, “tlstrust.pem”) as mentioned in below code.

<?php
include('config.php');

try {

// storing the SOAP message in a variable – note that the plain XML code
// is passed here as string for reasons of simplicity, however, it is
// certainly a good practice to build the XML e.g. with DOM – furthermore,
// when using special characters, you should make sure that the XML string
// gets UTF-8 encoded (which is not done here):
$body = '<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
        <SOAP-ENV:Header />
        <SOAP-ENV:Body>
            <ipgapi:IPGApiOrderRequest
            xmlns:v1="http://ipg-online.com/ipgapi/schemas/v1"
            xmlns:ipgapi="http://ipg-online.com/ipgapi/schemas/ipgapi">
            <v1:Transaction>
                <v1:CreditCardTxType>
                    <v1:Type>sale</v1:Type>
                </v1:CreditCardTxType>
                <v1:CreditCardData>
                    <v1:CardNumber>4111111111111111</v1:CardNumber>
                    <v1:ExpMonth>12</v1:ExpMonth>
                    <v1:ExpYear>27</v1:ExpYear>
                    <v1:CardCodeValue>222</v1:CardCodeValue>
                </v1:CreditCardData>
                <v1:Payment>
                    <v1:ChargeTotal>22.00</v1:ChargeTotal>
                    <v1:Currency>484</v1:Currency>
                </v1:Payment>
            </v1:Transaction>
            </ipgapi:IPGApiOrderRequest>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>';
// initializing cURL with the IPG API URL:
$ch = curl_init("https://test.ipg-online.com/ipgapi/services");
// setting the request type to POST:
curl_setopt($ch, CURLOPT_POST, 1);


// setting the content type:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
// setting the authorization method to BASIC:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// supplying your credentials:
curl_setopt($ch, CURLOPT_USERPWD, USER_ID.":".USER_PASSWORD);
// filling the request body with your SOAP message:
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);


// telling cURL to verify the server certificate:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// setting the path where cURL can find the certificate to verify the
// received server certificate against:
// curl_setopt($ch, CURLOPT_CAINFO, "tlstrust.pem");

// setting the path where cURL can find the client certificate:
curl_setopt($ch, CURLOPT_SSLCERT, "W10012345678._.1.pem");
// setting the path where cURL can find the client certificate’s
// private key:

curl_setopt($ch, CURLOPT_SSLKEY, "W10012345678._.1.key");
// setting the key password:
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, CERTIFICATE_PASSWORD);

ob_start();

$response = curl_exec($ch);

$xmlResponse = ob_get_clean();

$clean_xml = str_ireplace(['SOAP-ENV:', 'SOAP:', 'ipgapi:'], '', $xmlResponse);


$xml = simplexml_load_string($clean_xml);

echo "<pre>";
print_r($xml); 


curl_close($ch);

} catch (Exception $e) {
    echo $e->getMessage();
}

?>

Here we learn, how to integrate IPG FISERV with PHP.

Special Things to Know

IPG support 4 type of transaction type

  • sale: Sale is used when you directly want user’s card has to be charged in one go.
  • preAuth: PreAuth is used when you hold a amount on user card and want to process whenever your want.
  • postAuth: PostAuth is used only when the initial transaction is PreAuth, which meand PostAuth debits the amount from user’s card which is get whole while doing PreAuth.
  • void: Void is use when you want to release the amount which is put on hold on a user’s card.

IPG support almost all currencies

  • You can get the list of currency codes (ISO 4217) by visiting this link. CURRENCY CODE

TEST Card Details

  • 4111111111111111
  • 4931580001642617
  • 5579220000000012

PRO TIPS

After following above mentioned steps, I believe you can easily integrate the IPG Fiser to PHP. If still you find some issue such as:

  • Terminal Error: For this, you can contact to IPG Support and ask the to enable the Terminal to your Merchant Account.
  • Currency Error: It comes when you want to transact a user for different currency which is not enabled on your Merchant Account. If this happens ask IPG Support to enable these currencies as well.

Some more examples for different transaction types

PreAuth: Below is the code example to do a transaction in PreAuth.

<?php
include('config.php');

try {

// storing the SOAP message in a variable – note that the plain XML code
// is passed here as string for reasons of simplicity, however, it is
// certainly a good practice to build the XML e.g. with DOM – furthermore,
// when using special characters, you should make sure that the XML string
// gets UTF-8 encoded (which is not done here):
$body = '<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
        <SOAP-ENV:Header />
        <SOAP-ENV:Body>
            <ipgapi:IPGApiOrderRequest
            xmlns:v1="http://ipg-online.com/ipgapi/schemas/v1"
            xmlns:ipgapi="http://ipg-online.com/ipgapi/schemas/ipgapi">
            <v1:Transaction>
                <v1:CreditCardTxType>
                    <v1:Type>preAuth</v1:Type>
                </v1:CreditCardTxType>
                <v1:CreditCardData>
                    <v1:CardNumber>4111111111111111</v1:CardNumber>
                    <v1:ExpMonth>12</v1:ExpMonth>
                    <v1:ExpYear>27</v1:ExpYear>
                    <v1:CardCodeValue>222</v1:CardCodeValue>
                </v1:CreditCardData>
                <v1:Payment>
                    <v1:ChargeTotal>22.00</v1:ChargeTotal>
                    <v1:Currency>484</v1:Currency>
                </v1:Payment>
            </v1:Transaction>
            </ipgapi:IPGApiOrderRequest>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>';
// initializing cURL with the IPG API URL:
$ch = curl_init("https://test.ipg-online.com/ipgapi/services");
// setting the request type to POST:
curl_setopt($ch, CURLOPT_POST, 1);


// setting the content type:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
// setting the authorization method to BASIC:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// supplying your credentials:
curl_setopt($ch, CURLOPT_USERPWD, USER_ID.":".USER_PASSWORD);
// filling the request body with your SOAP message:
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);


// telling cURL to verify the server certificate:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// setting the path where cURL can find the certificate to verify the
// received server certificate against:
// curl_setopt($ch, CURLOPT_CAINFO, "tlstrust.pem");

// setting the path where cURL can find the client certificate:
curl_setopt($ch, CURLOPT_SSLCERT, "WS10012345678._.1.pem");
// setting the path where cURL can find the client certificate’s
// private key:

curl_setopt($ch, CURLOPT_SSLKEY, "WS10012345678._.1.key");
// setting the key password:
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, CERTIFICATE_PASSWORD);

ob_start();

$response = curl_exec($ch);

$xmlResponse = ob_get_clean();

$clean_xml = str_ireplace(['SOAP-ENV:', 'SOAP:', 'ipgapi:'], '', $xmlResponse);


$xml = simplexml_load_string($clean_xml);

echo "<pre>";
print_r($xml); 


curl_close($ch);

} catch (Exception $e) {
    echo $e->getMessage();
}

?>

PostAuth: Below is the code example to do a transaction in PostAuth.

<?php
include('config.php');

try {

// storing the SOAP message in a variable – note that the plain XML code
// is passed here as string for reasons of simplicity, however, it is
// certainly a good practice to build the XML e.g. with DOM – furthermore,
// when using special characters, you should make sure that the XML string
// gets UTF-8 encoded (which is not done here):
$body = '<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
        <SOAP-ENV:Header />
        <SOAP-ENV:Body>
            <ipgapi:IPGApiOrderRequest
            xmlns:v1="http://ipg-online.com/ipgapi/schemas/v1"
            xmlns:ipgapi="http://ipg-online.com/ipgapi/schemas/ipgapi">
            <v1:Transaction>
                <v1:CreditCardTxType>
                    <v1:Type>postAuth</v1:Type>
                </v1:CreditCardTxType>
                <v1:Payment>
                    <v1:ChargeTotal>50.00</v1:ChargeTotal>
                    <v1:Currency>484</v1:Currency>
                </v1:Payment>
                <v1:TransactionDetails>
                    <v1:OrderId>WQWE:13:1693215868:FSR</v1:OrderId>
                </v1:TransactionDetails>
            </v1:Transaction>
            </ipgapi:IPGApiOrderRequest>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>';
// initializing cURL with the IPG API URL:
$ch = curl_init("https://test.ipg-online.com/ipgapi/services");
// setting the request type to POST:
curl_setopt($ch, CURLOPT_POST, 1);


// setting the content type:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
// setting the authorization method to BASIC:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// supplying your credentials:
curl_setopt($ch, CURLOPT_USERPWD, USER_ID.":".USER_PASSWORD);
// filling the request body with your SOAP message:
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);


// telling cURL to verify the server certificate:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// setting the path where cURL can find the certificate to verify the
// received server certificate against:
// curl_setopt($ch, CURLOPT_CAINFO, "tlstrust.pem");

// setting the path where cURL can find the client certificate:
curl_setopt($ch, CURLOPT_SSLCERT, "WS6239488580010._.1.pem");
// setting the path where cURL can find the client certificate’s
// private key:

curl_setopt($ch, CURLOPT_SSLKEY, "WS6239488580010._.1.key");
// setting the key password:
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, CERTIFICATE_PASSWORD);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
ob_start();

$response = curl_exec($ch);

$xmlResponse = ob_get_clean();

$clean_xml = str_ireplace(['SOAP-ENV:', 'SOAP:', 'ipgapi:'], '', $xmlResponse);


$xml = simplexml_load_string($clean_xml);

echo "<pre>";
print_r($xml); 

curl_close($ch);

} catch (Exception $e) {
    echo $e->getMessage();
}

?>

NOTE: Kindly replace ORDER ID, PRICE and CURRENCY accordingly.

Void: Below is the code example to Void a transaction.

<?php
include('config.php');

try {

// storing the SOAP message in a variable – note that the plain XML code
// is passed here as string for reasons of simplicity, however, it is
// certainly a good practice to build the XML e.g. with DOM – furthermore,
// when using special characters, you should make sure that the XML string
// gets UTF-8 encoded (which is not done here):
$body = '<?xml version="1.0" encoding="UTF-8"?>
            <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
                <SOAP-ENV:Header />
                <SOAP-ENV:Body>
                    <ipgapi:IPGApiOrderRequest
                    xmlns:v1="http://ipg-online.com/ipgapi/schemas/v1"
                    xmlns:ipgapi="http://ipg-online.com/ipgapi/schemas/ipgapi">
                    <v1:Transaction>
                        <v1:DE_DirectDebitTxType>
                            <v1:Type>void</v1:Type>
                        </v1:DE_DirectDebitTxType>
                        <v1:TransactionDetails>
                            <v1:IpgTransactionId>84523118055</v1:IpgTransactionId>
                        </v1:TransactionDetails>
                    </v1:Transaction>
                    </ipgapi:IPGApiOrderRequest>
                </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>';
// initializing cURL with the IPG API URL:
$ch = curl_init("https://test.ipg-online.com/ipgapi/services");
// setting the request type to POST:
curl_setopt($ch, CURLOPT_POST, 1);


// setting the content type:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
// setting the authorization method to BASIC:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// supplying your credentials:
curl_setopt($ch, CURLOPT_USERPWD, USER_ID.":".USER_PASSWORD);
// filling the request body with your SOAP message:
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);


// telling cURL to verify the server certificate:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// setting the path where cURL can find the certificate to verify the
// received server certificate against:
// curl_setopt($ch, CURLOPT_CAINFO, "tlstrust.pem");

// setting the path where cURL can find the client certificate:
curl_setopt($ch, CURLOPT_SSLCERT, "WS6239488580010._.1.pem");
// setting the path where cURL can find the client certificate’s
// private key:

curl_setopt($ch, CURLOPT_SSLKEY, "WS6239488580010._.1.key");
// setting the key password:
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, CERTIFICATE_PASSWORD);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
ob_start();

$response = curl_exec($ch);

$xmlResponse = ob_get_clean();

$clean_xml = str_ireplace(['SOAP-ENV:', 'SOAP:', 'ipgapi:'], '', $xmlResponse);


$xml = simplexml_load_string($clean_xml);

echo "<pre>";
print_r($xml); 

curl_close($ch);

} catch (Exception $e) {
    echo $e->getMessage();
}

?>

NOTE: Kindly change the TRANSACTION ID accordingly.

Fore more details you can go through the documentation by vising this link. Documentation Here

PRODUCTION ENVIRONMENT
Change https://test.ipg-online.com/ipgapi/services to https://www2.ipg-online.com/ipgapi/services

Leave a Reply

Your email address will not be published. Required fields are marked *