Pay3 Unity Integration
Initialize
2min
the unity sdk needs to be initialised with configuration information associated with the mobile application, firebase realtime database and pay3 environment settings initialization parameters pay3hostname pay3 will be opened in a new window using this hostname prefix the host name is environment dependent pay3clientid a unique client id is created for each client application the client id is environment dependent appnotify configs these are config parameters for firebase realtime database this is used to publish realtime events to the app appdeeplink this string in the form of scheme //resource can be passed during initalization this will be used by pay3 as referrer / redirect intent the string needs to be whitelisted in pay3 backend for proper working of the pay3 services following are the sample code snippets for your reference the entire package with complete example will be provided during onboarding game can use pay3sdkconfig cs which extends scriptableobject this accepts all settings required for pay3 sdk game can create an asset using this the asset needs to be passed to pay3helper cs instance pay3sdkconfig cs using unityengine; \[createassetmenu(filename = "pay3sdkconfig", menuname = "scriptableobjects/pay3sdkconfig", order = 1)] public class pay3sdkconfig scriptableobject { public string androidpackageid; public string appnotifyapikey; public string appnotifyappid; public string appnotifyprojectid; public string appnotifydatabaseurl; public string appnotifystoragebucket; public string appdeeplink; public string pay3clientid; public string pay3hostname; } game can instantiate pay3helper cs that extends monobehaviour this loads configuration from pay3sdkconfig during the start pay3helper cs namespace pay3 sdk helper { // import essential packages using firebase auth; using firebase database; using firebase; using unityengine; public class pay3helper monobehaviour { // attach the pay3sdkconfig to this behaviour public pay3sdkconfig sdkconfig; // when the app starts, check to make sure that we have // the required dependencies to use firebase, and if not, // add them if possible public virtual void start() { initializefirebaseauth(); } // handle initialization of the necessary firebase modules private void initializefirebaseauth() { authoptions = new firebase appoptions { // use configuration from pay3sdk config }; fbapp = firebase firebaseapp create(authoptions, "pay3"); auth = firebase auth firebaseauth getauth(fbapp); signinanonymously(); } // request anonymous sign in and wait until asynchronous call completes private void signinanonymously() { auth signinanonymouslyasync() continuewith((authtask) => { if (authtask iscompleted) { firebase auth firebaseuser user = authtask result user; starttransactionlistener(user userid); } }); } } }