+31 (0) 20 760 2040 info@spilgames.com

Trigger Payment Screen

Note

In case you are using Dynamic Pricing you should skip this step.

Trigger the payment selection screen

After including the JavaScript client, you can access the PaymentClient variable. You can create an instance of this variable, as shown on the first line in the code example below.

Important Note:
If your game allows guest users, make sure that guest users are not able to invoke the Payment Selection Screen. In case a guest user click on Payment Button the best way to tackle it is:

  1. Display a message that guest users are not allowed to pay and they should login. You can place a login button on the message. (This is a nice to have step)
  2. Invoke the login button (see on Force Authentication)
  3. Be careful to save the users progress. After sign-in the user will become from guest to registered and keep the same GUID.

 

showPaymentSelectionScreen method

Method Definition
showPaymentSelectionScreen(options)
Use this method to trigger the payment selection screen.

Input

The showPaymentSelectionScreen method takes an object as its only argument. The object argument is a key-value pair representation of the parameters that define the content of the payment selection screen.

Name Type Mandatory? Definition
options object Yes Method parameterThis object holds the key-value pairs with the relevant configuration options for the payment selection screen.
Key-value pair parameters for the options object

The table below describes the options object attributes:

 
Name Type Mandatory? Definition
siteId string Yes Object property. Defines the unique identifier for the portal/site.Example: 88
gameId integer Yes Object property. Defines the unique identifier for the game. This value is automatically generated in the payment administration tool,when you add a new game as a Publisher. Example: 114
userId string Yes Object property. Defines the user name, as registered with Spil Games. You can retrieve this data through the API. Example: james_kirk
token integer|string Yes Object property. Defines the unique identifier for the transaction. This data is generated by the game developer. Example: ncc-1701
params integer No Object property. Defines additional optional custom parameters you may wish to include in the callback notification e-mail body. It has a limit of 200 characters. Example: test=true&log=true
selectedSku string No Object property. Defines the SKU type that will be selected when the user open the payment screen in case you are offering multiple SKU types. You should pass the Name of the SKU type and not the default text of it.

Output

N/A

Examples

Note

All code examples are syntactically correct, but they use dummy data values.
When you copy-paste these examples, make sure you replace the dummy data with actual, valid data.

Options Object

The showPaymentSelectionScreen method takes an object as its only argument. The object argument is a key-value pair representation of the parameters used to determine the content of the payment selection screen:


 


var client = new PaymentClient();
var options = {
    'siteId': 88,
    'gameId': 114,
    'userId': 'john.doe',
    'token': 'example-token-1234',
    'params': 'action=payment_source=spilgames',
    'selectedSku': 'greendiamonds'
};

client.showPaymentSelectionScreen(options);

 

Instant Triggering

 

To trigger the payment selection screen to automatically open, implement the following code:

 


var client = new PaymentClient();

if (client.hasExternalTrigger()) {
    // Set options (see the "options object" example in this section)
    client.showPaymentSelectionScreen(options);
}