TScheckout.ts TSapi.ts 1 fix
export async function charge(order) {
  const total = sum(order.items);
  if (total <= 0) return null;
  const paid = await pay(total, order.currency);
  // keep the receipt with the order
  await save(order.id, paid.id);
  return paid;
}
Added: wait for the payment before saving.