# About Payment via Bot

ConnectiveOne supports integration with payment systems for accepting payments directly in the bot without additional website integration. This allows creating full e-commerce solutions in messengers.

---

## Context and Problem

In many scenarios, you need to accept payment from users:
- Selling goods or services
- Subscriptions and recurring payments
- Donation collections
- Balance top-up

Integration with payment systems solves this task by allowing accepting payment directly in the bot.

---

## Key Concepts

### Supported Payment Methods

**Liqpay (all channels):**
- Works for Telegram, Viber, Facebook Messenger, Widget
- Universal solution for all channels

**Apple Pay & Google Pay (Viber only):**
- Works only for Viber channel
- Native integration with mobile payment systems

### General Payment Workflow

1. User selects product/service in the bot
2. Bot generates payment link
3. User goes to payment page
4. After successful payment, user returns to bot
5. Bot processes payment result and provides access to service/product

---

## Approach Options

### Liqpay vs Apple Pay & Google Pay

**Liqpay:**
- ✅ Pros: Works for all channels, universal solution
- ❌ Cons: Requires registration in Liqpay

**Apple Pay & Google Pay:**
- ✅ Pros: Native integration, convenience for users
- ❌ Cons: Works only for Viber, requires configuration

**Why we use both approaches:**
Liqpay ensures universality for all channels, and Apple Pay & Google Pay provide better user experience for Viber users.

---

## Adopted Solutions

### Payment Result Processing

After payment, the bot receives a callback with the result. You need to configure processing:
- Successful payment — providing access to service
- Payment error — informing user
- Payment cancellation — returning to selection

### Payment Security

All payments are processed through secure payment systems with HTTPS support and data encryption. Card data is not stored in the ConnectiveOne system.

---

## Implications for Users and Implementation

### For Integrators

When integrating payment, it's important to:

1. **Configure payment system** — register in Liqpay or configure Apple Pay & Google Pay
2. **Process payment results** — configure callback processing for different results
3. **Provide access after payment** — automatically provide access to service/product after successful payment
4. **Inform user** — notify about payment status and next steps

### Common Errors

**Error:** Payment does not go through  
**Problem:** Payment system is not configured or incorrect parameters  
**Solution:** Check payment system settings and request parameters

**Error:** User does not get access after payment  
**Problem:** Callback processing after successful payment is not configured  
**Solution:** Add callback processing and automatic access provision

**Error:** Payment works only for one channel  
**Problem:** Apple Pay & Google Pay used instead of Liqpay  
**Solution:** Use Liqpay to support all channels

---

## Related Documents

> 💡 **Note:** Detailed instructions for payment system integration are available in Swagger UI or technical documentation.

