> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/dynamic-bin-scheduler/pre-order/assign-saved-card-tappay-token-to-basket.md).

# Assign saved card (TapPay token) to basket

Assigns a saved TapPay card to a basket and returns eligible promotion activations.

**Flow:**

1. Validates token format (`{card_id}||{customer_id}`). Invalid format → returns `[]`.
2. Extracts BIN-6 from `masked_card_number[:6]`.
3. Checks for matching active promotions. No match → clears PreOrder, returns `[]`.
4. Calls TapPay API to resolve the full card (bin\_6, fingerprint).
5. Validates TapPay BIN matches `masked_card_number` prefix. Mismatch → returns `[]`.
6. Creates or updates `PreOrder` and recreates `PreOrderCall` records.

**Token format:** `{card_id}||{customer_id}`, e.g. `"card_E6VV262511||cus_TS03A272"`.

```json
{"openapi":"3.0.3","info":{"title":"Bankaci API","version":"1.0.0"},"tags":[{"name":"PreOrder","description":"Assign a card to a basket and retrieve eligible promotion activations"}],"servers":[{"url":"{BASE_URL}/api/v1","description":"Bankaci API","variables":{"BASE_URL":{"default":"https://your-bankaci-instance.example.com","description":"Base URL of the Bankaci service"}}}],"paths":{"/preorder/saved_card/":{"post":{"tags":["PreOrder"],"summary":"Assign saved card (TapPay token) to basket","description":"Assigns a saved TapPay card to a basket and returns eligible promotion activations.\n\n**Flow:**\n1. Validates token format (`{card_id}||{customer_id}`). Invalid format → returns `[]`.\n2. Extracts BIN-6 from `masked_card_number[:6]`.\n3. Checks for matching active promotions. No match → clears PreOrder, returns `[]`.\n4. Calls TapPay API to resolve the full card (bin_6, fingerprint).\n5. Validates TapPay BIN matches `masked_card_number` prefix. Mismatch → returns `[]`.\n6. Creates or updates `PreOrder` and recreates `PreOrderCall` records.\n\n**Token format:** `{card_id}||{customer_id}`, e.g. `\"card_E6VV262511||cus_TS03A272\"`.\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PreorderSavedCardRequest"}}}},"responses":{"200":{"description":"Eligible promotion activations","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BasketOfferResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}}}}}}},"components":{"schemas":{"PreorderSavedCardRequest":{"type":"object","required":["card_token","masked_card_number","basket_id","basket_modified_date"],"properties":{"card_token":{"type":"string","description":"TapPay card token in the format `{card_id}||{customer_id}`"},"masked_card_number":{"type":"string","description":"Masked card number. Minimum 6 characters. The first 6 characters are used as\nthe BIN-6 prefix for promotion matching. Must match the BIN returned by TapPay.\n","minLength":6},"basket_id":{"type":"integer","description":"Omnitron basket ID"},"basket_modified_date":{"type":"string","format":"date-time","description":"Last modification timestamp of the basket (ISO 8601)"},"currency":{"$ref":"#/components/schemas/CurrencyType"}}},"CurrencyType":{"type":"string","enum":["try","eur","usd","egp","gbp","mad","pln","sar","ron","uah","czk","huf","rub","bgn","iqd","kwd","bhd","omr","qar","aed","ngn","inr","lei","kzt","jod","rsd"],"description":"ISO 4217 currency codes supported by Bankaci"},"BasketOfferResponse":{"type":"object","properties":{"basket_offers":{"type":"array","items":{"$ref":"#/components/schemas/BasketOfferItem"},"description":"Basket offer activations eligible for this card/basket combination.\nEmpty array when no promotions match the card BIN.\n"}}},"BasketOfferItem":{"type":"object","properties":{"basket_offer_id":{"type":"integer","description":"Omnitron BasketOffer ID to activate for this basket"},"session_code":{"type":"string","format":"uuid","description":"Unique session UUID linking this activation to its `PreOrderCall` record.\nUsed internally for usage verification.\n"}}},"ValidationError":{"type":"object","properties":{"detail":{"type":"array","items":{"type":"object","properties":{"loc":{"type":"array","items":{"type":"string"}},"msg":{"type":"string"},"type":{"type":"string"}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://apidocs.akinon.com/commerce-openapis/dynamic-bin-scheduler/pre-order/assign-saved-card-tappay-token-to-basket.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
