From The Blog: Introducing TrialPay: More ways to monetize your app

tp-colored-logoTrialPay is a service that allows you to monetize your apps by letting users complete various tasks to earn in-game rewards. These tasks include installing apps, taking surveys, and so on.

“In our ongoing efforts to help developers better engage and reward their users, we have enabled access to our alternative payment tools as a plugin in the Corona SDK. We are excited about this partnership and helping to make it easier for existing Corona developers to access our tools. As part of our acquisition by Visa in April 2015, one of our new features is the ability to unlock offline payment spend as a way for your users to earn currency in your app. We look forward to your feedback and working with all the Corona developers!” said Tiffany Kwong, VP of Partnerships.

To implement TrialPay, you will first need to sign up at their developer portal. Once logged in, click on the My Evergreen Apps tab to add your app. Then, simply add the relevant code to your build.settings and other modules as needed. Please see the documentation to learn more.

Corona Labs is committed to providing you unique ways to monetize your apps. If you want to discuss this plugin further, join us in the Corona forums.

View the full article

Hi there,

I am currently implementing a class for using with trialpay and I do have questions on the API.

In the documentation is explained that you have to call the “init” function premarily… but how is working the loading process of an ad ?

I mean, do we have to launch the init every time before calling the “show” function ?

Or does it mean that the load process is automatically done before calling the “show” function ?

Is the “failed” callback covering an error occuring during the call of the “show” function ?

How can we know that an ad is available at any time ?

If my question isn’t in the right section, admins don’t hesitate to put it appropriatly.

Thanks for any advice.

In game rewards for installing apps…

Isn’t that against Apple Policy?

@christian.zoror

You should only call init() once. Offers are loaded automatically every time you call show().

Unfortunately it’s not possible to check if offers are available before calling show(), instead, a “failed” event will be sent if no offers are available after calling show().

thank you ingmar.

I have been wandering on the dashboard provided by trialpay and I’m amazed of how much controls are available to do the ads campains :smiley:

I’ll try to report for anybody curious to know how this plugin performs

Hi there,

So I try to play with trialpay and I am more than confused here:

It seems to me that the init function is not doing anything… I mean I try to show a message in the listener function but the message never appears…

My deduction is that the init function is not correctly designed I suppose in the sdk ?

Please could you tell me if you are able to pass a simple test case your side ?

Can you post the following:

  1. Which Corona build you are using
  2. Which device you are testing on (iOS/Android)
  3. Post the code you use for init() and show() including the listener

thanks ingemar.

I try to post here the code. There are 2 files

 --> 1 for the plugin iself

 --> 1 for a displaying UI

It runs on a android 5.1

the version of sdk:  2016.2983

plugin file:  Cls_Ads_Trialpay.lua

[lua]

local Cls_Ads_Trialpay = {}

function Cls_Ads_Trialpay:trialPayAdsListener( event )
    alert = native.showAlert( “Info”, "trialpay event type = " … event.type , { “OK” } )
    if ( event.type == “init” ) then  – lecture d’une publicite
        if event.isError then
            print( "trialpay ad event: initialisation Echec => " … tostring (event.response) )
            alert = native.showAlert( “Error”, "Initialisation ad trialpay echec: " … tostring (event.response), { “OK” } )
        else
            print( “trialpay ad event: init - OK” )
            alert = native.showAlert( “Info”, “Initialisation ad trialpay OK”, { “OK” } )
            self.isTrialPayLoaded = true;
        end

    elseif ( event.type == “failed” ) then
        print( "trialpay ad event: Erreur => " … tostring ( event.response ) )
        alert = native.showAlert( “Error”, "Ad trialpay failed: " … tostring (event.response), { “OK” } )

    elseif ( event.type == “closed” ) then
        print( "trialpay ad event: Ad Closed " )
        alert = native.showAlert( “Info”, “trialpay ad event: Ad Closed”, { “OK” } )

    elseif ( event.type == “reward” ) then
          print( “trialpay ad event: rewarded video completed”)
          alert = native.showAlert( “Info”, “trialpay ad event: rewarded video completed”, { “OK” } )    
          – event.data for the pairs key/value
    end
end

function Cls_Ads_Trialpay:new( APP_KEY_ID, UNIQUE_USER_ID )
    
    o_Cls_Ads_Trialpay = {};
    setmetatable( o_Cls_Ads_Trialpay, self )
    self.__index = self

    self.APP_ID_KEY    =     APP_KEY_ID
    self.USER_ID    =    UNIQUE_USER_ID
    
    self.trialPay = require( “plugin.trialPay” )
    self.isTrialPayLoaded = false;
    
    
    local function tpListener ( event )
        self:trialPayAdsListener( event )
    end

    self.trialPay.init( tpListener, { appKey = self.APP_ID_KEY, sid = self.USER_ID, APP_ID = self.APP_ID_KEY, UNIQUE_USER_ID = self.USER_ID,  app = self.APP_ID_KEY } )
    
    return o_Cls_Ads_Trialpay
end

function Cls_Ads_Trialpay:show ( name_of_ad_type )

    if self.isTrialPayLoaded then
        self.trialPay ( name_of_ad_type )
    else
        alert = native.showAlert( “Info”, “trialpay non initialisé - self.APP_ID_KEY = " … self.APP_ID_KEY … " / self.USER_ID =” … self.USER_ID, { “OK” } )    
    end
end

return Cls_Ads_Trialpay

[/lua]

And in the application UI:

[lua]

– ============================================================================
– TRIALPAY
– ============================================================================
 local trialpay = require (“classes.Cls_Ads_Trialpay”)
 local instance_trialpay_ads = trialpay:new ( “myKeyIDNumber”, “userID1” )
 
 function showTrialPayAd ()
     instance_trialpay_ads:show ( “evt_display_rewarded_vids” )    
 end
 

[/lua]

With evt_display_rewarded_vids  the name of my event for “Single Offer - Video or Action” - time_bonus_lvl1  as designed in my trialpay dashboard.

I am also having troubles with Appnext so I decided to have a look at the API again and

1- I see that for appnext the release build is written 2992 which I guess is more recent than mine for the sdk no ?

2- I also decided to study the example project provided and noted that all the buttons of widget are calling their function with

[lua]

function myclick( event )

    if “ended”==event.phase then

       do_something

    end

end

[/lua]

In my source code if I print (event.phase) the only answer I get is “began”  never “ended” …

So maybe should just i update my version of the SDK …

I’ll give it a try anyway

There are multiple issues:

  1. trialPay.init() only takes two parameters appKey and sid. The rest are invalid and should be removed. In fact the next version of the plugin will prevent you from specifying invalid parameters and will fail to initialize if you you try.
     
  2. You are checking event.type instead of event.phase in your listener.

Thank you I have made the corrections and I have noticed 2 things:

1- If I use my “custom” plugin class I get error code 417 

2- So I decided to use directly the trialpay plugin in the UI test source and here I only end up with “failed” event  … with nil in the response …

I don’t know exactly what’s going on but I am on the to try inMobi, supersonic and personaly … a bit deceiving though …

Hi there,

I am currently implementing a class for using with trialpay and I do have questions on the API.

In the documentation is explained that you have to call the “init” function premarily… but how is working the loading process of an ad ?

I mean, do we have to launch the init every time before calling the “show” function ?

Or does it mean that the load process is automatically done before calling the “show” function ?

Is the “failed” callback covering an error occuring during the call of the “show” function ?

How can we know that an ad is available at any time ?

If my question isn’t in the right section, admins don’t hesitate to put it appropriatly.

Thanks for any advice.

In game rewards for installing apps…

Isn’t that against Apple Policy?

@christian.zoror

You should only call init() once. Offers are loaded automatically every time you call show().

Unfortunately it’s not possible to check if offers are available before calling show(), instead, a “failed” event will be sent if no offers are available after calling show().

thank you ingmar.

I have been wandering on the dashboard provided by trialpay and I’m amazed of how much controls are available to do the ads campains :smiley:

I’ll try to report for anybody curious to know how this plugin performs

Hi there,

So I try to play with trialpay and I am more than confused here:

It seems to me that the init function is not doing anything… I mean I try to show a message in the listener function but the message never appears…

My deduction is that the init function is not correctly designed I suppose in the sdk ?

Please could you tell me if you are able to pass a simple test case your side ?

Can you post the following:

  1. Which Corona build you are using
  2. Which device you are testing on (iOS/Android)
  3. Post the code you use for init() and show() including the listener

thanks ingemar.

I try to post here the code. There are 2 files

 --> 1 for the plugin iself

 --> 1 for a displaying UI

It runs on a android 5.1

the version of sdk:  2016.2983

plugin file:  Cls_Ads_Trialpay.lua

[lua]

local Cls_Ads_Trialpay = {}

function Cls_Ads_Trialpay:trialPayAdsListener( event )
    alert = native.showAlert( “Info”, "trialpay event type = " … event.type , { “OK” } )
    if ( event.type == “init” ) then  – lecture d’une publicite
        if event.isError then
            print( "trialpay ad event: initialisation Echec => " … tostring (event.response) )
            alert = native.showAlert( “Error”, "Initialisation ad trialpay echec: " … tostring (event.response), { “OK” } )
        else
            print( “trialpay ad event: init - OK” )
            alert = native.showAlert( “Info”, “Initialisation ad trialpay OK”, { “OK” } )
            self.isTrialPayLoaded = true;
        end

    elseif ( event.type == “failed” ) then
        print( "trialpay ad event: Erreur => " … tostring ( event.response ) )
        alert = native.showAlert( “Error”, "Ad trialpay failed: " … tostring (event.response), { “OK” } )

    elseif ( event.type == “closed” ) then
        print( "trialpay ad event: Ad Closed " )
        alert = native.showAlert( “Info”, “trialpay ad event: Ad Closed”, { “OK” } )

    elseif ( event.type == “reward” ) then
          print( “trialpay ad event: rewarded video completed”)
          alert = native.showAlert( “Info”, “trialpay ad event: rewarded video completed”, { “OK” } )    
          – event.data for the pairs key/value
    end
end

function Cls_Ads_Trialpay:new( APP_KEY_ID, UNIQUE_USER_ID )
    
    o_Cls_Ads_Trialpay = {};
    setmetatable( o_Cls_Ads_Trialpay, self )
    self.__index = self

    self.APP_ID_KEY    =     APP_KEY_ID
    self.USER_ID    =    UNIQUE_USER_ID
    
    self.trialPay = require( “plugin.trialPay” )
    self.isTrialPayLoaded = false;
    
    
    local function tpListener ( event )
        self:trialPayAdsListener( event )
    end

    self.trialPay.init( tpListener, { appKey = self.APP_ID_KEY, sid = self.USER_ID, APP_ID = self.APP_ID_KEY, UNIQUE_USER_ID = self.USER_ID,  app = self.APP_ID_KEY } )
    
    return o_Cls_Ads_Trialpay
end

function Cls_Ads_Trialpay:show ( name_of_ad_type )

    if self.isTrialPayLoaded then
        self.trialPay ( name_of_ad_type )
    else
        alert = native.showAlert( “Info”, “trialpay non initialisé - self.APP_ID_KEY = " … self.APP_ID_KEY … " / self.USER_ID =” … self.USER_ID, { “OK” } )    
    end
end

return Cls_Ads_Trialpay

[/lua]

And in the application UI:

[lua]

– ============================================================================
– TRIALPAY
– ============================================================================
 local trialpay = require (“classes.Cls_Ads_Trialpay”)
 local instance_trialpay_ads = trialpay:new ( “myKeyIDNumber”, “userID1” )
 
 function showTrialPayAd ()
     instance_trialpay_ads:show ( “evt_display_rewarded_vids” )    
 end
 

[/lua]

With evt_display_rewarded_vids  the name of my event for “Single Offer - Video or Action” - time_bonus_lvl1  as designed in my trialpay dashboard.

I am also having troubles with Appnext so I decided to have a look at the API again and

1- I see that for appnext the release build is written 2992 which I guess is more recent than mine for the sdk no ?

2- I also decided to study the example project provided and noted that all the buttons of widget are calling their function with

[lua]

function myclick( event )

    if “ended”==event.phase then

       do_something

    end

end

[/lua]

In my source code if I print (event.phase) the only answer I get is “began”  never “ended” …

So maybe should just i update my version of the SDK …

I’ll give it a try anyway

There are multiple issues:

  1. trialPay.init() only takes two parameters appKey and sid. The rest are invalid and should be removed. In fact the next version of the plugin will prevent you from specifying invalid parameters and will fail to initialize if you you try.
     
  2. You are checking event.type instead of event.phase in your listener.

Thank you I have made the corrections and I have noticed 2 things:

1- If I use my “custom” plugin class I get error code 417 

2- So I decided to use directly the trialpay plugin in the UI test source and here I only end up with “failed” event  … with nil in the response …

I don’t know exactly what’s going on but I am on the to try inMobi, supersonic and personaly … a bit deceiving though …