• Paysepro documentation
    • Paysepro
    • Payment methods
      • Payment Methods
      • International
      • Europe
      • America
      • Africa
      • Asia
      • Oceania
  • Paysepro Sandbox
  • Payment API
    • API
    • Paysepro class for PHP
  • Payment Notifications
  • Checkout
  • Plugins
    • Plugins
    • Script
    • Woocommerce
    • WHMCS
Payment API

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.

Authentication

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)
email string Email registered on user's account

Get information about available methods

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.

Parameter Required Type Description
uid yes integer user account identifier
mid yes integer user module identifier
cc yes string country code (ISO 3166-2)

GetData Access Example
 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);
    }
?>

Example of 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
                )

        )

)

Response Parameter Reference
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

Error code references
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

To order a payment

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.

Creating a payment code

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:

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
email no email mail of who uses the service

createCode Access example
 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");
?>

JSON response example
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"
}
Error response example
1
2
3
{
    "error":"02",
}

Error Code References
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