Zebec Network 백서

Zebec Network

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 20쪽 중 13쪽

lygon | `POLYGON` | EVM top-ups. | | Zano | `ZANO` | The current card token is FUSD with four decimal places. Use the token address and decimals returned by the programs endpoint. | | Canton | `CANTON` | Canton top-ups use the Canton signature scheme. | Availability is partner-specific. Do not hardcode a chain, token address, or token precision; use the accepted tokens returned by the programs endpoint for the authenticated partner. ## Endpoint summary | Method | Path | Purpose | | ------ | -------------------------------- | ---------------------------------------------------------- | | POST | `/partner/v1/auth/otp/send` | Send an OTP to a user email | | POST | `/partner/v1/auth/otp/verify` | Verify OTP and get a delegation token | | POST | `/partner/v1/auth/token/refresh` | Refresh an unexpired delegation token | | GET | `/partner/v1/cards` | Get card metadata (no PAN/CVV) | | GET | `/partner/v1/cards/transactions` | List card transactions | | GET | `/partner/v1/topup/programs` | Discover available Carbon programs, currencies, and tokens | | GET | `/partner/v1/topup/quote` | Build a top-up quote (2-minute TTL) | | POST | `/partner/v1/topup/preflight` | Run preflight checks against a live quote | | POST | `/partner/v1/topup` | Submit a signed top-up against a quote | | GET | `/partner/v1/topup/{orderId}` | Poll top-up status | ## Guides * [Authentication](/developer-docs/partner-api/authentication) * [Cards](/developer-docs/partner-api/cards) * [Top-up flow](/developer-docs/partner-api/topup-flow) ## Getting access Partner API credentials are issued by Zebec admin. Contact your Zebec partner engineer or <support@zebec.io> to request access. # Authentication Authentication and request signing for the Zebec Partner API. Partner v1 uses two auth modes: * **OTP endpoints** (`/partner/v1/auth/otp/*`) use HMAC-SHA256 with a partner credential issued by Zebec admin. * **Cards and top-up endpoints** use `Authorization: Bearer <accessToken>`, where the token is returned by `POST /partner/v1/auth/otp/verify`. ## HMAC headers for OTP endpoints | Header | Value | | --------------- | ----------------------------------------------------------- | | `X-Partner-Key` | Public key ID, e.g. `pk_live_…` | | `X-Timestamp` | Request time in Unix milliseconds (server tolerates ±5 min) | | `X-Nonce` | UUID, unique per request — replay-protected for 10 min | | `X-Signature` | Hex `HMAC_SHA256(secret, stringToSign)` | ### stringToSign ``` stringToSign = `${timestamp}\n${METHOD}\n${path}\n${sha256Hex(rawBody)}` ``` * `path` is the full request path including the query string, e.g. `/partner/v1/topup/quote?amount=100&sourceChain=SOLANA`. * The body is hashed, not included raw, so signatures stay stable for any payload size. * Empty body uses `sha256Hex('')`. ## Delegated bearer tokens After verifying the OTP, the response contains an access token. * Carry the token as `Authorization: Bearer <accessToken>`. * Tokens expire after **one hour** (`expiresIn: 3600`). * Tokens carry the partner, API key, user, and `partner-delegated` scope claims. * The user is always derived from the token, not supplied in partner requests. ## Scopes API keys carry a scope set; endpoints declare what they need: | Scope | Allows | | ------------- | ----------------------------------------------------- | | `auth:otp` | Send / verify end-user OTP, mint delegation tokens | | `cards:read` | Read card metadata + transactions, poll top-up status | | `cards:topup` | Quote and submit a Carbon card top-up | Missing scope → `403`. Bad signature / replay / stale timestamp → `401`. Cross-partner reads → `404` (anti-enumeration). ### Verify OTP and refresh a token ```bash curl -X POST https://api.superapp.zebec.io/partner/v1/auth/otp/verify \ -H "X-Partner-Key: pk_live_..." \ -H "X-Timestamp: 1717339200000" \ -H "X-Nonce: 018f4b24-9f2c-7d2d-9c07-2d5d0f2f2a11" \ -H "X-Signature: <hmac-signature>" \ -H "Content-Type: application/json" \ -d '{"email":"user@example.com","code":"123456"}' ``` ```json { "accessToken": "eyJhbGciOiJIUzI1NiIs...", "tokenType": "Bearer", "expiresIn": 3600, "scope": "partner-delegated", "userId": "2f6c3b2e-4d5e-4a70-9e3b-8d2a1b4c5d6e", "isNewUser": false } ``` Refresh before the one-hour expiry (for example, when less than five minutes remain), or when a request returns `401` because the token is about to expire. The refresh endpoint requires the still-valid token; it cannot revive an expired or revoked session. If the token has expired, send and verify a new OTP. ```bash curl -X POST https://api.superapp.zebec.io/partner/v1/auth/token/refresh \ -H "Authorization: Bearer <accessToken>" ``` ```json { "accessToken": "eyJhbGciOiJIUzI1NiIs<new-token>", "tokenType": "Bearer", "expiresIn": 3600, "scope": "partner-delegated" } ``` Refresh is not a second OTP flow and does not change the delegated user or partner. Store tokens server-side and never expose partner credentials in a browser bundle. ## Example: sending an OTP ```bash curl -X POST https://dev-super.api.zebec.io/partner/v1/auth/otp/send \ -H "X-Partner-Key: pk_live_..." \ -H "X-Timestamp: 1717339200000" \ -H "X-Nonce: 018f4b24-9f2c-7d2d-9c07-2d5d0f2f2a11" \ -H "X-Signature: <hmac-signature>" \ -H "Content-Type: application/json" \ -d '{"email":"user@example.com"}' ``` For request/response schemas, see the [sandbox Swagger UI](https://dev-super.api.zebec.io/api/partner). Production uses the same schema and routes at `https://api.superapp.zebec.io`. The production Swagger UI is not publicly exposed; request the versioned OpenAPI document from your Zebec partner engineer if you need an offline production schema. # Cards Read Carbon card metadata and transactions with the Zebec Partner API. The Cards endpoints let a partner read card metadata and transaction history for users under their partner scope. ## Endpoints ### Get card metadata ```http GET /partner/v1/cards Authorization: Bearer <accessToken> ``` Returns card summary metadata. PAN and CVV are **not** included in the response. Example response: ```json { "id": "660e8400-e29b-41d4-a716-446655440001", "last4": "1234", "expiryMonth": "07", "expiryYear": "2050", "cardType": "carbon", "cardStatus": "ACTIVE", "availableBalance": { "amount": "125.50", "currencyCode": "USD" } } ``` ### List card transactions ```http GET /partner/v1/cards/transactions?page=1&take=10&status=SUCCESS&chain=SOLANA&startDate=2026-01-01&endDate=2026-01-31 Authorization: Bearer <accessToken> ``` Returns a list of card transactions. Example response: ```json { "items": [ { "cardNumber": "************1234", "authDate": "2026-01-14", "postDate": "2026-01-15", "description": "Carbon card top-up", "amount": "100.00", "postAmount": "100.00", "issuingCurrency": "USD", "merchantName": "Zebec", "transactionResult": "Approved", "transactionType": "Credit", "cardHolderAdjustment": "0.00", "code": "00", "reference": "TXN-123456", "transactionTimestamp": "2026-01-14T10:30:00.000Z", "uid": "onbe-transaction-id", "merchantCategoryCode": "4829", "reversed": "false" } ], "page": 1, "take": 10, "itemCount": 42 } ``` `page` is 1-indexed and `take` defaults to 10. The partner read endpoint currently applies `startDate` and `endDate` (ISO dates); omit them to use the default 90-day lookback. The legacy `term=allTime|currentMonth|lastSixMonths|lastYear` parameter can supply the date window. `itemCount` is the total number of transactions returned by the upstream card provider in that window, not the number in the current page. Results are returned in the provider's order. The general card-order DTO also exposes `status`, `cardType`, `chain`, and `order`, but these filters are not applied by `/partner/v1/cards/transactions` today. Do not rely on them for partner reads; filter the returned page in your application or request a future API version that explicitly advertises those filters. ## Errors All errors are JSON. Typical responses are: | HTTP | Example | Meaning | | ---- | -------------------------------------------------------- | ------------------------------------------------------------------- | | 401 | `{ "statusCode": 401, "message": "Unauthorized" }` | Missing/expired token or invalid partner authentication. | | 403 | `{ "statusCode": 403, "message": "Insufficient scope" }` | API key lacks `cards:read`. | | 404 | `{ "statusCode": 404, "message": "Card not found" }` | No Carbon card, or a cross-partner resource (intentionally hidden). | | 429 | `{ "statusCode": 429, "message": "Too Many Requests" }` | Rate limit exceeded; retry with backoff. | Do not retry a `401` with the same token: refresh it while still valid, or restart OTP authentication after expiry. ## Required scope Both endpoints require the `cards:read` scope on your partner API key. ## User resolution The user is derived from the Bearer token returned by `POST /partner/v1/auth/otp/verify`. Do not supply a user identifier in the request path or body. ## Common use cases * Display a user's card status and balance inside your app. * Show recent card activity. * Poll whether a top-up has landed before showing updated balances. For full schemas and example responses, see the [sandbox Swagger UI](https://dev-super.api.zebec.io/api/partner). Production uses the same routes and schema at `https://api.superapp.zebec.io`; production Swagger is private, so request the versioned OpenAPI file from your Zebec partner engineer. # Top-up flow Top up a Carbon card through the Zebec Partner API. This is the shared lifecycle for every token returned by `GET /partner/v1/topup/programs`. The payment itself is chain-specific; use the quote as the authority for the chain, network, token, amount, and payment instructions. For implementation examples, see [EVM](/developer-docs/partner-api/topup-flow/evm), [Solana](/developer-docs/partner-api/topup-flow/solana), [Canton](/developer-docs/partner-api/topup-flow/canton), or [Zano](/developer-docs/partner-api/topup-flow/zano). ## Flow overview 1. Discover the partner's enabled programs and tokens. 2. Request a short-lived quote. 3. Run preflight checks for the wallet that will pay. 4. Send the chain-native payment described by the quote. 5. Sign the quote's canonical signing message and submit the receipt. 6. Poll the returned order until it reaches a terminal state. ## 1. Discover programs ```http GET /partner/v1/topup/programs Authorization: Bearer <accessToken> ``` The response contains the available Carbon programs, target currencies, and the tokens enabled for the authenticated partner. Choose a token, then retain its `chain`, `sourceTokenMint`, and `decimals` for the quote request. Do not hardcode an address, mint, network, or token precision. ```json { "programs": [ { "programId": "carbon-intl", "displayName": "Carbon International", "currencies": ["USD"], "acceptedTokens": [ { "symbol": "USDC", "chain": "SOLANA", "contractAddress": "<token-address-or-mint>", "sourceTokenMint": "<token-address-or-mint>", "decimals": 6, "platformFeePercentage": "0.025" } ] } ], "currencies": { "USD": { "rate": 1, "symbol": "$" } } } ``` ## 2. Build a quote ```http GET /partner/v1/topup/quote?amount=100&currencyCode=USD&sourceChain=<chain>&sourceTokenMint=<token-address-or-mint> Authorization: Bearer <accessToken> ``` Copy `sourceChain` and `sourceTokenMint` from the selected accepted-token entry. A quote is single-use and valid for two minutes; `expiresIn` is its Unix-millisecond expiration time. Save the following values: * `id` — use as `quoteId`. * `cardId`, `requestedAmount`, and `payment` — bind the payment to this quote. * `payment.chain`, `payment.network`, `payment.contractAddress`, `payment.tokenAmount`, and `payment.tokenDecimals` — exact payment inputs. * `signingMessage` — sign this exact, unmodified UTF-8 message after payment. * Any additional rail-specific fields, such as a destination address, payment ID, contract route, or swap data. `payment.tokenAmount` is a base-unit string. Interpret it using `payment.tokenDecimals`, not a token precision stored in your app. ## 3. Preflight Run preflight before submitting a payment. Include the wallet identifier that will send the payment; it must match the receipt submitted later. ```http POST /partner/v1/topup/preflight Authorization: Bearer <accessToken> Content-Type: application/json { "quoteId": "<quote-id>", "amount": { "amount": 100, "currencyCode": "USD" }, "programId": "<program-id>", "receipt": { "deposit": { "buyerAddress": "<paying-wallet-identifier>" } } } ``` Proceed only when `canProceed` is `true`. A `fail` check makes it false; a `warn` is informational. The successful result is tied to the quote, expires with it, and is consumed when the top-up is submitted. ## 4. Send the payment Execute the payment with the user's wallet, using the values returned by the quote. Wait until the wallet reports a confirmed transaction identifier (`txHash`). * **EVM and Solana:** use the Partners Card SDK's `purchaseCard()` method. It selects and submits the quote-authorized card purchase path. * **Canton, Zano, and other supported rails:** use the wallet's native token transfer function, supplying the quote's network, token, destination, and base-unit amount exactly as returned. | Payment rail | Example | | ---------------------------------------- | -------------------------------------------------------------- | | Ethereum, Base, BNB Smart Chain, Polygon | [EVM top-up](/developer-docs/partner-api/topup-flow/evm) | | Solana | [Solana top-up](/developer-docs/partner-api/topup-flow/solana) | | Canton | [Canton top-up](/developer-docs/partner-api/topup-flow/canton) | | Zano | [Zano top-up](/developer-docs/partner-api/topup-flow/zano) | ## 5. Sign and submit After the payment is confirmed, sign the exact `signingMessage` from the quote and submit the receipt. Use the signature scheme appropriate to the quoted chain; the chain examples show the required identifiers and encodings. ```http POST /partner/v1/topup Authorization: Bearer <accessToken> Content-Type: application/json { "quoteId": "<quote-id>", "receipt": { "deposit": { "txHash": "<confirmed-transaction-id>", "buyerAddress": "<paying-wallet-identifier>" } }, "userSignature": { "signature": "<signature-of-signingMessage>", "publicKey": "<signer-public-key-or-wallet-identifier>", "scheme": "<evm|solana|canton|zano>" } } ``` For Canton, include `cantonAlgorithm` when the wallet does not use the default `ed25519` algorithm. The server derives chain and token metadata from the quote, so do not add a client-defined token, network, or payment ID. The endpoint returns `202 Accepted`: ```json { "orderId": "550e8400-e29b-41d4-a716-446655440000", "status": "PENDING", "statusUrl": "/partner/v1/topup/550e8400-e29b-41d4-a716-446655440000" } ``` Submits are idempotent for seven days by `receipt.deposit.txHash`. Reuse the same receipt only to retry an interrupted request; do not use a confirmed transaction for another quote. ## 6. Poll status ```http GET /partner/v1/topup/<orderId> Authorization: Bearer <accessToken> ``` Poll `statusUrl` until the order reaches a terminal status. Do not infer card balance changes from transaction broadcast alone; the top-up completes through the validation and card-provider pipeline. ## Errors and retries * Request a new quote after expiry, a failed preflight, or a failed payment. * Correct a signature or receipt error, then start again with a new quote and preflight because preflight is one-shot. * Retry temporary network failures with the same `txHash`; do not send the payment again until you have confirmed whether it settled. * Treat the partner [sandbox Swagger UI](https://dev-super.api.zebec.io/api/partner) as the source for complete schemas and current error responses. # EVM example Execute a Carbon card top-up from an EVM wallet through the Zebec Partner API. Use this flow for quotes whose `payment.chain` is `ETHEREUM`, `BASE`, `BINANCE`, or `POLYGON`. It applies to the EVM network returned by the quote, not to a network selected from a wallet default. Start with the shared [top-up flow](/developer-docs/partner-api/topup-flow) through preflight. Use the same EVM account for preflight, execution, and the final signature. ## Request and inspect the quote ```http GET /partner/v1/topup/quote?amount=100&currencyCode=USD&sourceChain=BASE&sourceTokenMint=<token-contract> Authorization: Bearer <accessToken> ``` For an EVM quote, inspect `payment.flow`: * `BUY_CARD_DIRECT` — pay the configured Zebec Card contract using the direct USDC purchase route. * `SWAP_AND_BUY` — execute the quote-provided route and card-contract call; the swap output is routed to the card contract. Use the quoted `cardContractAddress`, token amounts, output amounts, and, for a swap, the complete `swapQuote`. A plain ERC-20 transfer is not a valid EVM top-up receipt. ## Execute with the Partners Card SDK The preferred wallet integration is the Partners Card SDK's EVM `purchaseCard()` method. Pass the Partner API quote through the integration adapter together with the user's EVM signer. The adapter must preserve the quote's contract-bound data; it must not rebuild a route or change an amount. ```ts const { receipt } = await partnerCardService.purchaseCard({ amount: quote.sourceAmount, quote: partnerQuoteAdapter.toSdkQuote(quote), token: partnerQuoteAdapter.toSdkToken(quote), cardProgramId: program.programId, recipient, }); const txHash = receipt.hash; ``` `purchaseCard()` selects the direct `buyCardDirect` or quote-provided `swapAndBuy` path. If your integration calls the contract directly, reproduce the exact same quote-authorized path and do not replace it with a transfer. ## Sign and submit Sign the exact `quote.signingMessage` with EIP-191 `personal_sign` semantics, then submit the confirmed transaction hash: ```ts const buyerAddress = await signer.getAddress(); const signature = await signer.signMessage(quote.signingMessage); await partnerApi.submitTopup({ quoteId: quote.id, receipt: { deposit: { txHash, buyerAddress } }, userSignature: { signature, publicKey: buyerAddress, scheme: "evm", }, }); ``` `buyerAddress` must be the address used for preflight and for the contract transaction. Wait for the transaction receipt before submission. # Solana example Execute a Carbon card top-up from a Solana wallet through the Zebec Partner API. Use this flow for a quote whose `payment.chain` is `SOLANA`. Start with the shared [top-up flow](/developer-docs/partner-api/topup-flow) through preflight and use the same wallet public key throughout. ## Request the quote ```http GET /partner/v1/topup/quote?amount=100&currencyCode=USD&sourceChain=SOLANA&sourceTokenMint=<spl-token-mint> Authorization: Bearer <accessToken> ``` Read `payment.network`, `payment.contractAddress`, `payment.tokenAmount`, and `payment.tokenDecimals` from the response. Build and submit the quote-defined SPL-token/card-program transaction with your wallet adapter. Do not convert the quoted base-unit amount with a hard-coded decimal value. ## Execute and confirm The Partners Card SDK exposes `ZebecCardSolanaService.purchaseCard()` for wallet-backed Solana execution. Supply an adapter backed by the user's wallet and preserve the selected token and quote data when adapting the Partner API quote. ```ts const { signature: txHash } = await solanaCardService.purchaseCard({ amount: quote.sourceAmount, quote: partnerQuoteAdapter.toSdkQuote(quote), token: partnerQuoteAdapter.toSdkToken(quote), cardProgramId: program.programId, recipient, userAddress: wallet.publicKey.toBase58(), reloadCardId: quote.cardId, }); ``` Wait for finalization before treating `txHash` as the receipt. If you use a different Solana integration, it must submit the transaction encoded by the quote and retain the finalized transaction signature. ## Sign and submit Sign the U
프로젝트로 돌아가기