Riverty Logo

    Menu

    Please select your page

    SDK

    PHP

    If you want to connect to our API you can also use our PHP library.

    Website:
    https://www.php.net/

    Type:
    SDK

    Introduction

    This guide describes how to connect to our API, using our Riverty.com PHP SDK. It only covers the creation and submission of an order. Information and examples of other operations, like capture, cancel and refund, can be found in the package.

    PHP currently offers these payment methods:

    • 14-day invoice - This is the default 14-day invoice payment method in Riverty. It is primarily meant for business-to-consumer sales.
    • Direct Debit - This is a Direct Debit version of the 14-day invoice payment method Instead of receiving an invoice to be paid via their bank, the customer enters their bank details, and the money is immediately deducted from their bank account.
    • Campaign invoice
    • Fixed instalments
    • Flex payment
    • B2B invoice - This is the B2B consumer version of the default 14-day invoice payment method in Riverty.

    The available payment methods per country for PHP can be found in this table:

    Country 14-day invoice Direct Debit Campaign invoice Fixed instalments Flex payment B2B invoice
    The Netherlands
    x
    x
    x
    Belgium
    x
    Germany
    x
    x
    x
    x
    Austria
    x
    x
    x
    Switzerland
    x
    Sweden
    x
    x
    x
    x
    x
    Norway
    x
    x
    x
    x
    x
    Finland
    x
    x
    x
    x
    x
    Denmark
    x
    x
    x
    x
    x

    Include library using Composer

    1) Include the Riverty PHP Library by using Composer. If you are not familiar with using Composer, read this article with the basics about PHP Composer: http://culttt.com/2013/01/07/what-is-php-composer/. The AfterPay PHP Library can be found on packagist.org as “Payintegrator/Afterpay” (Details and releasenotes: link).

    The library can be included by the following command:

    composer require payintegrator/afterpay
    

    2) Next make sure you are using the Autoloader:

    require 'vendor/autoload.php';
    

    3) Create an empty object, for example using:

    $riverty = new AfterpayAfterpay();
    

    This object will be used to store the information of your order and to send an order to the Riverty API.

    Creating order lines

    With the function $riverty->createorderline you can send the specification of the order lines.

    You can use this for any type of orderline, i.e.:

    products
    shipping fee
    service fee
    discount

    Note: prices are to be submitted in cents, including TAX.

    Below is an example of an orderline for a product.

    $sku = 'PRODUCT-001';
    $name = 'Product name 1';
    $qty = 3;
    $price = 3000; // in cents, including TAX (for discounts, use a negative number)
    $tax_category = 1; // 1 = high, 2 = low, 3, zero, 4 no tax
    $riverty->create_order_line( $sku, $name, $qty, $price, $tax_category );
    

    Set-up address and other information

    In this step you set up the general order information and configure the Riverty object with this information. This contains the billing and shipping information and other relevant information like the ordernumber, the currency and the remote ip address of the customer.

    Below is an example of a B2C order.

    // Set up the bill to address
    $order['billtoaddress']['city'] = 'Heerenveen';
    $order['billtoaddress']['housenumber'] = '90';
    $order['billtoaddress']['housenumberaddition'] = '5';
    $order['billtoaddress']['isocountrycode'] = 'NL';
    $order['billtoaddress']['postalcode'] = '8441ER';
    $order['billtoaddress']['referenceperson']['dob'] = '1980-12-12T00:00:00';
    $order['billtoaddress']['referenceperson']['email'] = 'tester@riverty.com;
    $order['billtoaddress']['referenceperson']['initials'] = 'A';
    $order['billtoaddress']['referenceperson']['isolanguage'] = 'NL';
    $order['billtoaddress']['referenceperson']['lastname'] = 'de Tester';
    $order['billtoaddress']['referenceperson']['phonenumber'] = '0513744112';
    $order['billtoaddress']['streetname'] = 'KR Poststraat';
    
    // Set up the ship to address
    $order['shiptoaddress']['city'] = 'Heerenveen';
    $order['shiptoaddress']['housenumber'] = '90';
    $order['shiptoaddress']['housenumberaddition'] = '5';
    $order['shiptoaddress']['isocountrycode'] = 'NL';
    $order['shiptoaddress']['postalcode'] = '8441ER';
    $order['shiptoaddress']['referenceperson']['dob'] = '1980-12-12T00:00:00';
    $order['shiptoaddress']['referenceperson']['email'] = 'tester@riverty.com';
    $order['shiptoaddress']['referenceperson']['initials'] = 'A';
    $order['shiptoaddress']['referenceperson']['isolanguage'] = 'NL';
    $order['shiptoaddress']['referenceperson']['lastname'] = 'de Tester';
    $order['shiptoaddress']['referenceperson']['phonenumber'] = '0513744112';
    $order['shiptoaddress']['streetname'] = 'KR Poststraat';
    
    // Set up the additional information
    $order['ordernumber'] = 'ORDER123';
    $order['currency'] = 'EUR';
    $order['ipaddress'] = $_SERVER['REMOTE_ADDR'];
    
    // Create the order object for B2C or B2B
    $riverty->set_order( $aporder, 'B2C' );
    

    Processing the return object

    The result of the order will be set in the object $riverty->order_result. You can process the order, using the information in the object. Below is an overview of possible resultIDs in the object.

    img

    Example return objects

    ResultId 0 – Accepted payment

    img

    ResultId 1 – Technical error

    img

    ResultId 2 – Validation error

    img

    ResultId 3 – Rejected payment

    img

    Processing messages and descriptions

    Each returnobject contains an array with 1 or more

    messages: these are for logging and debugging
    descriptions: these are to be displayed in the webshop

    foreach ($riverty->order_result->return->messages as $message)
    {
        echo $message['message'];
    }
    

    Echo’s all the messages in the array.

    foreach ($riverty->order_result->return->messages as $message)
    {
        echo $message['description'];
    }
    

    Echo’s all the descriptions in the array.

    Submit testorders

    ResultId 0 – accepted payment
    To check the submission of successful orders, place an testorder for each payment method with:

    • multiple products
    • discount (if possible)
    • shipping fee (if possible)
    • service fee (if allowed)
    • alternate delivery address

    Below you will find the testdata that can be used.

    img

    ResultId 1 – technical error
    To verify and process a technical error, place a regular order, but trigger a technical error, for example using:

    • 0 as merchantID
    • Incorrect password

    ResultId 2 – validation error
    To verify and process a validation error, place a regular order, but use invalid data, for example:

    • telephone number consisting of 9 digits, i.e.: 051322334
    • postal code using only letters, i.e.: ABCD
    • name with number in it, i.e.: John Doe 123

    ResultId 3 – rejected payment
    To verify and process a rejected payment, place a regular order, but use the first name 'Reject' while communicating towards the sandbox environment.

    Visual guidelines

    In this chapter we will explain the Riverty visual guidelines you need to apply to your webshop.

    Logos and banners

    For convenience and a familiar customer experience, please integrate/enclose the Riverty logo in your Checkout next to the payment method. Please refer to our Merchant Playbook for full details on how to make the customer experience smooth and frictionless.

    When Implementing the Riverty logo throughout the shopping experience please ensure you are using our URL, not by downloading the image. The Riverty logos are hosted on a Content Delivery Network (CDN) to ensure the best performance and availability for your website. Furthermore, you do not have to care about changes, which are all done by Riverty.

    We provide two types of logos through our CDN - .svg and .png. We recommend using the Riverty logo as a .svg file with regard to the quality and size of the file. If you prefer .png just change the end of the URL to .png. We also offer the Riverty logo in different color schemes. Depending on your individual website background, choose the Riverty logo that fits best.

    DescriptionCopy URLLogo
    Riverty-AfterPay Checkout Logo in SVGhttps://cdn.riverty.design/logo/riverty-checkout-logo.svgRiverty-AfterPay Checkout Logo in SVG

    Terms and conditions

    Riverty mandates that it is mandatory for a consumer to be presented with Riverty's terms and conditions and Privacy Policy upon checkout. Thus the option to display the T&C should be always enabled in the plugin configuration. In certain cases where you would like to incorporate the Riverty T&C and Privacy Policy within your own Terms and Conditions, this must be done only with approval from Riverty's legal counsel. After approval include the country specific T&C and Privacy Policy resources.




    Last steps

    In this chapter we will explain which steps you need to take to complete the integration with PHP.

    Last check (Only applicable for the BeNeLux)

    Now that Riverty is live, we only have to check whether orders are also coming in properly.
    You can test this per Riverty connection by placing a rejected order:

    STEP 1
    Go to the webshop, and place a product in the shopping cart.

    STEP 2
    Go to checkout and fill in the necessary information, for the email address you have to enter rejection@afterpay.nl.

    STEP 3
    Choose the payment method Riverty and finish the order.

    RESULT
    The Riverty order should be rejected. If this is not the case and instead you receive a technical error or an authorization error please contact your Riverty Implementation Manager.

    Done

    Congratulations! You just went live with your Riverty connection. Please notify your Riverty Implementation Manager that you went live. If you encounter any issues in the upcoming week you can contact your Riverty Implementation Manager. After that period you can contact our local Merchant Desk for help.

    Introduction to the Riverty Merchant Portal

    You can go to the Merchant Portal here. Once logged in, you will also see an in-depth guide on how to best use it.

    In the merchant portal you can:

    • View and mutate your Riverty orders
    • Get financial reports
    • Setup your branding in the Riverty systems
    Riverty 2023