docs
/
AI skills

Take payments on the site

Switch on online payment so the site's checkout and payment links take money. Stripe or PayPal connected by the owner, offline pay-later, gift cards as a tender, all tried end to end in test mode before a real customer pays.

The checkout takes money through the business's own payment accounts. Appmint holds no money for it. Each way of paying is a gateway: a config record for one provider (StripeProvider, PayPalProvider, OfflineProvider, …). The checkout asks GET storefront/payment-gateways which ones exist. With none, it shows "Online payment is not available for this store yet. Please contact the store before placing an order."

Card details never touch Appmint's pages: Stripe's own card form and PayPal's own button take them.

Shipping comes first. The checkout shows no payment step until the order has a valid delivery quote. Until then it shows "Delivery quote unavailable … Payment is unavailable until this order has a valid quote", or "Enter your delivery address to see available payment methods." Set shipping up with Shipping rates and settings before anything here.

Ask first

  • How will customers pay? Card (Stripe), PayPal, bank transfer or cash later (offline), gift cards. Several can be on at once.
  • Do they already have a Stripe or PayPal business account? The owner signs in to it to get the keys. The AI never asks for secret keys in chat.
  • Test first? Yes, unless they say otherwise. Test keys take no real money.
  • Should invoices and payment links open on their own site? That needs the site's Payment page (step 5).

Steps

1. Shipping: the checkout can quote

Follow Shipping rates and settings. Then quote one real product to one real address with call_appengine POST shipping/options.

Hands on: a product SKU and an address that quote. Check: served: true with at least one option.

2. Finance › Gateway: connect Stripe

Stop: the secret key unlocks the business's money. The owner enters it on screen. The AI does not ask for it, type it or store it anywhere else.

Send the owner to Finance › Gateway (/finance?tab=gateway). They paste the publishable key (pk_test_… or pk_live_…) and the secret key (sk_… or a restricted rk_…) from Stripe's dashboard, then Save. The screen refuses keys that are the wrong kind, contain a space, or mix test and live. It shows a Test or Live badge read from the key prefix.

Saving writes one config record:

FieldValue
namedefault
providerStripeProvider
typePayment
useCases["Payment", "Subscription"]
statusactive
priority1
publishableKey, secretKeythe keys

Then it runs Test connection (POST upstream/call/StripeProvider/test), a read-only call that answers Connected to Stripe (test mode) or (live mode).

Use Finance › Gateway rather than the Setup wizard's Connect Stripe. The wizard opens a plain record form that checks nothing, and it shows "Success" as soon as a publishable key exists, even with no secret key.

Keep one Stripe record. The checkout uses the first active StripeProvider record it finds, in no set order. Finance › Gateway edits the one with the highest priority. With two records they can disagree, and the shop charges through keys nobody is looking at.

Hands on: test or live, from the badge. Check: call_appengine GET storefront/payment-gateways has a row with data.provider: "StripeProvider" and configured: true. The row carries only public fields: publishableKey, testMode, displayName, never the secret. configured: false means a key is missing.

3. Setup wizard: PayPal, offline (optional)

Open Setup wizard (/setup-wizard), section Get paid.

  • PayPal (payments.paypal). The owner enters the REST app's Client ID (clientId) and Secret (appSecret), and sets sandbox. sandbox is on unless it is set to false. The wizard shows "Sandbox" or "Live".
  • Offline (payments.offline, under advanced). It needs no keys. Saving the record turns on "Place order — pay later" at checkout, for bank transfer, cheque or cash. The order is saved unpaid (status new) for staff to mark paid when the money arrives.

Live PayPal needs sandbox: false. With live credentials and sandbox left unset, the shopper pays on PayPal, but the server checks the payment against the sandbox and the order fails to record.

Offline shows no bank details. merchantName and paymentMethods are saved but not shown. The shopper sees the standard choice and text. Tell customers where to send money in the order email or on the site.

New records made on Integrations (/integration-config) start as status: "inactive". An inactive gateway is never offered. Set it to active.

Hands on: the providers connected. Check: GET storefront/payment-gateways lists one row per provider.

4. Gift cards: a tender, not a gateway

Gift cards need no gateway record. Whenever the payment step shows, checkout has a Gift card box. The shopper enters a code and, if the card has one, its PIN. The quote (POST storefront/discounts/calculate with giftCards: [{ code, pin }]) says what the cards cover and what is left (amountDue). The card form charges only amountDue. When cards cover everything, the button reads "Place order — paid with gift card", with no card payment. Cards are spent when the order is written, not when they are entered.

Cards are issued in Gift cards (/gift-card); selling, sending and managing them is in Gift cards. Messages the shopper may see: "That PIN is not right", "This card has a PIN — enter it to use the card".

Check: with a test gift card, the summary shows the card's amount taken off and the rest due.

Invoices and payment requests carry a pay link. It opens the site's Payment page when the site's Payment feature is on and has a page chosen (Site Features › Payment › Choose page). Otherwise it opens the platform's hosted payment page, which needs no site and no sign-in.

The site's Payment page (default slug pay) takes the link's reference: ?invoiceNumber=, ?ref=, ?order=, or /pay/<ref>. It offers the same gateways, except gateways missing a key, and charges what the server says is owed. A payment request's link is <pay page>?ref=<id>. With no Payment page, making a request answers "No Payment page is configured on the site — set one in Site Config > Site Features."

Stop: turning on a site feature changes the live site. Ask first, and never change a site's features without a yes. See Site page routing for features and their pages.

A Payment feature switched on without a chosen page still answers /pay on the site, but invoice links skip it and use the hosted page. Choose the page. Also, the site's /pay doesn't check the invoice's Enable online payment switch; the hosted page does.

Check: open an invoice's Payment section: its link starts with the site's address and /pay, or with the hosted page.

6. Try it in test mode

Stop: with live keys, a test order takes real money. Try only with test keys, or with the owner's yes for one small real order that they then refund.

  1. Put a real product in the cart on the site and go to /checkout.
  2. Fill in contact and a full delivery address. Wait for the summary's Shipping line.
  3. Payment Method lists each gateway. Pay by card with Stripe's test card 4242 4242 4242 4242, any future expiry and any CVC; PayPal with a sandbox buyer; or Place order — pay later.
  4. The success page shows the order number.

Check:

  • The order opens in Orders (/order?openId=<sk>), paid for card or PayPal, new (unpaid) for offline.
  • The payment shows in Payments (/payment) with the gateway's reference.
  • With test keys, the payment shows in Stripe's dashboard under Test mode.

How the money is checked

  • Stripe. The card form asks the server for a payment intent with the cart's id. The server refuses an amount that isn't the stored cart's total: "The amount to pay no longer matches your cart…". When the order is placed (POST storefront/checkout-cart), the server reads the payment back from Stripe and compares it with the order total. If the order is refused, a Stripe payment not yet recorded is refunded automatically.
  • PayPal. The button creates and captures the PayPal order in the shopper's browser. The server records the amount PayPal reports. It doesn't compare that amount with the cart.
  • Offline. Nothing is charged. The order is saved unpaid.
  • The order starts processing with a payment reference, then becomes paid, or paid-partial when less than the total was paid.

Webhooks. Stripe calls POST <engine address>/connect/webhook/stripe?orgid=<org> for the events it reports (payment succeeded or failed, refunds, disputes, checkout sessions, subscriptions). A successful payment marks the invoice paid, settles a payment request, or moves the order to paid / paid-partial. When the record has a webhookSecret, the signature is checked. Without one, each event is fetched back from Stripe by its id, so a forged event is refused either way. Saving the gateway tries to register the endpoint at Stripe, but nothing stores the endpoint's id or secret, so check in Stripe's dashboard (Developers › Webhooks) that the endpoint exists. Stripe can't reach an engine on a private network, such as a local test engine. PayPal and Helcim events go to /connect/webhook/paypal and /connect/webhook/helcim. They are checked only when webhookId (PayPal) or webhookSecret (Helcim) is set on the record by hand.

Refunds at a glance

Staff refund from the order: POST storefront/order/refund/<orderNumber> with { amount?, reason?, paymentRef?, cashReturned?, operationKey? }. Cash and manual payments are only recorded, and cash needs cashReturned: true. A signed-in customer can call the same route on their own order, with no staff yes (tested). Every case, plus cancel and returns, is in Refund, cancel or return an order.

Stop: a refund sends money back. Show the order, the amount and the gateway, and wait for yes.

  • Stripe refunds go through Stripe.
  • PayPal and Helcim refunds from Appmint are refused: "Payment refund was not confirmed. Nothing was refunded." Refund in their dashboard; the order still reads paid.
  • Gift card, store credit and points payments go back onto the card or wallet they came from.

When it's done

Tell the person:

  • which gateways are on, and whether each is in test or live mode;
  • that shipping quotes, and the test order's number and how it was paid;
  • where invoice and payment links open.

Open Finance › Gateway. If they are in test mode, say plainly that no real money can be taken until the owner switches to live keys, and that the switch is theirs to make.

What it can't do yet

  • Helcim can't take money on the site. It is in the Setup wizard and saves a record, but the checkout and the Payment page never offer it. Staff charge and refund for Helcim are unfinished, its testMode changes nothing, and the wizard never shows it as connected. Use Stripe or PayPal online.
  • PayPal refunds, captures and voids from Appmint are unfinished.
  • Checkout offers a Stripe record with a missing key. The card form then says "Card payment could not be initialized. Please try again." Only the Payment page drops half-set-up gateways.
  • No Stripe Connect sign-in. Keys are pasted; there is no "log in with Stripe".
  • PayOxygen has a card form on the site, but the server never lists it.

Don'ts

  • Don't ask for, type or repeat secret keys (sk_…, rk_…, PayPal secrets). The owner enters them on screen.
  • Don't switch a business to live keys, or sandbox: false, without the owner's yes.
  • Don't place a real order to test with live keys.
  • Don't make a second Stripe record to "fix" the first; edit the one on Finance › Gateway.
  • Don't promise Helcim online payments.
  • Don't turn a site's Payment feature on or off without asking.