# BuyCards

> Sell BuyCards gift cards from your own BuyCards account: the API key to make first, how cards are delivered, and what happens when only some cards arrive.

Source: https://shopfa.st/docs/plugins/buycards

The BuyCards plugin sells gift cards from your own BuyCards account. Set it up as described in
[Sell from a supplier](https://shopfa.st/docs/plugins/suppliers); this page is what is particular to BuyCards.

## Before you press Connect

1. At BuyCards, create an **API key** (or reset one). You get an **App ID** and an **API Secret**. The secret is shown
   once, and it is not your website login token.
2. Add **ShopFast's address** (the plugin's **Setup** tab shows it) to that key's IP allow-list, and make sure the key
   is turned on.
3. Save the App ID and the API Secret on the Setup tab.
4. Optional: pick the **currency of BuyCards prices**. BuyCards sends prices without a currency, so ShopFast only shows
   costs and margins once you say which one your account is charged in.

## The catalog

- One item per card value (BuyCards calls it a SKU), named like "Steam Wallet Code · 10 USD", with its price and how
  many BuyCards has.
- The catalog is read again every 2 hours. A card BuyCards has none of is sold out in your store.
- An item's code is BuyCards' product id and SKU id, like `88:1201`. A SKU id on its own works too if you type a code by
  hand.

Before a buyer pays, the plugin asks BuyCards how many of the card are left right now and stops the checkout when there
are too few.

## Orders

- **One BuyCards order per mapped item**, for the whole quantity: three of a card are one order of three.
- **Each card** is delivered as one line: `number · PIN: … · Expires: …`.
- **Slow orders.** When BuyCards is still preparing the cards, ShopFast asks again every 30 seconds at first, then less
  often, for up to 6 hours.
- **BuyCards closes or refunds the order without a card:** ShopFast orders it again, twice at most.
- **Only some cards arrive.** When BuyCards delivers part of an order and refunds the rest, the plugin orders the
  missing cards on their own, up to twice, and never the ones that already arrived. If they still cannot be had, the
  buyer gets the cards that arrived with a note to contact you about the rest. Such a delivery shows fewer codes than
  it ordered under **Deliveries**.
- **BuyCards refuses the order** (not enough balance, no stock): the delivery fails with BuyCards' reason. Fix it and
  use **Order again**.

Every order carries an order number made from ShopFast's own key for that line. If an answer from BuyCards is ever
lost, ShopFast looks the order up by that number instead of buying again.

## Balance

BuyCards can hold several wallets. All of them show on the plugin's Overview. The low-balance alert watches the first
one.
