SolidTrust Pay Integration Guide - Transparent API For Instant Payouts

An Intro | A Quick Start | Parameters List | Result Parameters | Examples | Button Images

An Intro - What is this documentation for?

You may use your SolidTrust Pay account to make payments to other STPay members directly from your website without the need to login to your STPay account. This page gives an explanation on how to create an instant Transparent Payment and the parameters that the API system posts back to your server.

A Quick Start

* NOTE - to use the Transparent API System, you need to first set up the required details in your SolidTrust Pay account. To do so, LOG IN to your STPay account, go to the Merchant Zone and click the Create/Edit API link.

In the fields indicated on the API Creation Page, enter the following:

API Name - (of your choice) required
API password - (of your choice) required
Enable - Yes/No. required
Daily Limit - you may limit the total volume your account can payout daily. required
Notify URL - the URL where payment details are POSTED back so that your script can update your site. required
Server IP - payments will ONLY be accepted from this IP. required

You are only able to have one API enabled in your account at any one time.

You may edit your API as often as you wish. For example, set it to: Enable -> NO when you are not making, or planning to make, any payments.

All payments must go to the following URL:

Your script will capture the details of the username to send to, the amount and any memo. The following example uses two files on your site to make the payment.

The first one is: prepare_stp_pay.php
The second one is: makepayment.php

Here is how to create prepare_stp_pay.php

<form method="post" action="yoursite/makepayment.php"> Pay To<input type=text name="user" />
<input type = hidden name = testmode value = 0>
Amount<input type=text name="amount" />
Currency<input type=text name="currency" value="USD" />
Memo<input type=text name="item_id" />
<input type=image name="cartImage" src="">
<input type=hidden name="udf1" value="Any note that you will receive back as a result parameter" />
<input type=hidden name="udf2" value="[You can put your site member ID here to recognize him/her when the payment is completed]" />
<input type="submit" name="submit" value="Send">

The following is what yoursite/makepayment.php would look like

foreach($_POST as $k=>$v) $$k=urldecode($v);
$urladdress = "";
$api_id = "Your API name";
$api_pwd = "Your API password";
$api_pwd = md5($api_pwd.'s+E_a*');
$data = "user=".$user. "&testmode=".$testmode."&api_id=".$api_id. "&api_pwd=".$api_pwd. "&amount=".$amount."&paycurrency=".$currency."&comments=".$comments."&fee=".$fee."&udf1=".$udf1."&udf2=".$udf2;

// Call STP API

$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"$urladdress");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); //use this to suppress output
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);// tell cURL to graciously accept an SSL certificate
$result = curl_exec ($ch) or die(curl_error($ch));
echo $result;
echo curl_error($ch);
curl_close ($ch);

?> Next Payment click <a href = "prepare_stp_pay.php"> HERE</a>

In the example above, the $result captures the result fields that are returned from the API. You will see the transaction status and the transaction ID. If successful, the variables detailed below will be POSTed to the notify URL contained in your API so that your site can update the details.

In the event of an unsuccessful transaction nothing is posted to your site - an error message is displayed.

Parameters List

Below you can see an explanation of all the parameters that may be used for payment buttons:

Parameter Name Required Details
api_id YES The name you created for your API.
api_pwd YES The password for your API. For additional password security use a site such as to create an md5 password hash. You MUST use the additional salt as above. If your password is mypassword, for example, you would hash mypasswords+E_a* and enter the returned hash as the variable value; this saves the password from being stored in plain text on your server.
user YES The STPay username of your payee.
amount YES The amount you are paying. Do not add any currency signs - use only a number.
example 1: 9.99
example 2: 4
currency YES The currency of the transaction.
Valid Currencies: USD, EUR, GBP, AUD, CAD, NZD,
item_id YES The Item ID, Service or Product Name.
Example: My First Book On Sale
testmode NO Add this parameter and set it to "1" to set a payment button in Test Mode. The button acts as a live one, but no real transactions are made. You may use Test Mode to check your IPN script and see what parameters are sent back to your site when a payment is made or canceled. NOTE - if you do NOT set this parameter, or if you set it to "0", the button WILL be live and real transactions completed.
<input type = hidden name = testmode value = 0>
udf1 .. udf2 NO You may add up to 2 (udf1, udf2) custom parameters. These parameters are sent back to your notify_url unchanged. Use these parameters to track your members, etc.

Result Parameters Sent Back

On a successful payment the result parameters are sent to your notify_url as specified in your API.
Below are all the parameters explained:

Parameter Name Sent Back Details
status Always The status of the payment; one value:
ACCEPTED - successful payment
date Always Date & time of the transaction
tr_id When Payment Is Successful Unique ID for every transaction. You will see this ID in the Details link and in your Transaction History as found in your SolidTrust Pay Member's area.
amount Always The price of the item in your choice of currency(as you have set it in your payment button). This is the actual amount transferred to your account, minus processing fees, when the payment has been successful.
member Always The SolidTrust Pay payee username. (Who you sent funds to)
item_id Always The Item ID, Service or Product Name of what you are selling (as you have set it in your POST variables).
email Always The email address of the payer.
udf1 .. udf2 When Set If you have set any custom parameters to the POST code they will be sent back unchanged.