# Payment apps: Razorpay, Stripe and PayPal

> Connect Razorpay, Stripe or PayPal to send payment links in WhatsApp chats, check payments, refund and get paid updates instantly.

Source: https://docs.theavoxai.com/connections/apps/payments

Connect a payment app and Avox can send a payment link in a chat, check whether it was paid, refund
a payment, and hear about payments the moment they happen. Money always goes straight to your own
account at the app; Avox never holds it.

All three connect with keys from the app's own dashboard. Avox tries the keys with the app before
saving them, stores them encrypted and never shows them again.

> **Note**
>
> Amounts are in the currency's smallest unit, the way the app counts them: 49900 is ₹499.00 or $499.00, and 500 is ¥500.

## Razorpay

**What you need:** a Razorpay account, and an API key (live or test).

**1. Create a key**

In the Razorpay Dashboard open **Account & Settings**, then **API Keys**, and generate a key.
Copy the **Key ID** (it starts with `rzp_live_` or `rzp_test_`) and the **Key secret** (Razorpay
shows it once).

**2. Connect in Avox**

Open **Connections**, then **Apps**, then **Razorpay**, and click **Connect**. Paste both and click
**Connect**.

**3. Turn on instant updates**

On Razorpay's page in Avox, under **Instant updates**, copy Avox's address. In Razorpay open
**Webhooks**, add a webhook with that address, type a secret of your own, and tick
`payment_link.paid`, `payment_link.cancelled`, `payment_link.expired` and `refund.processed`. Paste
the same secret in Avox as the **Webhook secret**.

- Payment links are Razorpay Payment Links. Avox sends the link in the chat itself, so Razorpay's
  own SMS and email are off.
- Status works with a payment link id (`plink_...`) or a payment id (`pay_...`).
- A refund of a link refunds its captured payment; leave the amount out for a full refund.
- Every update is checked with your webhook secret; one that doesn't match is refused.

## Stripe

**What you need:** a Stripe account, and a restricted key.

**1. Create a restricted key**

In the Stripe Dashboard open **Developers**, then **API keys**, and click **Create restricted
key**. Give it **Checkout Sessions: Write** and **Refunds: Write**. Copy the key (`rk_live_...`).
A secret key (`sk_live_...`) works too, but a restricted key can do less if it's ever leaked.

**2. Connect in Avox**

Open **Stripe** under Apps, click **Connect** and paste the key.

**3. Turn on instant updates**

Copy Avox's address from **Instant updates**. In Stripe open **Developers**, then **Webhooks**, add
an endpoint with that address and the events `checkout.session.completed`,
`checkout.session.expired` and `charge.refunded`. Copy the endpoint's **Signing secret**
(`whsec_...`) and paste it in Avox.

- Payment links are Stripe Checkout pages, open for 30 minutes to 24 hours (24 hours unless a step
  says otherwise).
- When a step gives a reference, Stripe never makes two pages for it, even if the step runs twice.
- Status works with the checkout id (`cs_...`) or a payment id (`pi_...`), and shows refunds too.
- Updates are accepted only with a valid signature from the last 5 minutes.

## PayPal

**What you need:** a PayPal Business account and a REST app in the PayPal Developer Dashboard.

**1. Get the app's credentials**

In the PayPal Developer Dashboard open **Apps & Credentials**, choose **Live** (or **Sandbox** to
test), and open or create an app. Copy its **Client ID** and **Secret**.

**2. Connect in Avox**

Open **PayPal** under Apps, click **Connect**, paste both and pick the same environment.

**3. Turn on instant updates**

Copy Avox's address from **Instant updates**. In your PayPal app add a webhook with that address and
the events `INVOICING.INVOICE.PAID`, `INVOICING.INVOICE.CANCELLED` and `PAYMENT.CAPTURE.REFUNDED`.
Copy the **Webhook ID** PayPal shows and paste it in Avox.

- Payment links are PayPal invoices your customer pays in a tap. With the customer's email, PayPal
  also emails it; otherwise Avox only shares the link in the chat.
- Status works with the invoice id (`INV2-...`); refunds use the invoice id (or the PayPal payment id).
- Every update is checked with PayPal before Avox accepts it.

## What a payment step can send

| Detail | Notes |
| --- | --- |
| Amount | Whole number in the smallest unit, above zero. |
| Currency | 3 letters, like `INR`, `USD`, `EUR`. |
| Description | Up to 200 characters; the customer sees it. |
| Reference | Optional: your own order number (letters, numbers, `-` and `_`). |
| Customer | Optional: name, email, phone. |
| Expires in | Optional: minutes, from 30. |
| Return link | Optional: an `https://` page to show after paying. |

## Related
