The Paysepro API is a service that grants developers access to all info about a Payment Module, from its own server.
With such information it is possible to create a personalized UI with all payment methods available in the Module, in order to sell a product or service directly from a website.
First thing to do is to call the API through a URL that you will obtain from section Payment API, which must be done with the following autentication.
The authentication of the accesses to the API must be done by creating a signature of the request with the following parameters:
Parameter | Type | Description |
---|---|---|
uid | integer | Value that identifies user account |
mid | integer | Value that identifies the module referenced in the process |
country | string | Country Code (ISO 3166-2) |
string | Email registered on user's account |
Encryption with the SHA256 algorithm formed by string: uid + mid + country + email.
The encryption secret key must be the user's API KEY. You can get it in the Payment API section of your account.
The signature must be included as the header parameter of the request and the name of the parameter must be "signature".
The getData method helps us to obtain all the available methods for a certain country and about module defined in your account as well as to obtain all the detail and thepayment processing URL.
- Access URL: https://api.paysepro.com/getData.php
- Configuration parameters must be sent by GET
Parameter | Required | Type | Description |
---|---|---|---|
uid | yes | integer | user account identifier |
mid | yes | integer | user module identifier |
cc | yes | string | country code (ISO 3166-2) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <?php $uid=12345; $mid=54321; $country="es"; $email="[email protected]"; $apikey="CTIEP80XO8ZKMQOX"; $url="https://api.paysepro.com/getData.php?uid=$uid&mid=$mid&cc=$country"; $string=$uid.$mid.$country.$email; $signature=hash_hmac("sha256",$string,$apikey); $result=callUrl($url,$signature); print_r(json_decode($result,true)); echo "\n"; function callUrl($url,$signature) { $defaults = array( CURLOPT_POST => 1, CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => true, ); $ch = curl_init(); curl_setopt_array($ch, $defaults); $signature=Array("signature: $signature"); curl_setopt($ch, CURLOPT_HTTPHEADER, $signature); if( ! $result = curl_exec($ch)) trigger_error(curl_error($ch)); curl_close($ch); return($result); } ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | Array ( [error] => 0 [message] => API response -> successful request. [data] => Array ( [error] => 0 [sites] => Array ( [status] => enabled [url] => https://test.com/ ) [modules] => Array ( [price] => 12.00 [status] => enabled [currency] => USD [country] => es [api_ip] => 167.57.38.174 [methods] => Array ( [neosurf] => Array ( [0] => Array ( [method] => neosurf [country] => es [price] => 12.00 [pmin] => 1.00 [pmax] => 1000.00 ) ) [3esteleingreso] => Array ( [0] => Array ( [method] => 3esteleingreso [country] => es [price] => 12.00 [pmin] => 1.00 [pmax] => 1000.00 ) ) [sofort] => Array ( [0] => Array ( [method] => sofort [country] => es [price] => 0.000 [pmin] => 2.00 [pmax] => 500.00 ) ) [bitcoin] => Array ( [0] => Array ( [method] => bitcoin [country] => [price] => 0.000 [pmin] => 1.00 [pmax] => 1000.00 ) ) ) ) [gateway] => Array ( [url] => https://api.paysepro.com/createCode.php ) ) ) |
JSON Key | Description |
---|---|
error | API error codes |
message | API response message |
data | Object with payment information |
gateway | Object with payment information |
url | URL to process payments |
sites | Object with website information |
status | website status |
url | website URL |
modules | Object with payment module information |
price | Price of the payment module |
status | payment module status |
currency | Payment module currency type |
country | code of access country |
api_ip | IP from which the API can be accessed |
methods | Object with payment methods information |
creditcard | Object with information about Credit Card payment method |
method | Name of payment method |
price | transaction amount |
pmin | minimum transaction amount |
pmax | maximum transaction amount |
Code | Description |
---|---|
0 | Successful response |
05 | unknown MID |
06 | unknown UID |
19 | unknown website |
22 | incorrect API KEY |
31 | No data to display |
32 | unknown country code |
40 | incorrect Signature |
It is accessed by the GATEWAY->URL parameter returned in the getData method and allows you to start a payment process to generate an access code to a specific product or service. This access code will be disabled until the customer completes the payment process with the corresponding provider.
Once the payment is completed, the code will be enabled to be used in the URL that was configured as an ACCESS URL in the payment module.
For each customer receiveing a service and paying for it, a unique payment code must be created with the price, country and method configuration.
The following URL must be used to create the code and start the payment process:
- Access URL: https://api.paysepro.com/createCode.php
- Configuration parameters must be sent by POST.
Parameter | Required | Type | Description |
---|---|---|---|
uid | yes | numeric | user account identifier |
mid | yes | numeric | user module indentifier |
type | yes | text | payment method |
cc | yes | text | country code (ISO 3166-2) |
price | yes | numeric | price |
name | no | text | name of the person using the service |
no | mail of who uses the service |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | <?php $uid=12345; $mid=54321; $country="ar"; $email="[email protected]"; $apikey="CTIEP80XO8ZKMQOX"; //Payment array $data=Array( "uid"=>$uid, //USER ID -Value type: integer "mid"=>$mid, //PAYMENT MODULE ID -Value type: integer "type"=>"1arciti", //PAYMENT METHOD -Value type: string "cc"=>$country, //COUNTRY CODE -Value format: ISO 3166-2 format "price"=>2.99, //PRODUCT/SERVICE PRICE -Value type: float "ucode"=>"ABC", //PRODUCT/SERVICE CODE -Value type: string "name"=>"Jack Dalton", //CUSTOMER NAME -Value type: string "email"=>"[email protected]", //CUSTOMER EMAIL ); $string=$uid.$mid.$country.$email; $signature=hash_hmac("sha256",$string,$apikey); $fields=http_build_query($data); $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,"https://api.paysepro.com/createCode.php"); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); $signature=Array("signature: $signature"); curl_setopt($ch, CURLOPT_HTTPHEADER, $signature); $result=curl_exec($ch); curl_close($ch); if($result) { // Decode JSON data $data=json_decode($result); // Convert PHP object to PHP array if(is_object($data)) $data=(array)$data; if(is_array($data)&&count($data)) { if(!$data["error"]&&isset($data["url"])) { // Redirect to Payment Provider FORM header("Location: {$data["url"]}"); exit; } // Print Error code -view Error Codes reference die("Error: {$data["error"]}"); } } // Print Error message die("Error"); ?> |
1 2 3 4 5 6 | { 'code':"AABBCCDDEEFF", 'price':2.99, 'error':0, 'url':"https://api.paysepro.com/pay.php?uid=1&mid=1&method=paypal&country=uy&code=AABBCCDDEEFF" } |
1 2 3 | { "error":"02", } |
The URL of the correct result should be used to redirect the end user so that final payment can be done.
Each payment method adds particular parameters that give the necessary information for it.
Code | Description |
---|---|
0 | Successful response |
01 | Unknown payment method |
02 | empty Email |
03 | empty UID |
04 | empty MID |
05 | unknown MID |
06 | unknown UID |
07 | Disabled account |
08 | Internal Error |
09 | No payment methods enabled |
10 | Payment method selected is disabled |
11 | Incorrect Paysepro access data |
12 | Insufficient balance |
16 | Unknown payment method for the API |
17 | Internal processing error |
18 | Account setup error |
19 | unknown website |
20 | No commission configured |
22 | Incorrect API KEY |
26 | Unknown Referrer |
27 | Disabled IP |
28 | Payment module disabled |
29 | Disabled website |
40 | Incorrect Signature |