# Charge with saved account

Charges a user via a saved payment account.


  NoteIn sandbox mode, this API call works only with test cards that have no 3-D Secure function.





  NoticeFor the API call to work correctly, configure a timeout of 2 minutes.

Endpoint: POST /projects/{project_id}/users/{user_id}/payments/{type}/{account_id}
Version: 2.0
Security: basicAuth

## Path parameters:

  - `project_id` (integer, required)
    Project ID.

  - `user_id` (string, required)
    Unique user ID in the game stored on your side. Make sure you pass the existing user ID. In case an error occurs, refer to the answers to the FAQs.

  - `type` (string, required)
    Type of payment account.
    Enum: "card", "ais", "alipayplus_boost", "alipayplus_cn", "alipayplus_dana", "alipayplus_gcash", "alipayplus_hk", "alipayplus_kplus", "alipayplus_maya", "alipayplus_rabbitlinepay", "alipayplus_tng", "alipayplus_truemoney", "amazon", "klarna", "mercadopago", "nupay", "paidy", "paypal", "paysafecard_eu", "paysafecard_us", "skrill", "softbank_au", "softbank_docomo", "softbank_paypay", "softbank_softbank2", "softbank_ymobile", "toss"

  - `account_id` (integer, required)
    ID of the saved account in Xsolla database.

## Request fields (application/json):

  - `user` (object)
    User details.

  - `user.ip` (string, required)
    User IP address.

  - `user.name` (string)
    Username.

  - `user.legal` (object)
    Object with legal entity details.

  - `user.legal.name` (string)
    Full legal name.

  - `user.legal.address` (string)
    Full legal address.

  - `user.legal.vat_id` (string)
    Individual taxpayer identifier.

  - `user.legal.country` (string)
    Country of incorporation. Two-letter uppercase country code per [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) is used.

  - `settings` (object)
    Object containing purchase settings.

  - `settings.currency` (string)
    Preferred payment currency. Three-letter currency code per [ISO 4217](https://developers.xsolla.com/doc/pay-station/references/supported-currencies/).

  - `settings.external_id` (string)
    Transaction ID in the game. Has to be unique for each user payment. Refer to documentation for detailed information.

  - `settings.mode` (string)
    Set to sandbox to test out the payment process. Remove the parameter for real payments.

  - `settings.mock_code` (integer)
    An error code that you want to reproduce when testing the payment process via PayPal in sandbox mode. It works correctly only if you pass the "mode":"sandbox" parameter.
    Enum: 1002, 1015, 1039, 1046, 1057, 1089, 1201, 1203, 1801, 1803, 2031, 3006, 3031, 5004

  - `purchase` (object)
    Object containing purchase details.

  - `purchase.description` (object)

  - `purchase.description.value` (string)

  - `purchase.virtual_currency` (object)
    Object containing virtual currency details.

  - `purchase.virtual_currency.quantity` (number)
    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](https://developers.xsolla.com/doc/pay-station/references/supported-currencies/).

  - `purchase.checkout.amount` (number)
    Purchase amount.

  - `custom_parameters` (object)
    This object contains parameters to configure anti-fraud filters. The list of parameters is shown below. To add custom parameters, contact your Customer Success Manager or email at [csm@xsolla.com](mailto:csm@xsolla.com).

  - `custom_parameters.registration_date` (string)
    Account creation date per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).

  - `custom_parameters.total_hours` (integer)
    Total number of in-game hours.

  - `custom_parameters.total_characters` (integer)
    Number of in-game characters.

  - `custom_parameters.social_networks_added` (boolean)
    Whether the player has connected social media profiles.

  - `custom_parameters.profile_image_added` (boolean)
    Whether the player has uploaded a profile image.

  - `custom_parameters.active_date` (string)
    Last seen date per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).

  - `custom_parameters.total_friends` (integer)
    Number of friends.

  - `custom_parameters.additional_verification` (boolean)
    Whether the player uses account verification procedures.

  - `custom_parameters.win_rate` (integer)
    Win rate.

  - `custom_parameters.last_change_password_date` (string)
    Last password change date per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).

  - `custom_parameters.chat_activity` (boolean)
    Whether the player uses the chat function.

  - `custom_parameters.forum_activity` (boolean)
    Whether the player uses the forum function.

  - `custom_parameters.total_bans` (integer)
    Number of times the player was banned in the chat/forum.

  - `custom_parameters.profile_completed` (boolean)
    Whether the player added additional information to their profile.

  - `custom_parameters.notifications_enabled` (boolean)
    Whether the player enabled notifications.

  - `custom_parameters.user_level` (integer)
    Player’s level, reputation, or rank.

  - `custom_parameters.karma_points` (integer)
    Player’s karma.

  - `custom_parameters.total_sum` (number)
    Total amount of payments.

  - `custom_parameters.non_premium_currency` (number)
    Amount of non-premium currency.

  - `custom_parameters.total_game_events` (integer)
    Number of in-game events the player took part in.

  - `custom_parameters.total_gifts` (integer)
    Number of in-game gifts the player has sent/received.

  - `custom_parameters.tutorial_completed` (boolean)
    Whether the player has completed the game’s tutorial.

  - `custom_parameters.completed_tasks` (integer)
    Number of tasks/objectives completed.

  - `custom_parameters.items_used` (boolean)
    Whether the player uses purchased in-game items.

  - `custom_parameters.pvp_activity` (boolean)
    Whether the player takes part in PvP (Player(s) versus player(s)) battles.

  - `custom_parameters.total_clans` (integer)
    Number of clans the player is a member of.

  - `custom_parameters.unlocked_achievements` (integer)
    Number of achievements unlocked.

  - `custom_parameters.total_inventory_value` (number)
    Total inventory value (in-game currency).

  - `custom_parameters.character_customized` (boolean)
    Whether the player has customized their character.

  - `custom_parameters.session_time` (string)
    Average session time per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).

## Response 201 fields (application/json):

  - `transaction_id` (integer)


## Response 422 fields
