Sandbox

Card on your own form

PCI DSSJSON v3 · XML 2.9OpenAPI

How to test the merchant-collected card scenario (PCI DSS) in the sandbox: test cards, binding and charging by contract.

Normally the payer enters the card on the i-Free payment page (undefined_bank_card / UndefinedBankCardCustomer). In this scenario the merchant collects the card on its own form and sends the card details to the API: in JSON v3 — customer.type = bank_card and the customer.bank_card block, in XML — <BankCardCustomer> with a <BankCard> block.

Card details are sent when binding the card (creating a contract). Later charges go by contract. In production the scenario is available only to a PCI DSS merchant and is accepted on a dedicated host. The full scenario is described in the Merchant payment form guide.

How the sandbox differs from production

WhatIn the sandbox
HostThere is no separate PCI DSS contour host: card details are accepted on the sandbox main address
CertificationNot required. But never send real cards
Card numberOnly test numbers are accepted: 16 digits starting with 1111, e.g. 1111222233334444. Any other number is rejected (400 in JSON, ResultCode 200 in XML)
StorageOnly the last 4 digits of the number are stored. security_code / SecurityCode is not stored anywhere. In the request log the PAN is masked and the CVC is removed
Contract confirmationNo PIN needed: AuthorizationType = SKIP
MoneyNot charged

Test cards

NumberResult
1111222233334444 and any other 1111…Success
1111…0001Declined: insufficient funds (code 205)
1111…0002Declined: card blocked (206)
1111…0003Declined: limit exceeded (207)
1111…0004Declined: rejected by the bank (208)
1111…0005Declined: card expired (209)

The outcome is set by the last 4 digits of the number. Binding a card with these endings succeeds; the decline comes on the subsequent charge.

JSON v3 scenario

The signature is the same as for other JSON v3 requests (X-Login, X-Timestamp, X-Signature). The sandbox accepts X-Signature-Version: 3 and 4.

Step 1. Bind the card

POST /api/v3/projects/{project_id}/contracts
{  "client_ip": "127.0.0.1",  "customer": {    "type": "bank_card",    "source": "app",    "country": "RU",    "merchant_customer_id": "CUSTOMER-000000001",    "email": "test@test.com",    "bank_card": {      "pan": "1111222233334444",      "expiration_month": "12",      "expiration_year": "2030",      "security_code": "123",      "cardholder": "IVAN IVANOV"    }  },  "contract": {    "merchant_contract_id": "CONTRACT-000000001"  }}

Expected response — 201: contract_id, authorization_type: SKIP, expires_at, merchant_contract_id. The response contains no card details.

Step 2. Charge by contract

POST /api/v3/projects/{project_id}/invoices
{  "client_ip": "127.0.0.1",  "customer": { "type": "bank_card", "merchant_customer_id": "CUSTOMER-000000001" },  "order": {    "merchant_order_id": "ORDER-000000001",    "price": { "amount": "100.00", "currency": "RUB", "vat_included": true }  },  "contract": { "merchant_contract_id": "CONTRACT-000000001" }}

What happens depends on the project setting card_3ds_enabled (on by default):

  • 3-D Secure on. The response has authorization.type = AUTH_PAGE and authorization.url. Open the link and enter any 4 digits: the payment completes and a callback is sent.

  • 3-D Secure off. The payment is processed immediately: authorization.type = BY_CONTRACT, no link, the status is final.

For a card ending in 0001–0005 the payment ends with a decline with the matching code.

Bind and charge in one request

Send the customer.bank_card block and contract.create_if_not_exists: true in POST /invoices. The contract is created together with the invoice.

XML 2.9 scenario

Headers when sending a card: SignatureVersion: 4, Callisto-Protocol-Version: 2 (as described in the specification; the sandbox also accepts signature version 3).

Step 1. Bind the card

CreateCustomerContract
<Request>  <Header>    <Authentication>      <Login>demo_login</Login>      <NowUtc>20260831200008</NowUtc>      <Signature>…</Signature>    </Authentication>    <RequestAttempt>0</RequestAttempt>  </Header>  <CreateCustomerContractRequest>    <ProjectID>1001</ProjectID>    <ClientIP>10.20.30.40</ClientIP>    <BankCardCustomer>      <Source>shop</Source>      <Country>ru</Country>      <MerchantCustomerId>client_id</MerchantCustomerId>      <Email>test@test.com</Email>      <BankCard>        <PAN>1111222233334444</PAN>        <ExpirationMonth>08</ExpirationMonth>        <ExpirationYear>28</ExpirationYear>        <SecurityCode>123</SecurityCode>        <Cardholder>IVANOV IVAN</Cardholder>      </BankCard>    </BankCardCustomer>    <CustomerContractInfo>      <MerchantContractID>1234567890</MerchantContractID>    </CustomerContractInfo>  </CreateCustomerContractRequest></Request>

Response: ResultCode 0, ContractID, AuthorizationType SKIP, ExpirationTimeUtc. Without the <BankCard> block the request is processed as a regular one, outside this scenario.

Step 2. Charge by contract

CreateInvoice — CreateInvoiceRequest body
<CreateInvoiceRequest>  <ProjectID>1001</ProjectID>  <ClientIP>10.20.30.40</ClientIP>  <BankCardCustomer>    <Source>shop</Source>    <Country>ru</Country>    <MerchantCustomerId>client_id</MerchantCustomerId>    <Email>test@test.com</Email>  </BankCardCustomer>  <CustomerContractInfo>    <MerchantContractID>1234567890</MerchantContractID>  </CustomerContractInfo>  <InvoiceInfo>    <MerchantOrderID>ORDER-1</MerchantOrderID>    <CustomerPrice amount="100.00" currency="RUB" includingVAT="true"/>  </InvoiceInfo></CreateInvoiceRequest>

The response carries CustomerContractInfo. With 3-D Secure on, AuthorizationInfo/AuthorizationUrl holds the confirmation page link: enter any 4 digits. To create the contract together with the invoice, pass the CreateIfNotExists=true flag and the <BankCard> block in CustomerContractInfo.

Checking errors

What to doExpected result
A number not starting with 1111 or not 16 digitsJSON 400 BAD_REQUEST with the field list in error.details.fields; XML ResultCode 200
Wrong month, year or security codeJSON 400 BAD_REQUEST naming the field
Bind an active merchant_contract_id againJSON 409 CONTRACT_ALREADY_EXISTS with details.contract_id; XML 230 with ContractID in the description
Charge by a non-existent contractJSON 404 CONTRACT_NOT_FOUND; XML 232
JSON: binding without merchant_contract_id400 BAD_REQUEST: this scenario always works through contracts
A card ending in 0001–0005 on chargeDeclined with code 205–209

After a contract is cancelled, the same merchant_contract_id can be bound again.

Callbacks and retention

Payment notifications are sent as in other scenarios (for projects with public demo credentials the callback address is passed in test_info.callback_url / <CallbackUrl>). Data and logs are kept for 10 days, after which the contract can no longer be found.