> For the complete documentation index, see [llms.txt](https://developers.rewardful.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.rewardful.com/getting-started/other-payment-processors.md).

# Other Payment Processors

## Server-Side Integration

If you don't use Stripe, or want more control over the data you're sending to Rewardful, you can use our Server-Side Integration method. With this method, you can automate sending your sales data instead of using our Stripe App integration method. This allows you to connect Rewardful to any payment processor you want and to have more granular control over the sales data you are sending Rewardful.

In general, most payment processors work by sending a webhook to notify your application that a payment was successful, that a trial has started, that a subscription has been canceled, or that a payment has been refunded. When receiving these webhooks you likely provision or remove access to your service. To use Rewardful's server-side integration you just need to include a few API calls to our API within your existing customer lifecycle management.

{% hint style="info" %}
Rewardful's coupon based tracking is not available using this method as it relies on Stripe coupons. Coupon based tracking is only using our Stripe integrations.
{% endhint %}

## Requirements

Before you start implementing the Server-Side Integration Method, you will need to have completed the following configurations:

1\. Specify your display currency.

2\. Create your first campaign.

## Key Concepts

1. Link tracking/creating referrals
2. Converting referrals to leads
3. Creating sales/converting leads
4. Handling refunds/updating sales

## Link tracking/creating referrals

In order to track referrals from affiliates it is necessary to install Rewardful's Javascript tracking snippet. This snippet should be installed wherever you want affiliates to be able send traffic to and have it tracked.

```javascript
<script>(function(w,r){w._rwq=r;w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)}})(window,'rewardful');</script>
<script async src='https://r.wdfl.co/rw.js' data-rewardful='[YOUR-API-KEY]'></script>
```

When a customer visits your website via an affiliate link the tracking snippet will install a first party cookie on the users' browser. This cookie will persist on the user's browser and will be valid for the period that you define in your Rewardful account settings.

The Rewardful tracking snippet also makes available a Javascript method that allows you to get the referral ID of the customer referral that was created.

```javascript
Rewardful.referral
```

When a customer is signing up you will want to save this referral ID, either to your application database, or on your payment processor as metadata. The referral ID is a UUID that can be used later for converting referrals to leads, and for creating sales related to that referral using our REST API.

{% hint style="info" %}
In some cases using adblockers can prevent affiliate tracking scripts from working properly. However, it is possible to bypass these adblockers by [sideloading the Rewardful tracking script](https://help.rewardful.com/en/articles/8394462-bypassing-adblockers).
{% endhint %}

## Converting referrals to leads

It's up to you when in your customer lifecycle you want to convert a referral to a lead. The two most common moments are either (1) when a customer signs up for your application or (2) when a customer starts a trial for your application.

In order to convert a referral to a lead you will need to use our convert a referral to a lead endpoint using the referral ID.

## Creating sales/conversions

When a customer makes a purchase, you can let Rewardful know using the [Create sale endpoint](https://developers.rewardful.com/rest-api/sales/create). This would typically be after you receive a webhook from your payment processor indicating that a successful payment has been received from a customer.

The first time a sale is created for a customer/referral, it will be viewed within the Rewardful dashboard as a conversion for stats purposes. Each sale you send to Rewardful will generate a commission according to the rules of the campaign to which the affiliate responsible for the underlying referral is linked. Subsequent sales from this customer/referral will not increase the conversion count but will generate commissions.

## Handling refunds/updating sales

If a customer is refunded for a purchase in your payment processor or their charge increases, you can update the corresponding sale in Rewardful using the [Update sale endpoint](https://developers.rewardful.com/rest-api/update/create).

When a sale is updated, the associated commission that Rewardful generated for that sale will be updated accordingly. However, if the associated commission has already been marked as paid, our system will not update it.

{% hint style="info" %}
***Sales cannot be deleted***

Rewardful does not allow sales to be deleted. If needed, a sale can be updated to a zero value to represent a full refund.
{% endhint %}

## The sale object

Sales represent purchases from referrals. Commissions distributed to affiliates are calculated based on sales generated from their referrals.

Below is an example of a sale object.

```json
{
    "id": "74e37d3b-03c5-4bfc-841c-a79d5799551a",
    "currency": "USD",
    "charged_at": "2020-08-19T16:28:25.000Z",
    "stripe_account_id": "acct_ABC123",
    "stripe_charge_id": "ch_ABC123",
    "invoiced_at": "2020-08-19T16:28:25.000Z",
    "created_at": "2020-08-19T16:28:31.102Z",
    "updated_at": "2020-08-19T16:28:31.102Z",
    "charge_amount_cents": 10000,
    "refund_amount_cents": 0,
    "tax_amount_cents": 0,
    "sale_amount_cents": 10000,
    "referral": {
        "id": "d154e622-278a-4103-b191-5cbebae4047a",
        "stripe_account_id": "acct_ABC123",
        "stripe_customer_id": "cus_ABC123",
        "conversion_state": "conversion",
        "deactivated_at": null,
        "expires_at": "2020-10-18T16:13:12.109Z",
        "created_at": "2020-08-19T16:13:12.109Z",
        "updated_at": "2020-08-19T16:28:31.166Z",
        "customer": {
            "platform": "stripe",
            "id": "cus_ABC123",
            "name": "Freddie Mercury",
            "email": "freddie@example.com"
        },
        "visits": 2,
        "link": {
            "id": "b759a9ed-ed63-499f-b621-0221f2712086",
            "url": "http://www.demo.com:8080/?via=james",
            "token": "james",
            "visitors": 197,
            "leads": 196,
            "conversions": 156
        }
    }
}
```

### Attributes

| Name                          | Data type | Description                                                          |
| ----------------------------- | --------- | -------------------------------------------------------------------- |
| id                            | string    | Unique identifier for the sale (UUID).                               |
| created\_at                   | string    | Time at which the sale was created.                                  |
| updated\_at                   | string    | Time at which the sale was last updated.                             |
| currency                      | string    | ISO currency code in which the sale is denominated.                  |
| charged\_at                   | string    | Time at which the sale was charged.                                  |
| stripe\_account\_id           | string    | The Stripe account associated with the sale.                         |
| stripe\_charge\_id            | string    | The technical ID of the sale in Stripe.                              |
| invoiced\_at                  | string    | Time at which the sale was invoiced.                                 |
| charge\_amount\_cents         | integer   | The amount charged for the sale, in cents.                           |
| refund\_amount\_cents         | integer   | The refunded amount of the sale, in cents.                           |
| tax\_amount\_cents            | integer   | The tax amount of the sale, in cents.                                |
| sale\_amount\_cents           | integer   | The amount of the sale, tax excluded, in cents.                      |
| referral                      | object    | The referral of the actual customer who made the purchase.           |
| referral.id                   | string    | Unique identifier of the referral.                                   |
| referral.stripe\_account\_id  | string    | The ID of the customer's Stripe account.                             |
| referral.stripe\_customer\_id | string    | The ID of the customer in Stripe.                                    |
| referral.conversion\_state    | string    | The state of the client regarding their conversion.                  |
| referral.deactivated\_at      | string    | If the referral is deactivated, the deactivation date will be shown. |
| referral.expires\_at          | string    | Time at which the referral will expire.                              |
| referral.created\_at          | string    | Time at which the referral was created.                              |
| referral.updated\_at          | string    | Time at which the referral was updated.                              |
| customer                      | object    | Information on the customer.                                         |
| customer.platform             | string    | The platform in which the customer is registered.                    |
| customer.id                   | string    | The ID of the customer in Stripe.                                    |
| customer.name                 | string    | Customer's name.                                                     |
| customer.email                | string    | Customer's email address.                                            |
| visits                        | integer   | Number of visits that customer made to your website.                 |
| link                          | object    | Information on the referral link used.                               |
| link.id                       | string    | The referral link unique ID.                                         |
| link.url                      | string    | The URL of the referral.                                             |
| link.token                    | string    | The referral token. The unique part of the referral link.            |
| link.visitors                 | integer   | The total amount of visitors using that referral link.               |
| link.leads                    | integer   | The total amount of leads related to that referral link.             |
| link.conversions              | integer   | The total amount of conversions from that referral link.             |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.rewardful.com/getting-started/other-payment-processors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
