Documentation Paysafecard
   Not logged in, click here
TargetPay home TargetPay SEPA ready
Home iDEAL Bancontact SOFORT Banking Mobile Billing 0900 per call Premium SMS Paysafecard



Introduction
How does it work?
Payouts
Ready-to-use
Documentation





Documentation Paysafecard

1. General
This document describes how to handle a Paysafecard payment via TargetPay by using our API. In order to get started you will need some technical knowledge. If you do not personally have technical knowledge and no programmer to help you with this, look at the Plug and pay modules.

1.1 Remarks
To make integration easy for you we added an PHP example at the bottom of this page.

1.2 How the API works in a nutshell.
Payment with Paysafecard works as following:
  1. You call an URL on TargetPay with all the characteristics of the payment, TargetPay returns a link to the checkout page where your visitor will do the payment (see paragraph 2)
  2. After payment, the visitor returns to your site (see paragraph 3
  3. You check with us whether the payment has been successful (see paragraph 4
  4. Upon successful payment you provide the service or product to your customer.

1.3 E-mail notifications
It's possible to receive an E-mail notification for every successful Paysafecard payment. If you want to activate these notifications you can go to the Subaccounts/Layouts page. On this page you press the edit button for the layout code you use, then you can enter your email address and check the Paysafecard checkbox at the bottom of the page.
ATTENTION, also check the order details when you receive an notification e-mail.

2. Requesting an payment page URL
2.1 Request

You can start a transaction by doing a HTTP GET or POST call to:

https://www.targetpay.com/paysafecard/start

Using the following parameters:

Paramter Name Format Example Mandatory
rtloLayoutcodeNumeric12345Yes
descriptionDescriptionAlphanumeric300 creditsYes
amountAmount in Cents (150 = 1,50)Alphanumeric150Yes
useripCustmomer IP adresAlphanumeric123.45.122.89Yes
returnurlCustomer returns to this URLAlphanumerichttp://mysite.com/return.phpYes
reporturlWe will report to this URLAlphanumerichttp://mysite.com/report.phpNo

Parameters explained:
  • rtlo
    The number which we use to tell this is a request from you. See subaccounts.

  • description
    A clear and comprehensible description of the product or service you are delivering to your costumer. Letters and numbers only with a maximum of 32 characters.

  • amount
    The total amount of the payment in cents. The amount has to be between 10 eurocent (enter 10!) and 150 euro (enter 15000!). Its only posible to enter amounts in euro's. Paysafecard supports all European currency and Australian dollars. If a customer uses a Paysafecard that is denominated in a currency other than euro's Paysafecard exchange rates will be used.

  • returnurl
    The URL where your customer waarnaar de bezoeker moet worden verwezen na betaling (see paragraph 3).

  • reporturl
    If you supply this parameter, we will call this URL on your server when the Paysafecard payment has been made succesfully. This will happen even when your customer doesnt press the proceed button after completing the payment. To the report URL we will add two parameters: trxid (orderid) and amount (amount paid). The reporturl will be called with a HTTP POST request. If your report URL is 'www.test.nl/report' we will call: http://www.test.nl/report?trxid=13377159&amount=1000. ATTENTION: do not mix up the reporturl and returnurl. Your customer will never see the reporturl, this is between our servers and yours.

2.2 Resultcodes
If a payment has been succesfully initiated you will recieve the following result:

000000 xxxxxx|yyyyyy
  • xxxxxx : 8 character long transactie ID (Needed for requesting the status of the transaction);
  • yyyyyy : URL where you need to send your customer to.
Example

000000 15641569|https://www.targetpay.com/paysafecard/start?trxid=15641569

You can redirect your customer to the URL with a HTTP 302 response.

If something went wrong you can recieve the following error message's:

TP0001 No layoutcode specified
TP0002 Amount too low
TP0003 Amount too high
TP0004 Invalid or no return URL
TP0006 No description given
TP0007 Invalid or no country
TP0008 Country not supported for Paysafecard
TP0009 Invalid or no user IP given


In case you recieve an error message check if you supplied all the mandatory parameters in the appropiate format. If this is the case please contact TargetPay with the request and error message.


3. Customer gets redirected
When your customer has completed the Paysafecard payment or pressed the cancel button he or she will automaticly be directed to your website (supplied by your in the returnurl parameter). Paysafecard will add an extra parameter called 'ShoppingCartID' containing the transaction ID (trxid). This is the 8 character long transactie ID you recieve when you initiate a payment.
ATTENTION the ShoppingCartID parameter can consist of upper and lower case characters. For example in PHP parameter names are case sensitive by default!


4. Check payment Status
4.1 Request
You can check if payment has been made by doing a call to TargetPay:

https://www.targetpay.com/paysafecard/check

Using the following parameters:

Parameter Name Format Mandatory
rtloLayoutcodeNumericYes
trxidTransaction IDNumericYes
once'already redeemed' message?0 or 1Yes
testTestmode0 or 1No

Toelichting per variabele:
  • rtlo
    The number which we use to tell this is a request from you.

  • trxid
    Transaction ID (8 characters), returned as ShoppingCartID in the returnurl

  • once
    If you enter '1' the check will return the OK status only once. Subsequent requests will return an TP00014 (Already redeemed) error message with time and date of when the OK status was given. If you enter '0' the check will keep giving you an OK status.
    If your having doubts about this parameter we recommend entering 1, this way you know for sure products or services wont be delivered more than once when a customer would press Refresh/F5 repeatedly.

  • test
    If you enter '1' the check will return an OK status no matter what even if payment hasn't been made!


4.2 Resultcode's
If payment is successfull you will recieve the following message:

000000 OK

If payment has not been made, the transaction is unknown or the check has already been done with the once parameter set to '1' you can recieve the following error messages:

TP0010 Transaction not finished, try again later
TP0011 Transaction cancelled by user
TP0012 Transaction not finished and expired
TP0014 Already redeemed at YYYY-MM-DD HH:MM:SS
TP0020 No layoutcode given
TP0021 No transaction ID given
TP0022 No transaction with this ID
TP0023 Layoutcode doesn't match transaction

5. Voorbeelden
5.1 Paysafecard example.
You can copy the example below into a file called PaysafecardExample.php and upload it to your server. You only need to set the parameters in the top of the file to start doing transactions.
<?php
$rtlo=xxxxx;
$description="Paysafecard Example";
$amount=100;
$returnurl="http://yoursite.com/PaysafecardExample.php";
$reporturl="http://yoursite.com/PaysafecardExample.php";

// The returnurl is being called. We have to check the status
if( isset($_GET['ShoppingCartID'])){
  // 000000 OK means success. We can now deliver
  if( ($status = CheckReturnurl( $rtlo,  $_GET['ShoppingCartID'] )) == "000000 OK" ){
    // Set your orderinfo to success
    die( "Status was Successful...<br>Thank you for your order" );
  }
  // In other cases dont deliver.
  else die( $status );
} 
// The reporturl is being called from the targetpay server
elseif ( isset($_POST['trxid']) && isset($_POST['amount']) ){

  HandleReporturl( $_POST['trxid'], $_POST['amount'] );
} else{
  // Here we start with a redirect to Paysafecard
  $redirecturl = StartTransaction( $rtlo, $description, $amount, $returnurl, $reporturl );
  header ("Location: ".$redirecturl);
  die();
}

// Request transaction url and transaction number
function StartTransaction( $rtlo, $description,  $amount, $returnurl, $reporturl){
  $url= "https://www.targetpay.com/paysafecard/start?".
  "rtlo=".$rtlo.
  "&description=".urlencode(substr($description,0,32)).
  "&amount=".$amount.
  "&userip=".urlencode($_SERVER['REMOTE_ADDR']).
  "&returnurl=".urlencode($returnurl).
  "&reporturl=".urlencode($reporturl);
	
  $strResponse = httpGetRequest($url);
  $aResponse = explode('|', $strResponse );
  # Bad response
  if ( !isset ( $aResponse[1] ) ) die('Error' . $aResponse[0] );
 
  $responsetype = explode ( ' ', $aResponse[0] );

  $trxid = $responsetype[1];
  // Add the transaction number to your order
    
  if( $responsetype[0] == "000000" ) return $aResponse[1];
  else die($aResponse[0]);
}

// Status request in the returnurl
function CheckReturnurl($rtlo, $trxid){
  $once=1;
  $test=0; // Set to 1 for testing as described in paragraph 1.3 
  $url= "https://www.targetpay.com/paysafecard/check?".
  "rtlo=".$rtlo.
  "&trxid=".$trxid.
  "&once=".$once.
  "&test=".$test;
  return httpGetRequest($url);
}

// reporturl handler. Change your orderstatus to succes. 
// this call comes from Targetpay. 
// The consumer is not involved here
function HandleReporturl($trxid, $amount ){
  if( substr($_SERVER['REMOTE_ADDR'],0,10) == "89.184.168" ||
  
substr($_SERVER['REMOTE_ADDR'],0,9) == "78.152.58"
){
    // Werk hier uw status bij naar Succesvol.
    //reporturl should return OK to Targetpay.
    die( "OK" );
  }else{
    die("IP address not correct... This call is not from Targetpay");
  }
}

function httpGetRequest($url){
  $ch = curl_init( $url );
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ;
  $strResponse = curl_exec($ch);
  curl_close($ch);
  if ( $strResponse === false ) 
    die("Could not fetch response " . $url );	
  return $strResponse;
}
?>




© TargetPay.com

F.A.Q. | Contact | Network status | Voorwaarden | Cookie Policy | Cookie Instellingen | Privacy | Regulation | Company | Printable version