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.

Payment UI

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 following script from our CDN: link. Use this URL to integrate the script on your website. For more information please visit our GitHub repository.

Script initialization parameters:

Parameter Type Description
access_token
string Token, received via API. Required.
sandbox
boolean Set to true to test the payment process: sandbox-secure.xsolla.com will be used instead of secure.xsolla.com.
lightbox
object Lightbox parameters (object; desktop version only).
lightbox.width
string Lightbox frame width. If null, depends on Pay Station width. Default is null.
lightbox.height
string Lightbox frame height. If null, depends on Pay Station height. Default is '100%'.
lightbox.zIndex
integer Defines arrangement order. Default is 1000.
lightbox.overlayOpacity
integer Overlay opacity (0 to 1). Default is '.6'.
lightbox.overlayBackground
string Overlay background color. Default is '#000000'.
lightbox.modal
boolean If true, the lightbox frame cannot be closed. Default is 'false'.
lightbox.closeByClick
boolean If true, clicking the overlay will close the lightbox. Default is 'true'.
lightbox.closeByKeyboard
boolean If true, pressing ESC will close the lightbox. Default is 'true'.
lightbox.contentBackground
string Frame background color. Default is '#ffffff'.
lightbox.contentMargin
string Frame margin. Default is '10px'.
lightbox.spinner
string Type of animated loading indicator. Can be 'xsolla' or 'round'. Default is 'xsolla'.
lightbox.spinnerColor
string Spinner color. No default value.
childWindow
object Options for the child window containing the Pay Station UI. Supported in the mobile version.
childWindow.target
string Where 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:

Parameter Description
init Widget initialized.
open Widget opened.
load Payment UI (Pay Station) loaded.
close Payment UI (Pay Station) closed.
status User is on the status page.
status-invoice User is on the status page; payment in progress.
status-delivering Event when the user was moved on the status page, payment was completed, and we're sending payment notification.
status-done User is on the status page; payment credited to the user's account.
status-troubled Event 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/paystation2/?access_token=ACCESS_TOKEN.

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

Notice: Parameter access_token contains private user data. Please make sure that you use server-to-server communication when getting this parameter.
Copy
Full screen
php
  • php
  • html
Asynchronous script loading with a callback
<html>
<head lang="en">
    <meta charset="UTF-8">
</head>
<body>
    <button data-xpaystation-widget-open>Buy Credits</button>

    <?php \Xsolla\SDK\API\PaymentUI\PaymentUIScriptRenderer::send($paymentUIToken, $isSandbox = true); ?>
</body>
</html>
<script>
    var options = {
        access_token: 'abcdef1234567890abcdef1234567890'
    };
    var s = document.createElement('script');
    s.type = "text/javascript";
    s.async = true;
    s.src = "https://static.xsolla.com/embed/paystation/1.0.7/widget.min.js";
    s.addEventListener('load', function (e) {
        XPayStationWidget.init(options);
    }, false);
    var head = document.getElementsByTagName('head')[0];
    head.appendChild(s);
</script>

<button data-xpaystation-widget-open>Buy Credits</button>

Payment UI Events

Payment interface events are processed via the postMessage mechanism when opening Pay Station in an iframe or with Pay Station Embed.

Event Description
show-error-page Displaying an error. The error text is passed in 'value'.
open-{state_name} Opening a page in the payment UI.
create-invoice Creating an invoice on the Xsolla's side.
close-widget Closing the payment UI.
click-email-submit Sending an email from the status page.
click-custom-package-continue Clicking the Continue button when buying an arbitrary amount of virtual currency.
click-comment Clicking the button to post a comment.
click-buy-package Clicking the Buy Package button when buying a package of virtual currency.
click-buy-gift-package Clicking the button when buying a package of virtual currency as a gift.
click-buy-gift-custom-package Clicking the button when buying an arbitrary amount of virtual currency as a gift.
click-btn-share Clicking the button to share via a social network. The social network name is passed in 'value'.
click-btn-pay Clicking the Pay Now button on the billing data entry form.
click-btn-continue Clicking the button to buy the subscription.
click-btn-apply Clicking the Apply button when redeeming a coupon.
click-btn-activate Clicking the Activate button when activating a game key.
click-btn-accept Clicking the button to buy digital content.
choose-payment-widget Clicking on the payment method widget. The widget name is passed in 'value'.
choose-method Selecting the payment method. The payment method name is passed in 'value'.
change-status Changing the payment status. If the user closes the payment UI or leaves the page, and then the status changes, the event message is not sent.

The event parameters are passed in each message from postMessage. If the parameter information has not been collected yet, an empty string will come.

Parameter Type Description
action string Event name.
value string Additional parameter. Contains specific event parameters that vary depending on the user's choice.
state string The payment UI page, on which the action was performed.
date string Date and time in the GMT format.
milliseconds number Date and time in the Unix time format.
timezone string User time zone.
session_id string Session ID. The session includes all user actions performed within 30 minutes or until the payment UI is closed. The session starts from the moment when the payment UI is opened and is saved after the page with the payment UI is refreshed.
payment_country string Payment country.
purchase_invoice_id number Payment invoice ID in the Xsolla system.
purchase_external_id string Payment invoice ID in the partner’s system.
purchase_type string Purchase type. Can be: 'virtual item', 'virtual currency', 'pay2play', 'subscription'.
purchase_sum number Nominal purchase amount.
purchase_currency string Purchase currency.
purchase_sku string SKU of the purchased item.
purchase_digital_content_sku string SKU of the purchased game keys package.
purchase_description string Purchase description.
virtual_currency_amount number Virtual currency amount.
coupon_code string Coupon code.
subscription_package_external_id number Subscription ID.
subscription_package_name string Subscription name.
subscription_package_description string Subscription description.
total_sum number Total purchase amount. All fees are included.
total_sum_currency string Total purchase amount currency.
user_id string User ID (v1).
user_country string User country.
payment_instance_name string Payment method name.

Events are linked to the pages where the user performs all actions when purchasing an item.

State Description
cart Page with the selected item purchased in virtual currency and a purchase confirmation.
coupon Coupon entry form.
giftcard Page with the gift cards list (widget Gift Cards).
giftrecipient Gift purchase page.
history Purchase history page.
index Service page, to which the user is redirected after opening the application. It is not shown to the user.
legal Mobile version of the page with links to legal documents.
list List of payment methods.
paybycash Page with the list of payment methods for purchasing via cash kiosks (widget Pay with Cash).
payment Payment form.
paymentaccount Page with the saved payment accounts.
paymentreturn Service page, to which the user is redirected after the payment is made, and from which the user is sent to the status page. It is not shown to the user.
pincart Page with the list of digital content platforms.
pricepoint Virtual currency store.
savedmethod List of saved payment methods.
shippingaddress Delivery address form.
status Status page.
subscription Subscription plans store.
subscriptionchange Subscription plan change.
useraccount Account information page (username, balance) with Disable confirmation screen for future item purchases setting.
userinventory User inventory.
usermenu Mobile version of the user menu page.
usersubscription User subscriptions management.
usersubscriptioninfo Subscription details page.
virtualitem Virtual items store.


To send events to your Google Analytics and Facebook Analytics accounts, you need to integrate these analytics platforms.

Test Cards List

In the Sandbox you can use these cards to simulate successful payments:

Card 3-D Secure
Card number: 4111111111111111
Exp. date: 12/40
CVV2: 123
Card type: VISA
No
Card number: 5555555555554444
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
No
Card number: 4000000000000010
Exp. date: 12/40
CVV2: 123
Card type: VISA
Yes
Card number: 5200000000000114
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
Yes
Card number: 6759649826438453
Exp. date: 12/40
CVV2: 321
Card type: Maestro
Yes

In addition, you can use the following data to simulate declined transactions:

Card 3-D Secure Description
Card number: 4000000000000002
Exp. date: 12/40
CVV2: 123
Card type: VISA
No Insufficient funds
Card number: 5200000000000007
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
No Insufficient funds
Card number: 4000000000000036
Exp. date: 12/40
CVV2: 123
Card type: VISA
Yes Declined
Card number: 5200000000000031
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
Yes Declined

Errors List

Code Description
0004-0001 Token expired or incorrect.
0004-0008 Wrong URL (trying to access sandbox mode at secure.xsolla.com or live mode at sandbox-secure.xsolla.com).
0002-0004 Agreement not signed.
0004-0010 Tokenless integration prohibited.
0010-0001 Package not found.
0010-0003 Package has no DRM configured.
1000-0003 No modules turned on for the project.
0004-0003 Project ID is not passed.
0004-0009 Invalid JSON of access_data.
0003-0001 Payment is forbidden for the chosen country.
1000-0002 Network error. API response is not received during initialization.
0007-0009 Cannot change the subscription plan via the token. The currency of a new subscription plan is different from the one set for the existing plan.
0004-0002 Digital signature is incorrect.
0005-0001 Error retrieving user data from billing.
1000-0004 No data for the status page received.
1000-0001 Network error. API does not respond.
1004-0001 The subscription plan change is forbidden.
0002-0002 Project does not exist.

Tokenization

Get Saved Accounts

Lists saved payment accounts of a given user.

HTTP REQUEST

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

Parameter Type Description
project_id
integer Project ID.
user_id
integer User ID.
Copy
Full 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.

HTTP REQUEST

POST https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}

Parameter Type Description
project_id
integer Project ID. Required.
user_id
integer User ID. Required.
type
string Type of payment account: card / PayPal. Required.
account_id
integer ID of the saved account in Xsolla database. Required.
user
object User details (object).
user.ip
string User IP address. Required.
user.name
string Username.
purchase
object Object containing purchase details.
purchase.virtual_currency
object Object containing virtual currency details.
purchase.virtual_currency.quantity
float Purchase amount in the virtual currency.
purchase.checkout
object Object containing checkout details.
purchase.checkout.currency
string Currency of the purchase. Three-letter currency code per ISO 4217.
purchase.checkout.amount
float Purchase amount.
settings
object Object containing purchase settings.
settings.mode
string Set to "sandbox" to test out the payment process. Remove the parameter for real payments.
custom_parameters
string Your custom parameters, represented as a valid JSON set of key-value pairs.
Copy
Full 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

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

Parameter Type Description
project_id
integer Project ID.
user_id
integer User ID.
type
string Type of payment account: card / PayPal.
account_id
integer ID of the saved account in Xsolla database.
Copy
Full 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