Integrating with Twitch #

Set up Twitch Drops #

You can map an Pragma offer to a Twitch Drop.

Twitch Docs:

Plugin configuration #

Client id and secret can be found under the Application settings. Make sure you use the application that maps to the organization that owns the game which drops/rewards are managed under.

social:
  shared:
    configs:
        Twitch:
          class: "pragma.shared.TwitchCredentialsConfig"
          config:
            clientId: "[client-id]"
            clientSecret: "[encrypted-client-secret]" # encrypted value  

  pluginConfigs:
    AccountService.identityProviderPlugins:
      plugins:
        Twitch:
          class: "pragma.account.TwitchIdentityProviderPlugin"
          config:
            sharedConfigKey: "Twitch"
            playerLoginEnabled: true
            accountLinkingEnabled: true
            accountLinkingCooldownInDays: 30            
    ThirdPartyNodeService.orderProviderPlugins:
      plugins:
        Twitch:
          class: "pragma.order.TwitchOrderProviderPlugin"
          config:
            sharedConfigKey: "Twitch"
            gameId: "[game-id-assigned-in-Twitch]"    
Encrypting config values

All secrets must be encrypted and decrypted per shard. Shards use different encryption keys.

  1. Connect to the VPN using the *.ovpn file provided to you during onboarding.
  2. Navigate to your Homebase API URL: https://api.homebase.<studioname>.pragmaengine.com/
  3. Choose /secrets/encryptV1
  4. Enter the following values in the request body:
    1. shardId - The name of the shard you are encrypting a value for.
    2. titleId - The working title of your game that uses the secret.
    3. value - The secret you’re encrypting.

Your encrypted secret will appear below in the Responses section.

Any configuration set through the portal will override any values assigned in a config yml file.
  • Do not manually encrypt any secrets. The API automatically encrypts all sensitive values during submission.
  • You only need to enter credential values in one form. Portal will store credentials under shared config.

Order provider configuration #

  1. Navigate to the Order Providers page: select the Commerce Tab → Order Providers in side menu.
  2. Select platform to configure and fill out the form.
  3. Click Confirm to see changes.
  4. Click Deploy to apply changes.

order-providers-config-portal

Id provider configuration #

  1. Navigate to the ID Provider page: select the Accounts Tab → ID Provider in the side menu.
  2. Select a provider and fill out the form.
  3. Click Confirm to see changes.
  4. Click Deploy to apply changes.

id-providers-config-portal

Order mapping example #

Map each Twitch reward id to an order sku.

[project]/content/src/OrderMappingsSpecs.json

{
    "skuId": "SmallGoldBundle",
    "sources": [
        {
            "provider" : "TWITCH"
            "twitchSource" : {
                "rewardId" : "[twitch-reward-id]"
            }
        }
    ]
}

Run the content apply command to validate and generate content catalogs.

./pragma content apply

Testing #

To test order processing on a local or dev environment there are a couple of things you can do to make things easier.

  • This lets you authenticate and call the fulfill orders API through a unsafe account.
  • You can use the Postman collection for this flow.

Test Campaigns #

  • You cannot manually grant Twitch rewards.
  • Twitch does support a test mode for a campaign.

Refunds and charge backs #

Twitch does not support refunds on drops that have been consumed. If Pragma has recorded an order for a Twitch drop, it has been consumed and can not be returned.