Koywe
On this page

Accepting Payments (PAYIN)

Learn how to accept payments from customers using local payment methods across Latin America.

What is PAYIN?

PAYIN is the order type used to accept payments from customers into your virtual balance account.

Drawing diagram…

Use Cases

E-Commerce Checkout

Accept payments for online purchases at checkout

Service Payments

Collect payments for services rendered

Subscription Billing

Recurring payments for subscriptions

Invoice Payments

Accept payments for issued invoices


How It Works

High-Level Flow

  1. Customer initiates checkout

    User adds items to cart and proceeds to payment

  2. Your app creates PAYIN order

    Send order details to Koywe API

  3. Koywe returns payment URL

    Receive a checkout URL for the customer

  4. Customer completes payment

    Customer is redirected to payment page and pays using their preferred method

  5. Koywe confirms payment

    Payment provider confirms and Koywe credits your virtual account

  6. Your app receives webhook

    You’re notified via webhook to fulfill the order

Detailed Flow Diagram

Drawing diagram…

Supported Countries and Payment Methods

Colombia πŸ‡¨πŸ‡΄

MethodTypeSettlement Time
PSEBank transferInstant - 2 hours
NequiMobile walletInstant

Learn more about Colombian payment methods β†’

Brazil πŸ‡§πŸ‡·

MethodTypeSettlement Time
PIXInstant paymentInstant

Mexico πŸ‡²πŸ‡½

MethodTypeSettlement Time
SPEIBank transferInstant ⚑

Chile πŸ‡¨πŸ‡±

MethodTypeSettlement Time
KhipuBank transferInstant - 2 hours

Argentina πŸ‡¦πŸ‡·

MethodTypeSettlement Time
VariousLocal methodsVaries

Prerequisites

Before integrating PAYIN orders, ensure you have:

Required:

  • βœ… API Key and Secret
  • βœ… Organization ID
  • βœ… Merchant ID
  • βœ… Understanding of Core Concepts

Recommended:

  • Webhook endpoint configured
  • Error handling implemented
  • Testing in sandbox environment

Quick Start

Want to jump right in? Follow our step-by-step integration guide:

Complete Integration Guide

Detailed guide with code examples in cURL, Node.js, and Python

Or try the quickstart for a faster overview:

5-Minute Quickstart

Create your first PAYIN order in minutes


Payment Flow Explained

Step-by-Step Process

1. Authentication

Obtain an access token using your API credentials.

JavaScript
const token = await authenticate(apiKey, secret);

2. Get Available Payment Methods

Query which payment methods are available for the customer’s country.

JavaScript
const methods = await getPaymentMethods('CO', 'COP');
// Returns: PSE, NEQUI, etc.

Store customer information for tracking and compliance.

JavaScript
const contact = await createContact({
  firstName: 'Juan',
  lastName: 'PΓ©rez',
  countrySymbol: 'CO',
  businessType: 'PERSON',
  type: 'PERSON',
  email: 'customer@example.com'
});

4. Create PAYIN Order

Create the payment order with amount and payment method.

JavaScript
const order = await createPayinOrder({
  amount: 50000,
  currency: 'COP',
  paymentMethod: 'PSE',
  contactId: contact.id
});

5. Redirect Customer

Send customer to the payment URL to complete payment.

JavaScript
window.location.href = order.providedAction;

6. Handle Webhooks

Listen for webhook events to know when payment is complete.

JavaScript
// Webhook: order.completed
// -> Fulfill order, send confirmation email

Order Status Progression

Understanding order statuses:

Drawing diagram…
StatusDescriptionNext Action
PENDINGOrder created, waiting for customerCustomer needs to pay
PROCESSINGPayment being processedWait for confirmation
PAIDPayment confirmedFunds being settled
COMPLETEDFunds in your accountFulfill order
FAILEDPayment failedShow error to customer
EXPIREDPayment window expiredCreate new order
CANCELLEDOrder cancelledNo action needed

Key Concepts

Payment URL

Every PAYIN order returns a providedAction:

JSON
{
  "providedAction": "https://checkout.koywe.com/pay/ord_abc123"
}

This URL:

  • Is hosted by Koywe
  • Provides a secure payment experience
  • Handles the payment method UI
  • Redirects back to your successUrl or failedUrl

Success and Failed URLs

Specify where to redirect customers after payment:

JavaScript
{
  "successUrl": "https://yoursite.com/payment/success",
  "failedUrl": "https://yoursite.com/payment/failed"
}

Best Practice: Don’t rely solely on these redirects for order fulfillment. Always use webhooks as the source of truth.

External ID (Idempotency)

Use externalId to link orders to your system and prevent duplicates:

JavaScript
{
  "externalId": "order-12345"  // Your internal order ID
}

Benefits:

  • Safe to retry failed API calls
  • Prevents duplicate charges
  • Easy reconciliation with your database

Common Integration Patterns

Pattern 1: Simple Checkout

JavaScript
// 1. User clicks "Pay"
// 2. Create order
const order = await createPayinOrder({
  amount: cartTotal,
  currency: 'COP',
  paymentMethod: 'PSE'
});
// 3. Redirect
window.location.href = order.providedAction;
// 4. Handle webhook
// 5. Fulfill order

Pattern 2: Payment Method Selection

JavaScript
// 1. Show available methods
const methods = await getPaymentMethods(country, currency);
// 2. User selects method
// 3. Create order with selected method
const order = await createPayinOrder({
  amount: cartTotal,
  currency: 'COP',
  paymentMethod: userSelectedMethod
});
// 4. Redirect and handle webhook

Pattern 3: Stored Customer

JavaScript
// 1. Check if customer exists
let contact = await findContact(email);
if (!contact) {
  contact = await createContact(customerData);
}
// 2. Create order linked to contact
const order = await createPayinOrder({
  amount: cartTotal,
  contactId: contact.id,
  // ... other fields
});
// 3. Track payment history per contact

Next Steps


Additional Resources