- Reduced user friction and declined payments because network tokens are maintained by card schemes.
- Higher authorisation rates compared to payments made without network tokens.
- Better payment security because each transaction is protected with a one-time use cryptogram.
Requirements
Before you begin, make sure that you fulfill the following requirements:| Requirement | Description |
|---|---|
| Integration type | You must have an integration that supports Issuing. |
| API credentials | You need an API credential for the Configuration API that has the following role: Gives the user permissions to read and patch the NetworkTokens that are linked to the accounts they are able to access |
Get all network tokens
To get all network tokens that are linked to the Adyen-issued card:-
Make a GET /paymentInstruments/{id}/networkTokens request and specify the following parameter in the path:
Get all network tokens of a card
Path parameter Description idThe identifier of the payment instrument created when issuing a card. curl
curl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/PI3227C223222B5BPCMFXD2XG/networkTokens \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X GET \ -d ''Java
// Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.service.balancePlatform.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Make the API call PaymentInstrumentsApi service = new PaymentInstrumentsApi(client); ListNetworkTokensResponse response = service.listNetworkTokens("id", null);PHP
// Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Service\BalancePlatform\PaymentInstrumentsApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Make the API call $service = new PaymentInstrumentsApi($client); $response = $service->listNetworkTokens('id');C#
// Adyen .net API Library v14.4.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Service.BalancePlatform; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Make the API call var service = new PaymentInstrumentsService(client); var response = service.ListNetworkTokens("id");NodeJS (JavaScript)
// Adyen Node API Library v16.2.0 // Require the parts of the module you want to use const { Client, BalancePlatformAPI } = require('@adyen/api-library'); // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Make the API call const balancePlatformAPI = new BalancePlatformAPI(client); const response = balancePlatformAPI.PaymentInstrumentsApi.listNetworkTokens("id");Go
// Adyen Go API Library v9.3.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/balancePlatform" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Make the API call service := client.BalancePlatform() req := service.PaymentInstrumentsApi.ListNetworkTokensInput("id") res, httpRes, err := service.PaymentInstrumentsApi.ListNetworkTokens(context.Background(), req)Python
# Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. # Make the API call result = adyen.balancePlatform.payment_instruments_api.list_network_tokens(id="id")Ruby
# Adyen Ruby API Library v9.3.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment # Make the API call result = adyen.balancePlatform.payment_instruments_api.list_network_tokens('id')NodeJS (TypeScript)
// Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, BalancePlatformAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Make the API call const balancePlatformAPI = new BalancePlatformAPI(client); const response = balancePlatformAPI.PaymentInstrumentsApi.listNetworkTokens("id"); -
Verify that you receive an HTTP 200 — OK response that returns all network tokens associated with the payment instrument, regardless of the network token status. For each network token, note the parameters in the following table:
Response
Parameter Description Possible values typeThe type of wallet the network token is associated with. applePay, googlePay idThe unique identifier of the network token. NWTK00000000000000000000000001 paymentInstrumentIdThe unique identifier of the payment instrument. PI3227C223222B5BPCMFXD2XG creationDateDate and time when the network token was created. 2021-01-01T01:00:00+01:00 statusThe status of the network token. active, inactive, suspended, closed. brandVariantThe card brand variant of the payment instrument associated with the network token. mcmaestro, mc_prepaid_mrw, etc. tokenLastFourThe last four digits of the network token id.0001 device.osNameThe operating system of the device the network token is stored on. android, ios, other. device.formFactorThe form factor of the device the network token is stored on. phone, watch, tablet, other. { "data": [ { "type": "applePay", "id": "NWTK00000000000000000000000001", "paymentInstrumentId": "PI3227C223222B5BPCMFXD2XG", "creationDate": "2020-01-01T01:00:00+01:00", "status": "active", "brandVariant": "mcmaestro", "tokenLastFour": "0001", "device": { "osName": "ios", "formFactor": "phone" } }, { "type": "googlePay", "id": "NWTK00000000000000000000000002", "paymentInstrumentId": "PI3227C223222B5BPCMFXD2XG", "creationDate": "2021-01-01T01:00:00+01:00", "status": "suspended", "brandVariant": "mc_prepaid_mrw", "tokenLastFour": "0002", "device": { "osName": "android", "formFactor": "watch" } } ] }
Get a single network token
To get the details of a single network token that is linked to the Adyen-issued card:-
Make a GET /networkTokens/{networkTokenId} request and specify the following parameter in the path:
Get a single network token of a card
Path parameter Description networkTokenIdThe identifier of the network token associated with the card. curl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/PI3227C223222B5BPCMFXD2XG/networkTokens/NWTK00000000000000000000000001 \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X GET \ -d '' -
Verify that you receive an HTTP 200 — OK response that contains the details for the network token associated with the payment instrument. Note the parameters in the following table:
Response
Parameter Description Possible values typeThe type of wallet the network token is associated with. wallet, cof idThe unique identifier of the network token. An alphanumeric string. paymentInstrumentIdThe unique identifier of the payment instrument. An alphanumeric string. creationDateThe date and time when the network token was created. Date in ISO-8601 format. statusThe status of the network token. active, inactive, suspended, closed brandVariantThe card brand variant of the payment instrument associated with the network token. mcmaestro, mc_prepaid_mrw tokenLastFourThe last four digits of the network token id.A string of four numbers. tokenRequestor.idThe unique identifier of the entity that requested the network token. A string of numbers. tokenRequestor.nameThe name of the entity that requested the network token. googlePay, applePay device.osNameThe operating system of the device the network token is stored on. android, ios, or other device.formFactorThe type of device used to provision the network token. phone, watch, tablet, or other { "type": "wallet", "id": "NWTK00000000000000000000000001", "paymentInstrumentId": "PI00000000000000000000001", "creationDate": "2020-01-01T01:00:00+01:00", "status": "active", "brandVariant": "mcmaestro", "tokenLastFour": "0001", "tokenRequestor": { "id": "40012345678", "name": "googlePay" }, "device": { "osName": "ios", "formFactor": "phone" } }
Update the status of a network token
You can update the status of a network token to:- Manually activate a network token after completing phone call authentication: You change the status from inactive to active.
- Temporarily suspend a network token: You change the status from active to suspended.
- Reactivate a suspended token: You change the status from suspended to active.
- Permanently close a network token: You change the status from active or suspended to closed.
-
Make a PATCH /networkTokens/{networkTokenId} request and specify the following parameter in the path:
Provide the following parameters in the request body:
Path parameter Description networkTokenIdThe identifier of the network token associated with the card. Here’s an example of how to change theParameter Required Description status
The status of the network token. Possible values: active, suspended, closed. The closed status is final and cannot be changed. statusof the network token to suspended. Update the status of a network tokencurl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/PI3227C223222B5BPCMFXD2XG/networkTokens/NWTK00000000000000000000000001 \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X PATCH \ -d '{ "status": "suspended" }' - Verify that you receive an HTTP 202 — Accepted response with no content. This response means that the request has been accepted, but will be processed asynchronously.
- Listen to webhooks to receive the final result of this request.
Limit the usage of a network token
In some cases, you might need to limit the number of network tokens per card or set limits for transactions that use network tokens. You can do so by using the/transactionRules endpoint.
Limit the number of active network tokens
To limit the number of active network tokens allowed for a single card:-
Send a POST /transactionRules request and specify the following parameters:
The following example shows how to limit the number of active network tokens to only one per card. Limit the number of active network tokens for a card
Parameter Required Description description 
Your description for the rule. Maximum length: 300 characters. This description is shown in the Customer Area. entityKey 
Contains the ID and type of resource to which the rule is applied. interval 
The time period or duration when the rule applies. reference 
Your reference for the rule. Maximum length: 150 characters. type 
Set to blockList, maxUsage, or velocity. ruleRestrictions 
Object that contains key-value objects with the key as the condition and the value containing values and operations. status Set to active if you want to start evaluating the rule. When you set the status to active, we automatically set the startDateto the current time.curl
curl https://balanceplatform-api-test.adyen.com/bcl/v2/transactionRules \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X POST \ -d '{ "interval": { "type": "perTransaction" }, "type": "blockList", "description": "Set the maximum number of active network tokens to one for this card", "reference": "myRule123", "entityKey": { "entityType": "paymentInstrument", "entityReference": "PI3227C223222B5FN65FN5NS9" }, "ruleRestrictions": { "activeNetworkTokens": { "operation": "greaterThanOrEqualTo", "value": 1 } }, "status": "active", "requestType": "authorization", "outcomeType": "hardBlock" }'Java
// Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.balancePlatform.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.service.balancePlatform.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Create the request object(s) ActiveNetworkTokensRestriction activeNetworkTokensRestriction = new ActiveNetworkTokensRestriction() .operation("greaterThanOrEqualTo") .value(1); TransactionRuleEntityKey transactionRuleEntityKey = new TransactionRuleEntityKey() .entityType("paymentInstrument") .entityReference("PI3227C223222B5FN65FN5NS9"); TransactionRuleInterval transactionRuleInterval = new TransactionRuleInterval() .type(TransactionRuleInterval.TypeEnum.PERTRANSACTION); TransactionRuleRestrictions transactionRuleRestrictions = new TransactionRuleRestrictions() .activeNetworkTokens(activeNetworkTokensRestriction); TransactionRuleInfo transactionRuleInfo = new TransactionRuleInfo() .reference("myRule123") .outcomeType(TransactionRuleInfo.OutcomeTypeEnum.HARDBLOCK) .requestType(TransactionRuleInfo.RequestTypeEnum.AUTHORIZATION) .entityKey(transactionRuleEntityKey) .description("Set the maximum number of active network tokens to one for this card") .interval(transactionRuleInterval) .ruleRestrictions(transactionRuleRestrictions) .type(TransactionRuleInfo.TypeEnum.BLOCKLIST) .status(TransactionRuleInfo.StatusEnum.ACTIVE); // Make the API call TransactionRulesApi service = new TransactionRulesApi(client); TransactionRule response = service.createTransactionRule(transactionRuleInfo, null);PHP
// Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\BalancePlatform\TransactionRuleEntityKey; use Adyen\Model\BalancePlatform\TransactionRuleInterval; use Adyen\Model\BalancePlatform\TransactionRuleRestrictions; use Adyen\Model\BalancePlatform\ActiveNetworkTokensRestriction; use Adyen\Model\BalancePlatform\TransactionRuleInfo; use Adyen\Service\BalancePlatform\TransactionRulesApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Create the request object(s) $activeNetworkTokensRestriction = new ActiveNetworkTokensRestriction(); $activeNetworkTokensRestriction ->setOperation("greaterThanOrEqualTo") ->setValue(1); $transactionRuleEntityKey = new TransactionRuleEntityKey(); $transactionRuleEntityKey ->setEntityType("paymentInstrument") ->setEntityReference("PI3227C223222B5FN65FN5NS9"); $transactionRuleInterval = new TransactionRuleInterval(); $transactionRuleInterval ->setType("perTransaction"); $transactionRuleRestrictions = new TransactionRuleRestrictions(); $transactionRuleRestrictions ->setActiveNetworkTokens($activeNetworkTokensRestriction); $transactionRuleInfo = new TransactionRuleInfo(); $transactionRuleInfo ->setReference("myRule123") ->setOutcomeType("hardBlock") ->setRequestType("authorization") ->setEntityKey($transactionRuleEntityKey) ->setDescription("Set the maximum number of active network tokens to one for this card") ->setInterval($transactionRuleInterval) ->setRuleRestrictions($transactionRuleRestrictions) ->setType("blockList") ->setStatus("active"); // Make the API call $service = new TransactionRulesApi($client); $response = $service->createTransactionRule($transactionRuleInfo);C#
// Adyen .net API Library v14.4.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.BalancePlatform; using Adyen.Service.BalancePlatform; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Create the request object(s) ActiveNetworkTokensRestriction activeNetworkTokensRestriction = new ActiveNetworkTokensRestriction { Operation = "greaterThanOrEqualTo", Value = 1 }; TransactionRuleEntityKey transactionRuleEntityKey = new TransactionRuleEntityKey { EntityType = "paymentInstrument", EntityReference = "PI3227C223222B5FN65FN5NS9" }; TransactionRuleInterval transactionRuleInterval = new TransactionRuleInterval { Type = TransactionRuleInterval.TypeEnum.PerTransaction }; TransactionRuleRestrictions transactionRuleRestrictions = new TransactionRuleRestrictions { ActiveNetworkTokens = activeNetworkTokensRestriction }; TransactionRuleInfo transactionRuleInfo = new TransactionRuleInfo { Reference = "myRule123", OutcomeType = TransactionRuleInfo.OutcomeTypeEnum.HardBlock, RequestType = TransactionRuleInfo.RequestTypeEnum.Authorization, EntityKey = transactionRuleEntityKey, Description = "Set the maximum number of active network tokens to one for this card", Interval = transactionRuleInterval, RuleRestrictions = transactionRuleRestrictions, Type = TransactionRuleInfo.TypeEnum.BlockList, Status = TransactionRuleInfo.StatusEnum.Active }; // Make the API call var service = new TransactionRulesService(client); var response = service.CreateTransactionRule(transactionRuleInfo);NodeJS (JavaScript)
// Adyen Node API Library v16.2.0 // Require the parts of the module you want to use const { Client, BalancePlatformAPI } = require('@adyen/api-library'); // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object(s) const transactionRuleInfo = { interval: { type: "perTransaction" }, type: "blockList", description: "Set the maximum number of active network tokens to one for this card", reference: "myRule123", entityKey: { entityType: "paymentInstrument", entityReference: "PI3227C223222B5FN65FN5NS9" }, ruleRestrictions: { activeNetworkTokens: { operation: "greaterThanOrEqualTo", value: 1 } }, status: "active", requestType: "authorization", outcomeType: "hardBlock" } // Make the API call const balancePlatformAPI = new BalancePlatformAPI(client); const response = balancePlatformAPI.TransactionRulesApi.createTransactionRule(transactionRuleInfo);Go
// Adyen Go API Library v9.3.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/balancePlatform" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) activeNetworkTokensRestriction := balancePlatform.ActiveNetworkTokensRestriction{ Operation: "greaterThanOrEqualTo", Value: common.PtrInt32(1), } transactionRuleEntityKey := balancePlatform.TransactionRuleEntityKey{ EntityType: common.PtrString("paymentInstrument"), EntityReference: common.PtrString("PI3227C223222B5FN65FN5NS9"), } transactionRuleInterval := balancePlatform.TransactionRuleInterval{ Type: "perTransaction", } transactionRuleRestrictions := balancePlatform.TransactionRuleRestrictions{ ActiveNetworkTokens: &activeNetworkTokensRestriction, } transactionRuleInfo := balancePlatform.TransactionRuleInfo{ Reference: "myRule123", OutcomeType: common.PtrString("hardBlock"), RequestType: common.PtrString("authorization"), EntityKey: transactionRuleEntityKey, Description: "Set the maximum number of active network tokens to one for this card", Interval: transactionRuleInterval, RuleRestrictions: transactionRuleRestrictions, Type: "blockList", Status: common.PtrString("active"), } // Make the API call service := client.BalancePlatform() req := service.TransactionRulesApi.CreateTransactionRuleInput().TransactionRuleInfo(transactionRuleInfo) res, httpRes, err := service.TransactionRulesApi.CreateTransactionRule(context.Background(), req)Python
# Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "interval": { "type": "perTransaction" }, "type": "blockList", "description": "Set the maximum number of active network tokens to one for this card", "reference": "myRule123", "entityKey": { "entityType": "paymentInstrument", "entityReference": "PI3227C223222B5FN65FN5NS9" }, "ruleRestrictions": { "activeNetworkTokens": { "operation": "greaterThanOrEqualTo", "value": 1 } }, "status": "active", "requestType": "authorization", "outcomeType": "hardBlock" } # Make the API call result = adyen.balancePlatform.transaction_rules_api.create_transaction_rule(request=json_request)Ruby
# Adyen Ruby API Library v9.3.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { :interval => { :type => 'perTransaction' }, :type => 'blockList', :description => 'Set the maximum number of active network tokens to one for this card', :reference => 'myRule123', :entityKey => { :entityType => 'paymentInstrument', :entityReference => 'PI3227C223222B5FN65FN5NS9' }, :ruleRestrictions => { :activeNetworkTokens => { :operation => 'greaterThanOrEqualTo', :value => 1 } }, :status => 'active', :requestType => 'authorization', :outcomeType => 'hardBlock' } # Make the API call result = adyen.balancePlatform.transaction_rules_api.create_transaction_rule(request_body)NodeJS (TypeScript)
// Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, BalancePlatformAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object(s) const activeNetworkTokensRestriction: Types.balancePlatform.ActiveNetworkTokensRestriction = { operation: "greaterThanOrEqualTo", value: 1 }; const transactionRuleEntityKey: Types.balancePlatform.TransactionRuleEntityKey = { entityType: "paymentInstrument", entityReference: "PI3227C223222B5FN65FN5NS9" }; const transactionRuleInterval: Types.balancePlatform.TransactionRuleInterval = { type: Types.balancePlatform.TransactionRuleInterval.TypeEnum.PerTransaction }; const transactionRuleRestrictions: Types.balancePlatform.TransactionRuleRestrictions = { activeNetworkTokens: activeNetworkTokensRestriction }; const transactionRuleInfo: Types.balancePlatform.TransactionRuleInfo = { reference: "myRule123", outcomeType: Types.balancePlatform.TransactionRuleInfo.OutcomeTypeEnum.HardBlock, requestType: Types.balancePlatform.TransactionRuleInfo.RequestTypeEnum.Authorization, entityKey: transactionRuleEntityKey, description: "Set the maximum number of active network tokens to one for this card", interval: transactionRuleInterval, ruleRestrictions: transactionRuleRestrictions, type: Types.balancePlatform.TransactionRuleInfo.TypeEnum.BlockList, status: Types.balancePlatform.TransactionRuleInfo.StatusEnum.Active }; // Make the API call const balancePlatformAPI = new BalancePlatformAPI(client); const response = balancePlatformAPI.TransactionRulesApi.createTransactionRule(transactionRuleInfo); -
Verify that you receive an HTTP 200 — OK response that returns the
idof the transaction rule that can be used to further update or delete this rule. Response—Transaction rule successfully created{ "description": "Set the maximum number of active network tokens to one for this card", "entityKey": { "entityReference": "PI3227C223222B5FN65FN5NS9", "entityType": "paymentInstrument" }, "interval": { "timeZone": "UTC", "type": "perTransaction" }, "outcomeType": "hardBlock", "reference": "myRule123", "requestType": "authorization", "ruleRestrictions": { "activeNetworkTokens": { "operation": "greaterThanOrEqualTo", "value": 1 } }, "startDate": "2022-10-05T10:44:15.608698+02:00", "status": "active", "type": "blockList", "id": "TR32272223222C5GP4S4K5NZG" }
Limit transactions using network tokens
To limit the transactions using network tokens for a card:-
Make a POST /transactionRules request and specify the following parameters:
The following example shows how to block transactions that are greater than EUR 50 and use network tokens. Block the transactions using network tokens
Parameter Required Description description 
Your description for the rule. Maximum length: 300 characters. This description is shown in the Customer Area. entityKey 
Contains the ID and type of resource to which the rule is applied. interval 
The time period or duration when the rule applies. reference 
Your reference for the rule. Maximum length: 150 characters. type 
Set to blockList, maxUsage, or velocity. ruleRestrictions 
Object that contains key-value objects with the key as the condition and the value containing values and operations. status Set to active if you want to start evaluating the rule. When you set the status to active, we automatically set the startDateto the current time.curl
curl https://balanceplatform-api-test.adyen.com/bcl/v2/transactionRules \ -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \ -H 'content-type: application/json' \ -X POST \ -d '{ "description": "Block network token transactions above EUR 50", "reference": "myRule123", "entityKey": { "entityType": "paymentInstrument", "entityReference": "PI3227C223222B5FN65FN5NS9" }, "interval": { "type": "perTransaction" }, "ruleRestrictions": { "processingTypes": { "operation": "anyMatch", "value": [ "token" ] }, "totalAmount": { "operation": "greaterThan", "value": { "currency": "EUR", "value": 5000 } } }, "status": "active", "outcomeType": "hardBlock", "type": "velocity" }'Java
// Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.balancePlatform.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.service.balancePlatform.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Create the request object(s) Amount amount = new Amount() .currency("EUR") .value(5000L); TotalAmountRestriction totalAmountRestriction = new TotalAmountRestriction() .operation("greaterThan") .value(amount); ProcessingTypesRestriction processingTypesRestriction = new ProcessingTypesRestriction() .operation("anyMatch") .value(Arrays.asList(ProcessingTypesRestriction.ValueEnum.TOKEN)); TransactionRuleEntityKey transactionRuleEntityKey = new TransactionRuleEntityKey() .entityType("paymentInstrument") .entityReference("PI3227C223222B5FN65FN5NS9"); TransactionRuleInterval transactionRuleInterval = new TransactionRuleInterval() .type(TransactionRuleInterval.TypeEnum.PERTRANSACTION); TransactionRuleRestrictions transactionRuleRestrictions = new TransactionRuleRestrictions() .totalAmount(totalAmountRestriction) .processingTypes(processingTypesRestriction); TransactionRuleInfo transactionRuleInfo = new TransactionRuleInfo() .reference("myRule123") .outcomeType(TransactionRuleInfo.OutcomeTypeEnum.HARDBLOCK) .entityKey(transactionRuleEntityKey) .description("Block network token transactions above EUR 50") .interval(transactionRuleInterval) .ruleRestrictions(transactionRuleRestrictions) .type(TransactionRuleInfo.TypeEnum.VELOCITY) .status(TransactionRuleInfo.StatusEnum.ACTIVE); // Make the API call TransactionRulesApi service = new TransactionRulesApi(client); TransactionRule response = service.createTransactionRule(transactionRuleInfo, null);PHP
// Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\BalancePlatform\TransactionRuleEntityKey; use Adyen\Model\BalancePlatform\TransactionRuleInterval; use Adyen\Model\BalancePlatform\TransactionRuleRestrictions; use Adyen\Model\BalancePlatform\Amount; use Adyen\Model\BalancePlatform\TotalAmountRestriction; use Adyen\Model\BalancePlatform\ProcessingTypesRestriction; use Adyen\Model\BalancePlatform\TransactionRuleInfo; use Adyen\Service\BalancePlatform\TransactionRulesApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Create the request object(s) $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(5000); $totalAmountRestriction = new TotalAmountRestriction(); $totalAmountRestriction ->setOperation("greaterThan") ->setValue($amount); $processingTypesRestriction = new ProcessingTypesRestriction(); $processingTypesRestriction ->setOperation("anyMatch") ->setValue(array("token")); $transactionRuleEntityKey = new TransactionRuleEntityKey(); $transactionRuleEntityKey ->setEntityType("paymentInstrument") ->setEntityReference("PI3227C223222B5FN65FN5NS9"); $transactionRuleInterval = new TransactionRuleInterval(); $transactionRuleInterval ->setType("perTransaction"); $transactionRuleRestrictions = new TransactionRuleRestrictions(); $transactionRuleRestrictions ->setTotalAmount($totalAmountRestriction) ->setProcessingTypes($processingTypesRestriction); $transactionRuleInfo = new TransactionRuleInfo(); $transactionRuleInfo ->setReference("myRule123") ->setOutcomeType("hardBlock") ->setEntityKey($transactionRuleEntityKey) ->setDescription("Block network token transactions above EUR 50") ->setInterval($transactionRuleInterval) ->setRuleRestrictions($transactionRuleRestrictions) ->setType("velocity") ->setStatus("active"); // Make the API call $service = new TransactionRulesApi($client); $response = $service->createTransactionRule($transactionRuleInfo);C#
// Adyen .net API Library v14.4.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.BalancePlatform; using Adyen.Service.BalancePlatform; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Create the request object(s) Amount amount = new Amount { Currency = "EUR", Value = 5000 }; TotalAmountRestriction totalAmountRestriction = new TotalAmountRestriction { Operation = "greaterThan", Value = amount }; ProcessingTypesRestriction processingTypesRestriction = new ProcessingTypesRestriction { Operation = "anyMatch", Value = { ProcessingTypesRestriction.ValueEnum.Token } }; TransactionRuleEntityKey transactionRuleEntityKey = new TransactionRuleEntityKey { EntityType = "paymentInstrument", EntityReference = "PI3227C223222B5FN65FN5NS9" }; TransactionRuleInterval transactionRuleInterval = new TransactionRuleInterval { Type = TransactionRuleInterval.TypeEnum.PerTransaction }; TransactionRuleRestrictions transactionRuleRestrictions = new TransactionRuleRestrictions { TotalAmount = totalAmountRestriction, ProcessingTypes = processingTypesRestriction }; TransactionRuleInfo transactionRuleInfo = new TransactionRuleInfo { Reference = "myRule123", OutcomeType = TransactionRuleInfo.OutcomeTypeEnum.HardBlock, EntityKey = transactionRuleEntityKey, Description = "Block network token transactions above EUR 50", Interval = transactionRuleInterval, RuleRestrictions = transactionRuleRestrictions, Type = TransactionRuleInfo.TypeEnum.Velocity, Status = TransactionRuleInfo.StatusEnum.Active }; // Make the API call var service = new TransactionRulesService(client); var response = service.CreateTransactionRule(transactionRuleInfo);NodeJS (JavaScript)
// Adyen Node API Library v16.2.0 // Require the parts of the module you want to use const { Client, BalancePlatformAPI } = require('@adyen/api-library'); // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object(s) const transactionRuleInfo = { description: "Block network token transactions above EUR 50", reference: "myRule123", entityKey: { entityType: "paymentInstrument", entityReference: "PI3227C223222B5FN65FN5NS9" }, interval: { type: "perTransaction" }, ruleRestrictions: { processingTypes: { operation: "anyMatch", value: [ "token" ] }, totalAmount: { operation: "greaterThan", value: { currency: "EUR", value: 5000 } } }, status: "active", outcomeType: "hardBlock", type: "velocity" } // Make the API call const balancePlatformAPI = new BalancePlatformAPI(client); const response = balancePlatformAPI.TransactionRulesApi.createTransactionRule(transactionRuleInfo);Go
// Adyen Go API Library v9.3.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/balancePlatform" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) amount := balancePlatform.Amount{ Currency: "EUR", Value: 5000, } totalAmountRestriction := balancePlatform.TotalAmountRestriction{ Operation: "greaterThan", Value: &amount, } processingTypesRestriction := balancePlatform.ProcessingTypesRestriction{ Operation: "anyMatch", Value: []string{ "token", }, } transactionRuleEntityKey := balancePlatform.TransactionRuleEntityKey{ EntityType: common.PtrString("paymentInstrument"), EntityReference: common.PtrString("PI3227C223222B5FN65FN5NS9"), } transactionRuleInterval := balancePlatform.TransactionRuleInterval{ Type: "perTransaction", } transactionRuleRestrictions := balancePlatform.TransactionRuleRestrictions{ TotalAmount: &totalAmountRestriction, ProcessingTypes: &processingTypesRestriction, } transactionRuleInfo := balancePlatform.TransactionRuleInfo{ Reference: "myRule123", OutcomeType: common.PtrString("hardBlock"), EntityKey: transactionRuleEntityKey, Description: "Block network token transactions above EUR 50", Interval: transactionRuleInterval, RuleRestrictions: transactionRuleRestrictions, Type: "velocity", Status: common.PtrString("active"), } // Make the API call service := client.BalancePlatform() req := service.TransactionRulesApi.CreateTransactionRuleInput().TransactionRuleInfo(transactionRuleInfo) res, httpRes, err := service.TransactionRulesApi.CreateTransactionRule(context.Background(), req)Python
# Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "description": "Block network token transactions above EUR 50", "reference": "myRule123", "entityKey": { "entityType": "paymentInstrument", "entityReference": "PI3227C223222B5FN65FN5NS9" }, "interval": { "type": "perTransaction" }, "ruleRestrictions": { "processingTypes": { "operation": "anyMatch", "value": [ "token" ] }, "totalAmount": { "operation": "greaterThan", "value": { "currency": "EUR", "value": 5000 } } }, "status": "active", "outcomeType": "hardBlock", "type": "velocity" } # Make the API call result = adyen.balancePlatform.transaction_rules_api.create_transaction_rule(request=json_request)Ruby
# Adyen Ruby API Library v9.3.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { :description => 'Block network token transactions above EUR 50', :reference => 'myRule123', :entityKey => { :entityType => 'paymentInstrument', :entityReference => 'PI3227C223222B5FN65FN5NS9' }, :interval => { :type => 'perTransaction' }, :ruleRestrictions => { :processingTypes => { :operation => 'anyMatch', :value => [ 'token' ] }, :totalAmount => { :operation => 'greaterThan', :value => { :currency => 'EUR', :value => 5000 } } }, :status => 'active', :outcomeType => 'hardBlock', :type => 'velocity' } # Make the API call result = adyen.balancePlatform.transaction_rules_api.create_transaction_rule(request_body)NodeJS (TypeScript)
// Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, BalancePlatformAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object(s) const amount: Types.balancePlatform.Amount = { currency: "EUR", value: 5000 }; const totalAmountRestriction: Types.balancePlatform.TotalAmountRestriction = { operation: "greaterThan", value: amount }; const processingTypesRestriction: Types.balancePlatform.ProcessingTypesRestriction = { operation: "anyMatch", value: [ Types.balancePlatform.ProcessingTypesRestriction.ValueEnum.Token ] }; const transactionRuleEntityKey: Types.balancePlatform.TransactionRuleEntityKey = { entityType: "paymentInstrument", entityReference: "PI3227C223222B5FN65FN5NS9" }; const transactionRuleInterval: Types.balancePlatform.TransactionRuleInterval = { type: Types.balancePlatform.TransactionRuleInterval.TypeEnum.PerTransaction }; const transactionRuleRestrictions: Types.balancePlatform.TransactionRuleRestrictions = { totalAmount: totalAmountRestriction, processingTypes: processingTypesRestriction }; const transactionRuleInfo: Types.balancePlatform.TransactionRuleInfo = { reference: "myRule123", outcomeType: Types.balancePlatform.TransactionRuleInfo.OutcomeTypeEnum.HardBlock, entityKey: transactionRuleEntityKey, description: "Block network token transactions above EUR 50", interval: transactionRuleInterval, ruleRestrictions: transactionRuleRestrictions, type: Types.balancePlatform.TransactionRuleInfo.TypeEnum.Velocity, status: Types.balancePlatform.TransactionRuleInfo.StatusEnum.Active }; // Make the API call const balancePlatformAPI = new BalancePlatformAPI(client); const response = balancePlatformAPI.TransactionRulesApi.createTransactionRule(transactionRuleInfo); -
Verify that you receive an HTTP 200 — OK response that returns the
idof the transaction rule that can be used to further update or delete this rule. Response{ "description": "Block network token transactions above EUR 50", "entityKey": { "entityReference": "PI3227C223222B5FN65FN5NS9", "entityType": "paymentInstrument" }, "interval": { "timeZone": "UTC", "type": "perTransaction" }, "outcomeType": "hardBlock", "reference": "myRule123", "requestType": "authorization", "ruleRestrictions": { "processingTypes": { "operation": "anyMatch", "value": [ "token" ] }, "totalAmount": { "operation": "greaterThan", "value": { "currency": "EUR", "value": 5000 } } }, "startDate": "2022-10-05T10:34:31.911273+02:00", "status": "active", "type": "velocity", "id": "TR32272223222C5GP4S4K5NZG" }