Skip to main content
Embed can be configured to use multiple merchant accounts either using an admin API key or a merchant API key.

Set the merchant ID

Embed can be configured to explicitly take the merchant account ID to process a transaction for.

<Gr4vyEmbed
  gr4vyId='example'
  environment='sandbox'
  merchantAccountId='my-merchant-account-id'
  ...
/>
setup({
  gr4vyId: 'example',
  environment: 'sandbox',
  merchantAccountId: 'my-merchant-account-id',
  ...
})
Although it’s recommended to set the merchant ID, the ID falls back to default if not set, which is the standard ID for the single merchant account in a single merchant environment.

Pinning metadata

When using an API key that has access to multiple merchant accounts (an admin API key) it is recommended to pin the merchant_account_id value when generating an Embed token.
const token = await client.getEmbedToken({
  amount: 1299,
  currency: 'AUD',
  merchant_account_id: 'my-merchant-account-id'
})
Gr4vyClient client = new Gr4vyClient("[YOUR_GR4VY_ID]", "private_key.pem");
			
Map<String, Object> embed = new HashMap<String, Object>();
embed.put("amount", 1299);
embed.put("currency", "AUD");
embed.put("merchant_account_id", "my-merchant-account-id");

String token = client.getEmbedToken(embed);
embed = {
  "amount": 1299,
  "currency": "AUD",
  "merchant_account_id": "my-merchant-account-id",
}

token = client.generate_embed_token(embed)
echo $config->getEmbedToken(
  array(
    "amount" => 200,
    "currency" => "AUD",
    "merchant_account_id" => "my-merchant-account-id"
  )
);
Pinning is not required with merchant API keys as they are restricted to one single merchant account.