Yapy API

A Way for Yapy and your business website to work together.

What is Yapy API

Simply, Yapy API is a small piece of code added to your website so we can record all of the sales that we send. We need to record these sales to credit the commissions, to the promoter that sent you the clients.

How Yapy API works

It creates a communication between Yapy and your sales page. It will only record user sales sent from Yapy. This will allow you to add “online discounts” in the discount section.

How to integrate with Yapy API

Step 1. Copy and paste the following reference into the section of the website page you are about to add to the online discount:

<script src=”https://api.yapy.com/static/business/integration/index_production.js”></script>

The final result should look like this:

                    
<head>
    <script src="https://api.yapy.com/static/business/integration/index_production.js"></script>
</head>
                    
                

Step 2. Into the <head> section of your ‘Transaction is successful’ or “Thank You” page add a <script> section to pass us data to calculate the Promoter’s commission:

                    
    <head>
        <script src="https://api.yapy.com/static/business/integration/index_production.js"></script>
        <script>
            const data = {
                price: Value1,
                peopleCount: Value2,
            }
            window.verifyDiscount(data).catch(err => alert(err));
        </script>
        
    </head>
                    
                

Where Value1 is a name of a variable on your website that shows the total amount of the purchase during checkout.

Value2 is a name of a variable on your website that shows the number of people the item is purchased for during checkout (e.g. number of guests in the hotel room).

Step 3. In case you use a 3rd-party service for the checkout, please make sure that the 3rd-party service enables modification of CORS policies or front-end on their end.

List of possible errors to handle

“no yapy_token available” – check that url has yapy_token installed in the correct spot.

404:

“Transaction token is not found or uuid_identifier is incorrect” – 404 error

400:

“Obligatory field is absent” – obligatory field in encrypted payload is absent

“Payload decode error” – Incorrect encrypted payload/ invalid public key for data encryption

“Transaction is expired” – transaction token for user is expired (15 days from share)

“Transaction is already verified” – transaction token is already used

“missing 1 required keyword-only argument: ‘price'” – discount has type ‘%’, but ‘price’ parameter is empty or not in payload

“missing 1 required keyword-only argument: ‘people_count'” – discount hat type ‘per_person’, but ‘people_count’ parameter is empty or not in payload

‘people_count/price’: [‘A valid integer is required.] – listed parameters are not valid inside encrypted payload

Please keep in mind that if the integration is incomplete or implemented incorrectly, discount usage might not be registered and Promoter’s commission might not be credited. Also, you are responsible for handling all of your website performance issues as they might affect the possibility of using online discounts and correct integration work.

FAQ / Support

What is Yapy token/transaction token?

This is a unique identifier, which is added to the website link in an online discount automatically by the system. It allows us to connect a particular discount with a purchase, calculate Promoter’s commission and statistics.

What are the requirements for link in an online discount?

The link has to fit these criteria:

  1. The link has to be valid (leading to the actual working website)
  2. The link has to lead to the website that is integrated with Yapy API
  3. The link has to have a secured protocol
  4. The link has to lead directly to the website with item or offer

In case you have any questions or require assistance, feel free to contact us at info@yapy.com