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:

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'. Please 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/paystation2/?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/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.

EventDescription
show-error-pageDisplaying an error. The error text is passed in 'value'.
open-{state_name}Opening a page in the payment UI.
create-invoiceCreating an invoice on the Xsolla's side.
close-widgetClosing the payment UI.
click-email-submitSending an email from the status page.
click-custom-package-continueClicking the Continue button when buying an arbitrary amount of virtual currency.
click-commentClicking the button to post a comment.
click-buy-packageClicking the Buy Package button when buying a package of virtual currency.
click-buy-gift-packageClicking the button when buying a package of virtual currency as a gift.
click-buy-gift-custom-packageClicking the button when buying an arbitrary amount of virtual currency as a gift.
click-btn-shareClicking the button to share via a social network. The social network name is passed in 'value'.
click-btn-payClicking the Pay Now button on the billing data entry form.
click-btn-continueClicking the button to buy the subscription.
click-btn-applyClicking the Apply button when redeeming a coupon.
click-btn-activateClicking the Activate button when activating a game key.
click-btn-acceptClicking the button to buy digital content.
choose-payment-widgetClicking on the payment method widget. The widget name is passed in 'value'.
choose-methodSelecting the payment method. The payment method name is passed in 'value'.
change-statusChanging 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.

ParameterTypeDescription
actionstringEvent name.
valuestringAdditional parameter. Contains specific event parameters that vary depending on the user's choice.
statestringThe payment UI page, on which the action was performed.
datestringDate and time in the GMT format.
millisecondsnumberDate and time in the Unix time format.
timezonestringUser time zone.
session_idstringSession 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_countrystringPayment country.
purchase_invoice_idnumberPayment invoice ID in the Xsolla system.
purchase_external_idstringPayment invoice ID in the partner’s system.
purchase_typestringPurchase type. Can be: 'virtual item', 'virtual currency', 'pay2play', 'subscription'.
purchase_sumnumberNominal purchase amount.
purchase_currencystringPurchase currency.
purchase_skustringSKU of the purchased item.
purchase_digital_content_skustringSKU of the purchased game keys package.
purchase_descriptionstringPurchase description.
virtual_currency_amountnumberVirtual currency amount.
coupon_codestringCoupon code.
subscription_package_external_idnumberSubscription ID.
subscription_package_namestringSubscription name.
subscription_package_descriptionstringSubscription description.
total_sumnumberTotal purchase amount. All fees are included.
total_sum_currencystringTotal purchase amount currency.
user_idstringUser ID (v1).
user_countrystringUser country.
payment_instance_namestringPayment method name.

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

StateDescription
cartPage with the selected item purchased in virtual currency and a purchase confirmation.
couponCoupon entry form.
giftcardPage with the gift cards list (widget Gift Cards).
giftrecipientGift purchase page.
historyPurchase history page.
indexService page, to which the user is redirected after opening the application. It is not shown to the user.
legalMobile version of the page with links to legal documents.
listList of payment methods.
paybycashPage with the list of payment methods for purchasing via cash kiosks (widget Pay with Cash).
paymentPayment form.
paymentaccountPage with the saved payment accounts.
paymentreturnService 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.
pincartPage with the list of digital content platforms.
pricepointVirtual currency store.
savedmethodList of saved payment methods.
shippingaddressDelivery address form.
statusStatus page.
subscriptionSubscription plans store.
subscriptionchangeSubscription plan change.
useraccountAccount information page (username, balance) with Disable confirmation screen for future item purchases setting.
userinventoryUser inventory.
usermenuMobile version of the user menu page.
usersubscriptionUser subscriptions management.
usersubscriptioninfoSubscription details page.
virtualitemVirtual 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:

Card3-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:

Card3-D SecureDescription
Card number: 4000000000000002
Exp. date: 12/40
CVV2: 123
Card type: VISA
NoInsufficient funds
Card number: 5200000000000007
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
NoInsufficient funds
Card number: 4000000000000036
Exp. date: 12/40
CVV2: 123
Card type: VISA
YesDeclined
Card number: 5200000000000031
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
YesDeclined

Errors List

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

ParameterTypeDescription
project_id
integerProject ID.
user_id
integerUser 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}

ParameterTypeDescription
project_id
integerProject ID. Required.
user_id
integerUser ID. Required.
type
stringType of payment account: card / PayPal. Required.
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
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}

ParameterTypeDescription
project_id
integerProject ID.
user_id
integerUser ID.
type
stringType of payment account: card / PayPal.
account_id
integerID 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