Configuring TreviPay

Learn how to configure TreviPay for DigitialRiver.js with Elements.

If you're using DigitalRiver.js with Elements, you can create a TreviPay payment method for your app or website in four easy steps:

Step 1: Build the TreviPay object

A TreviPay source request object requires the following fields.





The payment session identifier.


A TreviPay source details object that includes the details of the transaction.

TreviPay source details object

The TreviPay source details object requires the following fields.

    "returnUrl": "",
    "cancelUrl": "",



If you choose to use the full redirect flow, this is where you will redirect your customer after authorizing within the TreviPay experience. Note that the returnUrl must use https.



If you choose to utilize the full redirect flow, this is where you will redirect your customer after canceling within the TreviPay experience.

Step 2: Create a TreviPay agreement source using DigitalRiver.js

Use the DigitalRiver.js library to create and mount elements to the HTML container.

The address object must contain postal code and state/province data that adheres to a standardized format.

var data = {
    "type": "msts",
    "sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
    "msts": {
        "returnUrl": "",
        "cancelUrl": ""

digitalriver.createSource(data).then(function(result) {
    if (result.error) {
        //handle errors
    } else {
        var source = result.source;
        //send source to back end

TreviPay source response example

    "clientId": "gc",
    "channelId": "drdod15",
    "liveMode": false,
    "id": "d6a44e5d-1373-4013-847d-10deb4ded4df",
    "sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",    
    "clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_ddd44e5d-1373-4013-847d-10deb4ded4df",
    "type": "msts",
    "reusable": false,
    "amount": "10.00",
    "currency": "USD",
    "state": "pending_redirect",
    "creationIp": "",
    "createdTime": "2019-05-22T00:00:46.975Z",A 
    "updatedTime": "2019-05-22T00:00:46.975Z",
    "flow": "redirect",
    "redirect": {
        "redirectUrl": "",
        "returnUrl": "",
        "cancelUrl": ""
    "msts": {
        "shipping": {
            "recipient": "John Doe",
            "phoneNumber": "555-555-1212",
            "address": {
                "line1": "54321 Fake St.",
                "line2": "Apt. 3C",
                "city": "Minnetonka",
                "state": "MN",
                "country": "US",
                "postalCode": "55341"
        "token": "EC-1HD67063RG318840B"

Step 3: Authorize a TreviPay source

When you create a TreviPay source, the customer is required to authorize the charge at TreviPay. You can accomplish this by redirecting the customer to TreviPay to authorize the charge as part of your experience.

Redirecting the customer to TreviPay for authorization

To redirect your customer to TreviPay for authorization, use the redirectUrl parameter in your createSource response.

window.location.href = sourceResponse.redirect.redirectUrl;

At TreviPay, the customer can authorize or cancel the transaction when presented with the transaction details. If the authorization is successful, the customer will be redirected to the TreviPay Return URL parameter you specified when you created the source. If the customer cancels, they will be returned to the TreviPay Cancel URL parameter you specified.​

Step 4: Use the authorized source

Once authorized, you can use the source by attaching it to a checkout.

  "sourceId": "src_a78cfeae-f7ae-4719-8e1c-d05ec04e4d37"

Testing TreviPay

See Testing redirect payment methods for testing instructions.

Last updated