# 2Checkout Module

https://docs.wisecp.com/en/2checkout-module

Send clients to the 2Checkout payment page and let a notification from 2Checkout close the invoice.

## Reaching the Screen

Go to **Settings → Financial → Payment Gateways**, open **All Modules** and click the **2Checkout** card: `{admin}/modules/payment?module=TCO`

Adding the gateway to the method list clients see is covered in [Payment Modules](https://docs.wisecp.com/en/payment-modules).

## What Is on the Screen

One settings form: the 2Checkout credentials, a test switch and the shared gateway settings every module carries.

The client is moved to the 2Checkout payment page with the order lines and the billing address already filled in. The card never touches your site. 2Checkout then reports the result to your callback address, and that report is what closes the invoice.

The module does not keep cards, does not open subscriptions, offers no installments and cannot refund a payment. Refunds are made in your 2Checkout account.

## Before You Configure It

- A 2Checkout account with its merchant code.
- The currency you charge in accepted on that account.
- An address your 2Checkout account can reach over HTTPS, because the result arrives there.

## Fields

- **Merchant Code**: The account the payment page is opened for. Required.
- **Secret Key**: Checks the signature on an incoming notification. A notification is refused when the check fails. Required.
- **Secret Word**: The second value that goes into the same signature. Required.
- **Publishable Key**: Neither the payment page nor the notification uses this value. You can leave it empty.
- **Private Key**: Not used either. You can leave it empty.
- **Test Mode**: Opens the payment page as a demonstration order, so no money moves. Off by default.

**Status**, **Commission Rate (%)**, **Converting Currency**, **Accepted Amount Range** and the country lists work the same way in every gateway. See [Payment Modules](https://docs.wisecp.com/en/payment-modules). **Callback URL**, **Success URL** and **Failed URL** cannot be edited: copy them with the icon at the end of the field.

## Tasks

### Take the credentials from 2Checkout

1. Sign in to your 2Checkout account and open **Integrations → Webhooks & API**.
2. Copy the secret key from the API section and the secret word from the INS section.
3. Copy your merchant code from the same area. It also appears on your account summary.

### Enter the credentials

1. Open the module card and tick **Status**. The other fields stay locked until you do, and nothing else is saved while it is off.
2. Fill in **Merchant Code**, **Secret Key** and **Secret Word**.
3. Tick **Test Mode** while you try the flow, and untick it before you take real payments.
4. Click **Save Changes**. Clients who pick this method are now taken to the 2Checkout page.

### Register the notification address

1. Copy the **Callback URL** from the module card with the icon at the end of the field.
2. Open **Integrations → Webhooks & API → INS Settings → Add endpoint**. Paste the address, select **SHA256** and click **Save endpoint**.
3. Edit the `INVOICE_STATUS_CHANGED` trigger. Under **Parameters**, replace `md5_hash` with `hash` and click **Save trigger**.
4. Run a test payment and check both the provider transaction and WISECP invoice. The module accepts signed `approved` and `deposited` notifications.

### What the client goes through

1. The client picks this method at checkout, on an invoice or when adding funds.
2. A short waiting page appears and the client is moved to the 2Checkout payment page.
3. The client pays there and comes back to your site.
4. The invoice closes when the notification arrives, which may be a moment later than the return.

### Refund a payment

1. Refund the order in your 2Checkout account. The module cannot send a refund.
2. Open the paid invoice: `{admin}/invoices/detail?id={invoice}`
3. Under **Summary → Change Status**, select **Refunded** and **Add as expense**.
4. Click **Update Status**. WISECP records the refund; this step does not send money again.

## Things to Watch

> **Verify the payment notification**
> 
> A wrong secret key, secret word or unreachable notification address can leave an invoice unpaid. Check the invoice status with a test payment before offering the method to clients.

> **The return page can read as a failure**
> 
> A client coming back from 2Checkout may land on the failed payment page even after a successful payment. Judge the payment by the invoice status, not by the page the client saw, and expect the occasional support message about it.

> **A basic gateway**
> 
> There are no kept cards, no subscriptions and no installments here, and refunds happen in your 2Checkout account. Pick another gateway under **Card Storage Module** when you want automatic renewal payments.

## Required Privileges

Settings require **Payment Module Settings** (`MODULES_PAYMENT_SETTINGS`). Invoice changes require **Billing → Edit** (`INVOICES_OPERATION`).

## Related Articles

- [Payment Modules](https://docs.wisecp.com/en/payment-modules)
- [Invoice Detail Overview](https://docs.wisecp.com/en/invoice-detail-overview)
- [Module Management](https://docs.wisecp.com/en/module-management)
