Getting Started

Overview

This document provides technical specifications for processing financial transactions through Paysafe Solution's payment gateway. We have written this specifically for web designers and professionals who design, implement and support the intended systems. We use HTTPS POST to transmit and receive data.

Please explore our payment gateway through our demonstration account with given test credentials.

Demo Account Credentials

Log on to Paysafe Solution’s Demo Account to explore the payment gateway at www.paymentxp.com. You many verify your transactions processed successfully by using listed credentials or by using any credit card. Data created with test credentials will never hit the credit card networks and are void of costs.

Demo Account
MerchantID 10012
MerchantKey C22A63EE-2E7A-4ACE-96AC-0958DC8D953F
Hosted Payment Key 1QZYRLqw0vbL6gZTinRv+WqfZF/jIrYDALbMppssqHRKKmtatc+kmCIjumfpqipE

Test Credit Card Numbers

Use these test credit card numbers with the Demo Account. Data created with the test credit cards will never hit the credit card networks and are void of costs.

Test Credit Card Numbers
Visa 4111111111111111
MasterCard 5431111111111111
Discover 6011601160116611
American Express 341111111111111
Credit Card Expiration 0615

Create a Sale

A sale can be created in many ways: either by charging a credit card, or debiting from an account using the ACH System.

This operation will charge the credit card. This method performs both authorization and capture into one operation.

Credit Card Charge Example: (C#)

File: Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <P> This sample code is designed to generate a post using PaymentXP's
        Web Host Interface. Response will be displayed on the screen after post method. </P>
        <br />
        <h3>Response:</h3>
        <asp:Label ID="lblResponse" runat="server" Text=""></asp:Label>
        </div>
    </form>
</body>
</html>                            

File: Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Sample credit card charge
        Hashtable prms = new Hashtable();
        prms.Add("TransactionType","CreditCardCharge");
        prms.Add("MerchantID","10012");
        prms.Add("MerchantKey","C22A63EE-2E7A-4ACE-96AC-0958DC8D953F");
        prms.Add("CardNumber","4111111111111111");
        prms.Add("ExpirationDateMMYY","0115");
        prms.Add("TransactionAmount", "19.99");
        prms.Add("BillingNameFirst", "John");
        prms.Add("BillingNameLast","Doe");
        prms.Add("BillingFullName","John Doe");
        prms.Add("BillingAddress","455 Abc Street");
        prms.Add("BillingZipCode","92708");
        prms.Add("BillingCity","Santa Ana");
        prms.Add("BillingState","CA");

        String postdata = string.Empty;
        foreach (DictionaryEntry prm in prms)
        {
            postdata += prm.Key + "=" + prm.Value + "&";
        }
        postdata = postdata.TrimEnd('&');

        //Create Request Object
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentLength = postdata.Length;
        request.ContentType = "application/x-www-form-urlencoded";

        //Post Data
        StreamWriter sw = null;
        sw = new StreamWriter(request.GetRequestStream());
        sw.Write(postdata);
        sw.Close();

        //Get response
        String post_response;
        HttpWebResponse objResponse = (HttpWebResponse)request.GetResponse();
        using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
        {
            post_response = responseStream.ReadToEnd();
            responseStream.Close();
        }

        lblResponse.Text = post_response;
    }
}

Credit Card Charge Example: (Python)

import httplib
import urllib
import urlparse

# establish connection
conn = httplib.HTTPSConnection('webservice.paymentxp.com', 443)

# set parameters
params = urllib.urlencode({
    "CardNumber":'4111111111111111',
    "ExpirationDateMMYY":'0615',
    "MerchantID":'10012',
    "MerchantKey":'c22a63ee-2e7a-4ace-96ac-0958dc8d953f',
    "TransactionAmount":'2.34',
    "TransactionType":'CreditCardCharge',
    "BillingFirstName":"john", #optional
    "BillingLastName":"smith", #optional
    "BillingFullName":"john smith", #optional
    "BillingZipCode":"90210", #optional
    })

# set headers
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain",
           "Content-Length": "%d"%(len(params))}

# post request
conn.request("POST", '/wh/webhost.aspx', params, headers)

# retrieve response
resp = conn.getresponse()

if resp.status == 200 and resp.reason == "OK":

    # parse return value into dictionary
    resp_dict = urlparse.parse_qs(resp.read(), True)

    if str(resp_dict["StatusID"]) == "['0']":
        print "good" # transaction good!
    else:
        print "bad" # invalid transaction, handle accordingly

    conn.close()
else:
    # could not connect
    print "could not connect"

Credit Card Charge Example: (PHP)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML lang='en'>
<HEAD>
    <TITLE> Web Host Sample </TITLE>
</HEAD>
<BODY>
    <P> This sample code is designed to connect to PaymentXP using the Web Host Interface. Response will be displayed on the screen after post method. </P>
    <HR />
    <?PHP
        // Post URL
        $postURL = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Set Post Array
        $postArray = array
        (
            //Post Parameters
            "TransactionType" => "CreditCardCharge",
            "MerchantID" => "10012",
            "MerchantKey" => "C22A63EE-2E7A-4ACE-96AC-0958DC8D953F",
            "CardNumber" => "4111111111111111",
            "ExpirationDateMMYY" => "0115",
            "TransactionAmount" => "19.99",
            "BillingNameFirst" => "John",
            "BillingNameLast" => "Doe",
            "BillingFullName" => "John Doe",
            "BillingAddress" => "455 Abc Street",
            "BillingZipCode" => "92708",
            "BillingCity" => "Santa Ana",
            "BillingState" => "CA",
        );

        //Generate post String
        $postString = "";
        foreach( $postArray as $key => $value )
        { 
            $postString .= "$key=" . urlencode( $value ) . "&"; 
        }
        $postString = rtrim( $postString, "& " );

        // This sample code uses the CURL library for php to establish an HTTP POST
        // To find out if Curl is enabled. Include code below on your page. Then searh for the word Curl.
        // <?php phpinfo(); ?>
        $request = curl_init($postURL); // Initiate
        curl_setopt($request, CURLOPT_HEADER, 0);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($request, CURLOPT_POSTFIELDS, $postString); //HTTP POST
        curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
        $post_response = curl_exec($request); // Execute
        curl_close ($request); // Close

        //Write reponse
        echo $post_response
    ?>
</BODY>
</HTML>

Related Functions:

ACH Sale

ACH Debit Example: (C#)

File: Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <P> This sample code is designed to generate a post using PaymentXP's
        Web Host Interface. Response will be displayed on the screen after post method. </P>
        <br />
        <h3>Response:</h3>
        <asp:Label ID="lblResponse" runat="server" Text=""></asp:Label>
        </div>
    </form>
</body>
</html>                            

File: Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Sample credit card charge
        Hashtable prms = new Hashtable();
        prms.Add("TransactionType","ACHDebit");
        prms.Add("MerchantID","10012");
        prms.Add("MerchantKey","C22A63EE-2E7A-4ACE-96AC-0958DC8D953F");
        prms.Add("RoutingNumber","123456780");
        prms.Add("Amount", "19.99");
        prms.Add("ProcessDate", "12152015");
        prms.Add("Description", "Test Trans");
        prms.Add("BankAccountType", "1");
        prms.Add("ACHCheckType", "1");
        prms.Add("AccountNumber", "123456");
        prms.Add("AccountName", "John Smith");
        

        String postdata = string.Empty;
        foreach (DictionaryEntry prm in prms)
        {
            postdata += prm.Key + "=" + prm.Value + "&";
        }
        postdata = postdata.TrimEnd('&');

        //Create Request Object
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentLength = postdata.Length;
        request.ContentType = "application/x-www-form-urlencoded";

        //Post Data
        StreamWriter sw = null;
        sw = new StreamWriter(request.GetRequestStream());
        sw.Write(postdata);
        sw.Close();

        //Get response
        String post_response;
        HttpWebResponse objResponse = (HttpWebResponse)request.GetResponse();
        using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
        {
            post_response = responseStream.ReadToEnd();
            responseStream.Close();
        }

        lblResponse.Text = post_response;
    }
}

Ach Debit Example: (Python)

import httplib
import urllib
import urlparse

# establish connection
conn = httplib.HTTPSConnection('webservice.paymentxp.com', 443)

# set parameters
params = urllib.urlencode({
    "TransactionType":"ACHDebit",
    "MerchantID":"10012",
    "MerchantKey":"C22A63EE-2E7A-4ACE-96AC-0958DC8D953",
    "RoutingNumber":"123456780",
    "Amount":"19.99",
    "ProcessDate":"12152015",
    "Description":"Test Trans",
    "BankAccountType":"1",
    "ACHCheckType":"1",
    "AccountNumber":"123456",
    "AccountName":"John Smith",
    })

# set headers
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain",
           "Content-Length": "%d"%(len(params))}

# post request
conn.request("POST", '/wh/webhost.aspx', params, headers)

# retrieve response
resp = conn.getresponse()

if resp.status == 200 and resp.reason == "OK":

    # parse return value into dictionary
    resp_dict = urlparse.parse_qs(resp.read(), True)

    if str(resp_dict["StatusID"]) == "['1']":
        print "good" # transaction good!
    else:
        print "bad" # invalid transaction, handle accordingly

    conn.close()
else:
    # could not connect
    print "could not connect"

Credit Card Charge Example: (PHP)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML lang='en'>
<HEAD>
    <TITLE> Web Host Sample </TITLE>
</HEAD>
<BODY>
    <P> This sample code is designed to connect to PaymentXP using the Web Host Interface. Response will be displayed on the screen after post method. </P>
    <HR />
    <?PHP
        // Post URL
        $postURL = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Set Post Array
        $postArray = array
        (
            //Post Parameters
            "TransactionType" => "ACHDebit",
            "MerchantID" => "10012",
            "MerchantKey" => "C22A63EE-2E7A-4ACE-96AC-0958DC8D953",
            "RoutingNumber" => "123456780",
            "Amount" => "19.99",
            "ProcessDate" => "12152015",
            "Description" => "Test Trans",
            "BankAccountType" => "1",
            "ACHCheckType" => "1",
            "AccountNumber" => "123456",
            "AccountName" => "John Smith"
        );

        //Generate post String
        $postString = "";
        foreach( $postArray as $key => $value )
        { 
            $postString .= "$key=" . urlencode( $value ) . "&"; 
        }
        $postString = rtrim( $postString, "& " );

        // This sample code uses the CURL library for php to establish an HTTP POST
        // To find out if Curl is enabled. Include code below on your page. Then searh for the word Curl.
        // <?php phpinfo(); ?>
        $request = curl_init($postURL); // Initiate
        curl_setopt($request, CURLOPT_HEADER, 0);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($request, CURLOPT_POSTFIELDS, $postString); //HTTP POST
        curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
        $post_response = curl_exec($request); // Execute
        curl_close ($request); // Close

        //Write reponse
        echo $post_response
    ?>
</BODY>
</HTML>

Related Functions:

You can refund the entire amount of the original transaction, or a partial amount.

Credit Card Refund Example: (C#)

File: Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <P> This sample code is designed to generate a post using PaymentXP's
        Web Host Interface. Response will be displayed on the screen after post method. </P>
        <br />
        <h3>Response:</h3>
        <asp:Label ID="lblResponse" runat="server" Text=""></asp:Label>
        </div>
    </form>
</body>
</html>                            

File: Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Sample credit card refund
        Hashtable prms = new Hashtable();
        prms.Add("TransactionType","CreditCardCredit");
        prms.Add("MerchantID","10012");
        prms.Add("MerchantKey","C22A63EE-2E7A-4ACE-96AC-0958DC8D953F");
        prms.Add("ReferenceNumber","testref");
        prms.Add("TransactionAmount", "19.99");
        prms.Add("TransactionID","1000000");

        String postdata = string.Empty;
        foreach (DictionaryEntry prm in prms)
        {
            postdata += prm.Key + "=" + prm.Value + "&";
        }
        postdata = postdata.TrimEnd('&');

        //Create Request Object
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentLength = postdata.Length;
        request.ContentType = "application/x-www-form-urlencoded";

        //Post Data
        StreamWriter sw = null;
        sw = new StreamWriter(request.GetRequestStream());
        sw.Write(postdata);
        sw.Close();

        //Get response
        String post_response;
        HttpWebResponse objResponse = (HttpWebResponse)request.GetResponse();
        using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
        {
            post_response = responseStream.ReadToEnd();
            responseStream.Close();
        }

        lblResponse.Text = post_response;
    }
}

Credit Card Capture Example: (Python)

import httplib
import urllib
import urlparse

# establish connection
conn = httplib.HTTPSConnection('webservice.paymentxp.com', 443)

# set parameters
params = urllib.urlencode({
    "ReferenceNumber":'testref',
    "MerchantID":'10012',
    "MerchantKey":'c22a63ee-2e7a-4ace-96ac-0958dc8d953f',
    "TransactionAmount":'19.99',
    "TransactionType":'CreditCardCredit',
    "TransactionID":"1000000",
    })

# set headers
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain",
           "Content-Length": "%d"%(len(params))}

# post request
conn.request("POST", '/wh/webhost.aspx', params, headers)

# retrieve response
resp = conn.getresponse()

if resp.status == 200 and resp.reason == "OK":

    # parse return value into dictionary
    resp_dict = urlparse.parse_qs(resp.read(), True)

    if str(resp_dict["StatusID"]) == "['0']":
        print "good" # transaction good!
    else:
        print "bad" # invalid transaction, handle accordingly

    conn.close()
else:
    # could not connect
    print "could not connect"

Credit Card Capture Example: (PHP)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML lang='en'>
<HEAD>
    <TITLE> Web Host Sample </TITLE>
</HEAD>
<BODY>
    <HR />
    <?PHP
        // Post URL
        $postURL = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Set Post Array
        $postArray = array
        (
            //Post Parameters
            "MerchantID" => "10012",
            "MerchantKey" => "C22A63EE-2E7A-4ACE-96AC-0958DC8D953F",
            "ReferenceNumber" => "testref",
            "TransactionAmount" => "19.99",
            "TransactionID" => "1000000",
            "TransactionType" => "CreditCardSettle"
        );

        //Generate post String
        $postString = "";
        foreach( $postArray as $key => $value )
        { 
            $postString .= "$key=" . urlencode( $value ) . "&"; 
        }
        $postString = rtrim( $postString, "& " );

        // This sample code uses the CURL library for php to establish an HTTP POST
        // To find out if Curl is enabled. Include code below on your page. Then searh for the word Curl.
        // <?php phpinfo(); ?>
        $request = curl_init($postURL); // Initiate
        curl_setopt($request, CURLOPT_HEADER, 0);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($request, CURLOPT_POSTFIELDS, $postString); //HTTP POST
        curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
        $post_response = curl_exec($request); // Execute
        curl_close ($request); // Close

        //Write reponse
        echo $post_response
    ?>
</BODY>
</HTML>

Related Functions:

Add a new Customer

Creates a new customer in the Customer Vault.

Credit Card Charge Example: (C#)

File: Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <P> This sample code is designed to generate a post using PaymentXP's
        Web Host Interface. Response will be displayed on the screen after post method. </P>
        <br />
        <h3>Response:</h3>
        <asp:Label ID="lblResponse" runat="server" Text=""></asp:Label>
        </div>
    </form>
</body>
</html>                            

File: Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Sample credit card charge
        Hashtable prms = new Hashtable();
        prms.Add("TransactionType","AddCustomer");
        prms.Add("MerchantID","10012");
        prms.Add("MerchantKey","C22A63EE-2E7A-4ACE-96AC-0958DC8D953F");
        prms.Add("CardNumber","4111111111111111");
        prms.Add("CardExpirationDate","0115");

        prms.Add("AccountNumber","123456789");
        prms.Add("CustomerName","Test Name");
        prms.Add("RoutingNumber","123465780");
        prms.Add("CustomerID","JaneSmith123");

        String postdata = string.Empty;
        foreach (DictionaryEntry prm in prms)
        {
            postdata += prm.Key + "=" + prm.Value + "&";
        }
        postdata = postdata.TrimEnd('&');

        //Create Request Object
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentLength = postdata.Length;
        request.ContentType = "application/x-www-form-urlencoded";

        //Post Data
        StreamWriter sw = null;
        sw = new StreamWriter(request.GetRequestStream());
        sw.Write(postdata);
        sw.Close();

        //Get response
        String post_response;
        HttpWebResponse objResponse = (HttpWebResponse)request.GetResponse();
        using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
        {
            post_response = responseStream.ReadToEnd();
            responseStream.Close();
        }

        lblResponse.Text = post_response;
    }
}

Credit Card Charge Example: (Python)

import httplib
import urllib
import urlparse

# establish connection
conn = httplib.HTTPSConnection('webservice.paymentxp.com', 443)

# set parameters
params = urllib.urlencode({
    "CardNumber":'4111111111111111',
    "ExpirationDateMMYY":'0615',
    "MerchantID":'10012',
    "MerchantKey":'c22a63ee-2e7a-4ace-96ac-0958dc8d953f',
    "TransactionType":'AddCustomer',
    "CustomerName":'Kate Smith',
    "CustomerID":'KateSmith123',
    "AccountNumber":'123456',
    "RoutingNumber":'12346780',
    
    })

# set headers
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain",
           "Content-Length": "%d"%(len(params))}

# post request
conn.request("POST", '/wh/webhost.aspx', params, headers)

# retrieve response
resp = conn.getresponse()

if resp.status == 200 and resp.reason == "OK":

    # parse return value into dictionary
    resp_dict = urlparse.parse_qs(resp.read(), True)

    if str(resp_dict["StatusID"]) == "['0']":
        print "good" # transaction good!
    else:
        print "bad" # invalid transaction, handle accordingly

    conn.close()
else:
    # could not connect
    print "could not connect"

Credit Card Charge Example: (PHP)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML lang='en'>
<HEAD>
    <TITLE> Web Host Sample </TITLE>
</HEAD>
<BODY>
    <P> This sample code is designed to connect to PaymentXP using the Web Host Interface. Response will be displayed on the screen after post method. </P>
    <HR />
    <?PHP
        // Post URL
        $postURL = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Set Post Array
        $postArray = array
        (
            //Post Parameters
            "TransactionType" => "AddCustomer",
            "MerchantID" => "10012",
            "MerchantKey" => "C22A63EE-2E7A-4ACE-96AC-0958DC8D953F",
            "CardNumber" => "4111111111111111",
            "CardExpirationDate" => "0115",
            "RoutingNumber" => "123456780",
            "AccountNumber" => "123456",
            "CustomerID" => "Doe",
            "CustomerName" => "John Doe",
            
        );

        //Generate post String
        $postString = "";
        foreach( $postArray as $key => $value )
        { 
            $postString .= "$key=" . urlencode( $value ) . "&"; 
        }
        $postString = rtrim( $postString, "& " );

        // This sample code uses the CURL library for php to establish an HTTP POST
        // To find out if Curl is enabled. Include code below on your page. Then searh for the word Curl.
        // <?php phpinfo(); ?>
        $request = curl_init($postURL); // Initiate
        curl_setopt($request, CURLOPT_HEADER, 0);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($request, CURLOPT_POSTFIELDS, $postString); //HTTP POST
        curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
        $post_response = curl_exec($request); // Execute
        curl_close ($request); // Close

        //Write reponse
        echo $post_response
    ?>
</BODY>
</HTML>

Related Functions:

Charge a Customer

Create transactions from saved customers stored in the Customer Vault.

Charge Customer Credit Card Example: (C#)

File: Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <P> This sample code is designed to generate a post using PaymentXP's
        Web Host Interface. Response will be displayed on the screen after post method. </P>
        <br />
        <h3>Response:</h3>
        <asp:Label ID="lblResponse" runat="server" Text=""></asp:Label>
        </div>
    </form>
</body>
</html>                            

File: Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Sample credit card charge
        Hashtable prms = new Hashtable();
        prms.Add("TransactionType","AddCustomerCCCharge");
        prms.Add("MerchantID","10012");
        prms.Add("MerchantKey","C22A63EE-2E7A-4ACE-96AC-0958DC8D953F");
        prms.Add("TransactionAmount", "19.99");
        prms.Add("CustomerID", "TestCustomer");
        

        String postdata = string.Empty;
        foreach (DictionaryEntry prm in prms)
        {
            postdata += prm.Key + "=" + prm.Value + "&";
        }
        postdata = postdata.TrimEnd('&');

        //Create Request Object
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentLength = postdata.Length;
        request.ContentType = "application/x-www-form-urlencoded";

        //Post Data
        StreamWriter sw = null;
        sw = new StreamWriter(request.GetRequestStream());
        sw.Write(postdata);
        sw.Close();

        //Get response
        String post_response;
        HttpWebResponse objResponse = (HttpWebResponse)request.GetResponse();
        using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
        {
            post_response = responseStream.ReadToEnd();
            responseStream.Close();
        }

        lblResponse.Text = post_response;
    }
}

Charge Customer Credit Card Example: (Python)

import httplib
import urllib
import urlparse

# establish connection
conn = httplib.HTTPSConnection('webservice.paymentxp.com', 443)

# set parameters
params = urllib.urlencode({
    "MerchantID":'10012',
    "MerchantKey":'c22a63ee-2e7a-4ace-96ac-0958dc8d953f',
    "TransactionAmount":'2.34',
    "TransactionType":'AddCustomerCCCharge',
    "CustomerID":"TestCustomer", 
    })

# set headers
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain",
           "Content-Length": "%d"%(len(params))}

# post request
conn.request("POST", '/wh/webhost.aspx', params, headers)

# retrieve response
resp = conn.getresponse()

if resp.status == 200 and resp.reason == "OK":

    # parse return value into dictionary
    resp_dict = urlparse.parse_qs(resp.read(), True)

    if str(resp_dict["StatusID"]) == "['0']":
        print "good" # transaction good!
    else:
        print "bad" # invalid transaction, handle accordingly

    conn.close()
else:
    # could not connect
    print "could not connect"

Charge Customer Credit Card Example: (PHP)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML lang='en'>
<HEAD>
    <TITLE> Web Host Sample </TITLE>
</HEAD>
<BODY>
    <P> This sample code is designed to connect to PaymentXP using the Web Host Interface. Response will be displayed on the screen after post method. </P>
    <HR />
    <?PHP
        // Post URL
        $postURL = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Set Post Array
        $postArray = array
        (
            //Post Parameters
            "TransactionType" => "AddCustomerCCCharge",
            "MerchantID" => "10012",
            "MerchantKey" => "C22A63EE-2E7A-4ACE-96AC-0958DC8D953F",
            "TransactionAmount" => "3.44",
            "CustomerID" => "TestCustomerID",
            
        );

        //Generate post String
        $postString = "";
        foreach( $postArray as $key => $value )
        { 
            $postString .= "$key=" . urlencode( $value ) . "&"; 
        }
        $postString = rtrim( $postString, "& " );

        // This sample code uses the CURL library for php to establish an HTTP POST
        // To find out if Curl is enabled. Include code below on your page. Then searh for the word Curl.
        // <?php phpinfo(); ?>
        $request = curl_init($postURL); // Initiate
        curl_setopt($request, CURLOPT_HEADER, 0);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($request, CURLOPT_POSTFIELDS, $postString); //HTTP POST
        curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
        $post_response = curl_exec($request); // Execute
        curl_close ($request); // Close

        //Write reponse
        echo $post_response
    ?>
</BODY>
</HTML>

Create a Recurring Charge

Create recurring transactions

Add Recurring Credit Card Charge: (C#)

File: Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <P> This sample code is designed to generate a post using PaymentXP's
        Web Host Interface. Response will be displayed on the screen after post method. </P>
        <br />
        <h3>Response:</h3>
        <asp:Label ID="lblResponse" runat="server" Text=""></asp:Label>
        </div>
    </form>
</body>
</html>                            

File: Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Sample credit card charge
        Hashtable prms = new Hashtable();
        prms.Add("TransactionType","CreditCardRecurringCharge");
        prms.Add("MerchantID","10012");
        prms.Add("MerchantKey","C22A63EE-2E7A-4ACE-96AC-0958DC8D953F");
        prms.Add("TransactionAmount", "19.99");

        prms.Add("StartDate", "01012014");
        prms.Add("WeekOption", "0");
        prms.Add("WeekdayOption", "0");
        prms.Add("OccurenceOption", "2");
        prms.Add("MonthOfYearOption", "1");
        prms.Add("MonthlyOption", "1");
        prms.Add("DayOfMonthOption", "05");
        prms.Add("CardNumber", "4111111111111111");
        prms.Add("ExpirationDateMMYY", "1216");

        String postdata = string.Empty;
        foreach (DictionaryEntry prm in prms)
        {
            postdata += prm.Key + "=" + prm.Value + "&";
        }
        postdata = postdata.TrimEnd('&');

        //Create Request Object
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentLength = postdata.Length;
        request.ContentType = "application/x-www-form-urlencoded";

        //Post Data
        StreamWriter sw = null;
        sw = new StreamWriter(request.GetRequestStream());
        sw.Write(postdata);
        sw.Close();

        //Get response
        String post_response;
        HttpWebResponse objResponse = (HttpWebResponse)request.GetResponse();
        using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
        {
            post_response = responseStream.ReadToEnd();
            responseStream.Close();
        }

        lblResponse.Text = post_response;
    }
}

Add Recurring Credit Card Charge: (Python)

import httplib
import urllib
import urlparse

# establish connection
conn = httplib.HTTPSConnection('webservice.paymentxp.com', 443)

# set parameters
params = urllib.urlencode({
    "MerchantID":'10012',
    "MerchantKey":'c22a63ee-2e7a-4ace-96ac-0958dc8d953f',
    "TransactionAmount":'2.34',
    "TransactionType":'CreditCardRecurringCharge',
    "StartDate":"01012014",
    "WeekOption":"0",
    "WeekdayOption":"0",
    "OccurenceOption":"2",
    "MonthOfYearOption":"1",
    "MonthlyOption":"1",
    "DayOfMonthOption":"05",
    "CardNumber":"4111111111111111",
    "ExpirationDateMMYY":"1216",
    })

# set headers
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain",
           "Content-Length": "%d"%(len(params))}

# post request
conn.request("POST", '/wh/webhost.aspx', params, headers)

# retrieve response
resp = conn.getresponse()

if resp.status == 200 and resp.reason == "OK":

    # parse return value into dictionary
    resp_dict = urlparse.parse_qs(resp.read(), True)

    if str(resp_dict["StatusID"]) == "['0']":
        print "good" # transaction good!
    else:
        print "bad" # invalid transaction, handle accordingly

    conn.close()
else:
    # could not connect
    print "could not connect"

Add Recurring Credit Card Charge: (PHP)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML lang='en'>
<HEAD>
    <TITLE> Web Host Sample </TITLE>
</HEAD>
<BODY>
    <P> This sample code is designed to connect to PaymentXP using the Web Host Interface. Response will be displayed on the screen after post method. </P>
    <HR />
    <?PHP
        // Post URL
        $postURL = "https://webservice.paymentxp.com/wh/webhost.aspx";

        //Set Post Array
        $postArray = array
        (
            //Post Parameters
            "TransactionType" => "CreditCardRecurringCharge",
            "MerchantID" => "10012",
            "MerchantKey" => "C22A63EE-2E7A-4ACE-96AC-0958DC8D953F",
            "TransactionAmount" => "2.33",
            "StartDate" => "01012014",
            "WeekOption" => "0",
            "WeekdayOption" => "0",
            "OccurenceOption" => "2",
            "MonthOfYearOption" => "1",
            "MonthlyOption" => "1",
            "DayOfMonthOption" => "05",
            "CardNumber" => "4111111111111111",
            "ExpirationDateMMYY" => "1216",
        );

        //Generate post String
        $postString = "";
        foreach( $postArray as $key => $value )
        { 
            $postString .= "$key=" . urlencode( $value ) . "&"; 
        }
        $postString = rtrim( $postString, "& " );

        // This sample code uses the CURL library for php to establish an HTTP POST
        // To find out if Curl is enabled. Include code below on your page. Then searh for the word Curl.
        // <?php phpinfo(); ?>
        $request = curl_init($postURL); // Initiate
        curl_setopt($request, CURLOPT_HEADER, 0);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($request, CURLOPT_POSTFIELDS, $postString); //HTTP POST
        curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
        $post_response = curl_exec($request); // Execute
        curl_close ($request); // Close

        //Write reponse
        echo $post_response
    ?>
</BODY>
</HTML>

Tokenization

When should I use a token?

You should use a token whenever you want to process a transaction, but don't want to handle the sensitive data on your servers.

You'll want to use a Token for all transactions if you want to remove yourself from PCI Scope.

Meritus.js

Meritus.js is the jQuery library that sends the sensitive information to Paysafe, and returns back a single use Token for processing.

NOTE: The token will expire in 20 minutes after initialization.

Credit Card Tokens

Processing a Credit Card transaction with tokens requires the following steps:

Step 1) Collect sensitive information and use Meritus.js to convert that information into a Token (client side)

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Meritus Credit Card Token sample</title>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://webservice.paymentxp.com/js/Meritus.js"></script>


    <script type="text/javascript">
        $(document).ready(function () {

            // attaches a function to the submit event on the form
            $("#form1").submit(function (event) {

                // disable button to prevent multiple clicks
                $('.submit-button').attr("disabled", "disabled");

                // create token
                Meritus.createToken({
                    merchantid: $('.merchantid').val(),
                    cardnumber: $('.cardnumber').val(),
                    cvv2: $('.cvv2').val(),
                    expmonth: $('.expmonth').val(),
                    expyear: $('.expyear').val()
                }, meritusResponseHandler);

                // prevent default action.
                return false;
            });

            // this is the callback function that Meritus.createToken() calls after creating the token
            function meritusResponseHandler(token, statusid) {
                if (statusid != "0") {

                    // show the errors on the form
                    alert("Error: StatusID: " + statusid);

                    // enable button so you can process again.
                    $(".submit-button").removeAttr("disabled");

                } else {

                    // locate our form
                    var myform = $("#form1");

                    // insert our token into our form. we'll be using this to process the transaction
                    myform.append("<input type='hidden' name='Token' value='" + token + "'/>");

                    // for debugging
                    $("#mytoken").text(token);

                    // submit the form
                    myform.get(0).submit();
                }
            }
        });
    </script>

</head>
<body>
    <form id="form1" >
        <div>
            <div>
                <label>MerchantID</label>

                <!-- This is the merchantid issued to you from Meritus. 
                     Use 10012 for testing. -->
                <input type="text" class="merchantid" value="10012" />
            </div>
            <div>
                <label>Card Number</label>

                <!-- notice that there are no "name" attributes. this ensures that 
                     these sensitive values are never communicated back to your 
                     server on postback -->
                <input type="text" size="20" autocomplete="off" 
                       value="4242424242424242" class="cardnumber" />
            </div>
            <div>
                <label>CVV2</label>
                <input type="text" size="4" autocomplete="off" 
                       value="123" class="cvv2" />
            </div>
            <div>
                <label>Expiration (MM/YY)</label>
                <input type="text" size="2" class="expmonth" value="01" />
                <span>/ </span>
                <input type="text" size="4" class="expyear" value="15" />
            </div>
            <button type="submit" class="submit-button">
                Submit Payment
            </button>
        </div>

        <!-- for debugging -->
        <div id="mytoken"></div>

    </form>
</body>
</html>

Step 2) Use that token to process the transaction (server side)

Credit Card Charge Example: (C#)

File: Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "https://webservice.paymentxp.com/wh/webhost.aspx";

        string token = Request["Token"];

        //Sample credit card charge
        Hashtable prms = new Hashtable();
        prms.Add("TransactionType","CreditCardCharge");
        prms.Add("MerchantID","10012");
        prms.Add("MerchantKey","C22A63EE-2E7A-4ACE-96AC-0958DC8D953F");
        prms.Add("Token","token");
        prms.Add("TransactionAmount", "19.99");
        prms.Add("BillingNameFirst", "John");
        prms.Add("BillingNameLast","Doe");
        prms.Add("BillingFullName","John Doe");
        prms.Add("BillingAddress","455 Abc Street");
        prms.Add("BillingZipCode","92708");
        prms.Add("BillingCity","Santa Ana");
        prms.Add("BillingState","CA");

        String postdata = string.Empty;
        foreach (DictionaryEntry prm in prms)
        {
            postdata += prm.Key + "=" + prm.Value + "&";
        }
        postdata = postdata.TrimEnd('&');

        //Create Request Object
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentLength = postdata.Length;
        request.ContentType = "application/x-www-form-urlencoded";

        //Post Data
        StreamWriter sw = null;
        sw = new StreamWriter(request.GetRequestStream());
        sw.Write(postdata);
        sw.Close();

        //Get response
        String post_response;
        HttpWebResponse objResponse = (HttpWebResponse)request.GetResponse();
        using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
        {
            post_response = responseStream.ReadToEnd();
            responseStream.Close();
        }

        lblResponse.Text = post_response;
    }
}

Credit Card Charge Example: (Python)

import httplib
import urllib
import urlparse

# establish connection
conn = httplib.HTTPSConnection('webservice.paymentxp.com', 443)

# NOTE: this all depends on your framework.
token = request.POST.get['token']                            

# set parameters
params = urllib.urlencode({
    "Token":token,
    "MerchantID":'10012',
    "MerchantKey":'c22a63ee-2e7a-4ace-96ac-0958dc8d953f',
    "TransactionAmount":'2.34',
    "TransactionType":'CreditCardCharge',
    "BillingFirstName":"john", #optional
    "BillingLastName":"smith", #optional
    "BillingFullName":"john smith", #optional
    "BillingZipCode":"90210", #optional
    })

# set headers
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain",
           "Content-Length": "%d"%(len(params))}

# post request
conn.request("POST", '/wh/webhost.aspx', params, headers)

# retrieve response
resp = conn.getresponse()

if resp.status == 200 and resp.reason == "OK":

    # parse return value into dictionary
    resp_dict = urlparse.parse_qs(resp.read(), True)

    if str(resp_dict["StatusID"]) == "['0']":
        print "good" # transaction good!
    else:
        print "bad" # invalid transaction, handle accordingly

    conn.close()
else:
    # could not connect
    print "could not connect"

Credit Card Charge Example: (PHP)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML lang='en'>
<HEAD>
    <TITLE> Web Host Sample </TITLE>
</HEAD>
<BODY>
    <P> This sample code is designed to connect to PaymentXP using the Web Host Interface. Response will be displayed on the screen after post method. </P>
    <HR />
    <?PHP
        // Post URL
        $postURL = "https://webservice.paymentxp.com/wh/webhost.aspx";

        $token = $_REQUEST['token'];

        //Set Post Array
        $postArray = array
        (
            //Post Parameters
            "TransactionType" => "CreditCardCharge",
            "MerchantID" => "10012",
            "MerchantKey" => "C22A63EE-2E7A-4ACE-96AC-0958DC8D953F",
            "Token" => $token,
            "TransactionAmount" => "19.99",
            "BillingNameFirst" => "John",
            "BillingNameLast" => "Doe",
            "BillingFullName" => "John Doe",
            "BillingAddress" => "455 Abc Street",
            "BillingZipCode" => "92708",
            "BillingCity" => "Santa Ana",
            "BillingState" => "CA",
        );

        //Generate post String
        $postString = "";
        foreach( $postArray as $key => $value )
        { 
            $postString .= "$key=" . urlencode( $value ) . "&"; 
        }
        $postString = rtrim( $postString, "& " );

        // This sample code uses the CURL library for php to establish an HTTP POST
        // To find out if Curl is enabled. Include code below on your page. Then searh for the word Curl.
        // <?php phpinfo(); ?>
        $request = curl_init($postURL); // Initiate
        curl_setopt($request, CURLOPT_HEADER, 0);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($request, CURLOPT_POSTFIELDS, $postString); //HTTP POST
        curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
        $post_response = curl_exec($request); // Execute
        curl_close ($request); // Close

        //Write reponse
        echo $post_response
    ?>
</BODY>
</HTML>

Related Functions: