One-time payments · Bank cards

Payment widget

Protocol: JSON v3 · XML 2.9OpenAPI

Embeddable SBP widget: SDK, iframe and status.

The widget opens payment in an iframe on your site: the customer chooses SBP or a wallet and confirms. Card details never reach your server.

How to connect

  1. Create an invoice on your server with customer type undefined_bank_card: the customer picks the payment method in the widget.

  2. Pass the invoice id and its token to the browser — the token is required. In production the token is AuthorizationInfo/AuthorizationToken from the XML CreateInvoice response; the platform JSON v3 specification has no token field. In the sandbox JSON v3 the token comes in data.authorization.token. Never send your login and secret to the browser: the invoice token is all the widget needs.

  3. Call SbpWidget.mount(): the SDK inserts an iframe with the amount, QR, countdown and status polling and adjusts its height.

  4. Take the final payment result from the payment.updated webhook: widget callbacks are for the UI.

Create the invoice

POST/api/v3/projects/YOUR_PROJECT_ID/invoicesPRODUCTIONReference ↗
Request
curl -X POST "https://pay-api.digitalspb.com/api/v3/projects/YOUR_PROJECT_ID/invoices" \  -H "Content-Type: application/json" \  -H "X-Login: YOUR_LOGIN" \  -H "X-Timestamp: YOUR_TIMESTAMP" \  -H "X-Signature-Version: 3" \  -H "X-Signature: YOUR_SIGNATURE" \  -d '{  "client_ip": "10.20.30.40",  "customer": {    "type": "undefined_bank_card",    "source": "my_app",    "country": "RU",    "merchant_customer_id": "client_12345",    "email": "test@test.com"  },  "order": {    "merchant_order_id": "order_456",    "price": {      "amount": "20.00",      "currency": "RUB",      "vat_included": true    }  }}'
Read-only example. Runnable examples are available in the Sandbox section.
201
{  "success": true,  "data": {    "invoice_id": "1624505c-0031-00cf-7d54-4cf1ce08cb30",    "status": "created",    "payment_status": "NOT_PAID",    "authorization": {      "type": "BY_CONTRACT",      "is_authorized": true    },    "price": {      "amount": "25.00",      "currency": "RUB",      "vat_included": true    },    "merchant_order_id": "order_123",    "created_at": "2025-03-29T20:00:10Z",    "expires_at": "2025-03-29T22:00:10Z",    "billing_channel": "CPA",    "customer": {      "type": "mobile_phone",      "msisdn": "79600000000",      "country": "RU",      "network": {        "id": 3,        "name": "Beeline"      },      "operator": {        "id": 42,        "name": "Beeline"      }    },    "contract": {      "contract_id": "16449203-0000-009b-a125-351b7bfbd207",      "authorization_type": "SMS_PIN",      "expires_at": "2025-03-29T20:00:08Z",      "merchant_contract_id": "1234567890"    }  }}

Embed code

HTML · production (sandbox: pay-sandbox.digitalspb.com)
<div id="pay"></div><script src="https://pay.digitalspb.com/Card/Sbp/embed.js"></script><script>  var widget = SbpWidget.mount('#pay', {    invoiceId: 'INVOICE_ID',     // from the CreateInvoice response    token: 'INVOICE_TOKEN',      // AuthorizationInfo/AuthorizationToken from the same response (required)    methods: ['sbp', 'alfapay'], // optional: narrow the set of methods    brand: { name: 'My shop', logo: '/logo.png', primary: '#007c91', background: '#ffffff' },    onSuccess: function () { location.href = '/thanks'; },    onFail: function () {},    onExpired: function () {},   // QR expired — create a new invoice    onError: function (error) {}  });  // widget.destroy() — remove the widget from the page</script>
mount() optionWhat to pass
invoiceIdInvoice id from the CreateInvoice response
tokenInvoice token, required — authorizes the widget instead of your login and secret
methodsOptional. Narrows the methods to the listed codes (sbp, alfapay …): an array or a comma-separated string. Never adds methods the shop does not have. If the intersection is empty, the widget shows all available methods and calls onError
webviewOptional. true — the widget is open in the shop app WebView. Without it the widget detects the environment itself, less accurately, and the bank hand-off depends on it
brandLook: name, logo, primary, background, textColor
pollfalse turns status polling off; on by default
onSuccess, onFailPayment succeeded / failed
onExpiredQR expired — create a new invoice
onErrorWidget error

mount() returns an object with destroy(). The set and order of methods come from the server, from the shop settings; with a single method there is no choice screen. The SDK accepts iframe messages only from its own frame and only from the payment domain origin.