Code Examples

Production-ready code samples for payments, wallets, WhatsApp, and automation.

Payment examples

Accept Bre-B payment

const payment = await orangepill.payments.create({
  amount: 50000,
  currency: 'COP',
  payment_method_types: ['bre_b'],
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel'
});

// Redirect customer to payment.url

Handle webhook confirmation

app.post('/webhooks/orangepill', (req, res) => {
  const event = req.body;

  if (event.type === 'payment.succeeded') {
    const payment = event.data;
    // Fulfill order for payment.metadata.order_id
  }

  res.sendStatus(200);
});

WhatsApp examples

Send checkout link

const session = await orangepill.whatsapp.checkout.create({
  phone: '+573001234567',
  items: [{ product_id: 'prod_abc', quantity: 1 }]
});

await orangepill.whatsapp.messages.send({
  to: '+573001234567',
  type: 'text',
  text: { body: `Tu checkout: ${session.url}` }
});

Wallet examples

Create loyalty wallet

const wallet = await orangepill.wallets.create({
  customer_id: 'cust_abc',
  type: 'loyalty_points',
  currency: 'POINTS'
});

// Award points
await orangepill.wallets.transactions.create({
  wallet_id: wallet.id,
  amount: 100,
  type: 'credit',
  description: 'Purchase reward'
});

Sample repositories

Full sample applications on GitHub:

Next steps