Pay Station API v2.0

Overview

The section describes methods for working with Pay Station. Use basic authentication to call methods. To open the payment UI and enable secure payments, you first need to get a token.

Endpoint path: https://api.xsolla.com.

Open Pay Station

Pay Station is a complete payment UI that allows your users to purchase games and items on your website. To easily implement the payment UI on your website, download the script from our CDN. Use this URL to integrate the script on your website. For more information visit our GitHub repository.

Script initialization parameters:

ParameterTypeDescription
access_token
stringToken, received via API. Required.
sandbox
booleanSet to true to test the payment process: sandbox-secure.xsolla.com will be used instead of secure.xsolla.com.
lightbox
objectLightbox parameters (object; desktop version only).
lightbox.width
stringLightbox frame width. If null, depends on Pay Station width. Default is null.
lightbox.height
stringLightbox frame height. If null, depends on Pay Station height. Default is '100%'.
lightbox.zIndex
integerDefines arrangement order. Default is 1000.
lightbox.overlayOpacity
integerOverlay opacity (0 to 1). Default is '.6'.
lightbox.overlayBackground
stringOverlay background color. Default is '#000000'.
lightbox.modal
booleanIf true, the lightbox frame cannot be closed. Default is 'false'.
lightbox.closeByClick
booleanIf true, clicking the overlay will close the lightbox. Default is 'true'.
lightbox.closeByKeyboard
booleanIf true, pressing ESC will close the lightbox. Default is 'true'.
lightbox.contentBackground
stringFrame background color. Default is '#ffffff'. Note that these color changes do not affect the Pay Station iframe itself, only the settings of the lightbox that hold it.
lightbox.contentMargin
stringFrame margin. Default is '10px'.
lightbox.spinner
stringType of animated loading indicator. Can be 'xsolla' or 'round'. Default is 'xsolla'.
lightbox.spinnerColor
stringSpinner color. No default value.
childWindow
objectOptions for the child window containing the Pay Station UI. Supported in the mobile version.
childWindow.target
stringWhere to open the Pay Station window. Can be '_blank', '_self', '_parent'. Default is '_blank'.

The script allows you to track payment UI events. Depending on the event type, you can perform various actions on the web page.

List of events:

ParameterDescription
initWidget initialized.
openWidget opened.
loadPayment UI (Pay Station) loaded.
closePayment UI (Pay Station) closed.
statusUser is on the status page.
status-invoiceUser is on the status page; payment in progress.
status-deliveringEvent when the user was moved on the status page, payment was completed, and we're sending payment notification.
status-doneUser is on the status page; payment credited to the user's account.
status-troubledEvent when the user was moved on the status page, but the payment failed.

If you want to initialize the opening of the payment UI by yourself, use this link: https://secure.xsolla.com/paystation3/?access_token=ACCESS_TOKEN.

Note: It is necessary to use the link with the https:// prefix only for the payment UI opening.

Use the following URL for testing purposes: https://sandbox-secure.xsolla.com/paystation3/?access_token=ACCESS_TOKEN.

Notice: Parameter access_token contains private user data. Make sure that you use server-to-server communication when getting this parameter.

Tokenization

To learn more about setting up tokenization for your app, see the Pay Station documentation.

Get Saved Accounts

Lists saved payment accounts of a given user.

HTTP REQUEST

Copy
Full screen
Small screen

GET https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts

ParameterTypeDescription
project_id
integerProject ID.
user_id
stringUser ID.
Copy
Full screen
Small screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts \
  --header 'authorization: Basic <your_authorization_basic_key> '
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key> '
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key> ");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key> " }

conn.request("GET", "/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key> '

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key> ")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key> ");

xhr.send(data);
Response
[
  {
    "id": 4612345,
    "name": "PP_saved_account",
    "payment_system": {
      "id": 24,
      "name": "PayPal"
    },
    "type": "paypal"
  }
]
[
  {
    "id": 4612345,
    "name": "PP_saved_account",
    "payment_system": {
      "id": 24,
      "name": "PayPal"
    },
    "type": "paypal"
  }
]
[
  {
    "id": 4612345,
    "name": "PP_saved_account",
    "payment_system": {
      "id": 24,
      "name": "PayPal"
    },
    "type": "paypal"
  }
]
[
  {
    "id": 4612345,
    "name": "PP_saved_account",
    "payment_system": {
      "id": 24,
      "name": "PayPal"
    },
    "type": "paypal"
  }
]
[
  {
    "id": 4612345,
    "name": "PP_saved_account",
    "payment_system": {
      "id": 24,
      "name": "PayPal"
    },
    "type": "paypal"
  }
]
[
  {
    "id": 4612345,
    "name": "PP_saved_account",
    "payment_system": {
      "id": 24,
      "name": "PayPal"
    },
    "type": "paypal"
  }
]
[
  {
    "id": 4612345,
    "name": "PP_saved_account",
    "payment_system": {
      "id": 24,
      "name": "PayPal"
    },
    "type": "paypal"
  }
]
[
  {
    "id": 4612345,
    "name": "PP_saved_account",
    "payment_system": {
      "id": 24,
      "name": "PayPal"
    },
    "type": "paypal"
  }
]

Charge With Saved Account

Charges a user via a saved payment account.

Notice: This API method can't be used under high load. When the number of requests is high, rate limits may apply. Contact your Account Manager to find out the rate limits for this API method.

HTTP REQUEST

Copy
Full screen
Small screen
POST https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}
ParameterTypeDescription
project_id
integerProject ID. Required.
user_id
stringUser ID. Required.
type
stringType of payment account. Required.
This parameter can have the following values:
ValueType of payment account
cardBank cards
amazonAmazon Pay
skrillSkrill Digital Wallet
yandexYandex.Money
paymasterwebmoneyWebMoney
paypalPayPal
qiwiQIWI Wallet
If you receive an HTTP 200 success status code, the request returns a transaction ID and its status. Possible statuses:
  • processing — the transaction is in process
  • done — the transaction successfully processed
  • error — an error occurred processing the transaction
  • canceled — the transaction is cancelled
  • held — funds on the user’s account are on hold

If you receive an HTTP 422 error status code, the request returns an error code with its detailed description.

ParameterTypeDescription
account_id
integerID of the saved account in Xsolla database. Required.
user
objectUser details (object).
user.ip
stringUser IP address. Required.
user.name
stringUsername.
purchase
objectObject containing purchase details.
purchase.virtual_currency
objectObject containing virtual currency details.
purchase.virtual_currency.quantity
floatPurchase amount in the virtual currency.
purchase.checkout
objectObject containing checkout details.
purchase.checkout.currency
stringCurrency of the purchase. Three-letter currency code per ISO 4217.
purchase.checkout.amount
floatPurchase amount.
settings
objectObject containing purchase settings.
settings.mode
stringSet to "sandbox" to test out the payment process. Remove the parameter for real payments.
custom_parameters
stringYour custom parameters, represented as a valid JSON set of key-value pairs.
Copy
Full screen
Small screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
POST https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "card": {
    "cvn": "123"
  },
  "purchase": {
    "description": {
      "value": "currency purchase"
    },
    "virtual_currency": {
      "quantity": 100
    }
  },
  "settings": {
    "currency": "USD",
    "external_id": "ext123",
    "save": true
  },
  "user": {
    "id": "user123",
    "name": "John Smith"
  }
}
curl --request POST \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id} \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"user":{"id":"user123","name":"John Smith"},"card":{"cvn":"123"},"purchase":{"virtual_currency":{"quantity":100},"description":{"value":"currency purchase"}},"settings":{"save":true,"currency":"USD","external_id":"ext123"}}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"user":{"id":"user123","name":"John Smith"},"card":{"cvn":"123"},"purchase":{"virtual_currency":{"quantity":100},"description":{"value":"currency purchase"}},"settings":{"save":true,"currency":"USD","external_id":"ext123"}}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"user\":{\"id\":\"user123\",\"name\":\"John Smith\"},\"card\":{\"cvn\":\"123\"},\"purchase\":{\"virtual_currency\":{\"quantity\":100},\"description\":{\"value\":\"currency purchase\"}},\"settings\":{\"save\":true,\"currency\":\"USD\",\"external_id\":\"ext123\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"user\":{\"id\":\"user123\",\"name\":\"John Smith\"},\"card\":{\"cvn\":\"123\"},\"purchase\":{\"virtual_currency\":{\"quantity\":100},\"description\":{\"value\":\"currency purchase\"}},\"settings\":{\"save\":true,\"currency\":\"USD\",\"external_id\":\"ext123\"}}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("POST", "/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"user\":{\"id\":\"user123\",\"name\":\"John Smith\"},\"card\":{\"cvn\":\"123\"},\"purchase\":{\"virtual_currency\":{\"quantity\":100},\"description\":{\"value\":\"currency purchase\"}},\"settings\":{\"save\":true,\"currency\":\"USD\",\"external_id\":\"ext123\"}}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"user\":{\"id\":\"user123\",\"name\":\"John Smith\"},\"card\":{\"cvn\":\"123\"},\"purchase\":{\"virtual_currency\":{\"quantity\":100},\"description\":{\"value\":\"currency purchase\"}},\"settings\":{\"save\":true,\"currency\":\"USD\",\"external_id\":\"ext123\"}}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "user": {
    "id": "user123",
    "name": "John Smith"
  },
  "card": {
    "cvn": "123"
  },
  "purchase": {
    "virtual_currency": {
      "quantity": 100
    },
    "description": {
      "value": "currency purchase"
    }
  },
  "settings": {
    "save": true,
    "currency": "USD",
    "external_id": "ext123"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
    "transaction_id": 123458390
}
{
    "transaction_id": 123458390
}
{
    "transaction_id": 123458390
}
{
    "transaction_id": 123458390
}
{
    "transaction_id": 123458390
}
{
    "transaction_id": 123458390
}
{
    "transaction_id": 123458390
}
{
    "transaction_id": 123458390
}

Delete Saved Account

Deletes a saved payment account.

HTTP REQUEST

Copy
Full screen
Small screen
DELETE https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id}
ParameterTypeDescription
project_id
integerProject ID.
user_id
stringUser ID.
type
stringType of payment account.

This parameter can have the following values:

ValueType of payment account
cardBank cards
amazonAmazon Pay
skrillSkrill Digital Wallet
yandexYandex.Money
paymasterwebmoneyWebMoney
paypalPayPal
qiwiQIWI Wallet
If you receive an HTTP 200 success status code, the request returns a transaction ID and its status. Possible statuses:
  • processing — the transaction is in process
  • done — the transaction successfully processed
  • error — an error occurred processing the transaction
  • canceled — the transaction is cancelled
  • held — funds on the user’s account are on hold

If you receive an HTTP 422 error status code, the request returns an error code with its detailed description.

ParameterTypeDescription
account_id
integerID of the saved account in Xsolla database.
Copy
Full screen
Small screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
DELETE https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id}

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request DELETE \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id} \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id}');
$request->setRequestMethod('DELETE');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id}");
var request = new RestRequest(Method.DELETE);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("DELETE", "/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Delete.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id}")
  .delete(null)
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("DELETE", "https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payment_accounts/{type}/{account_id}");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response