routing-rules

Stable. Describes behaviour that is built and covered by tests in this repository.

API reference

GET /v1/routing-rules #

The ordered rules that choose a new subscription's payment provider from the customer's country and the subscription's currency

Responses

StatusMeaningBody
200OKRoutingRules
Example response
{
  "rules": [
    {
      "country": "string",
      "currency": "string",
      "provider": "string"
    }
  ]
}
curl
curl -X GET https://YOUR-API-ADDRESS/v1/routing-rules \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY"

PUT /v1/routing-rules #

Replace the rules (first match wins; a rule with neither country nor currency is the catch-all and must be last). Existing subscriptions keep their provider

Request body

FieldTypeDescription
rulesarray of object
Example
{}

Responses

StatusMeaningBody
200OKRoutingRules
400Error envelopeError
Example response
{
  "rules": [
    {
      "country": "string",
      "currency": "string",
      "provider": "string"
    }
  ]
}
curl
curl -X PUT https://YOUR-API-ADDRESS/v1/routing-rules \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

POST /v1/routing-rules/preview #

Where a customer in a country paying in a currency would go, without creating anything

Request body

FieldTypeDescription
countrystring
currencystring
Example
{}

Responses

StatusMeaningBody
200OKPreviewRoutingResponse
Example response
{
  "provider": "string",
  "rule_index": 1,
  "owner": "payrudder",
  "can_charge": false
}
curl
curl -X POST https://YOUR-API-ADDRESS/v1/routing-rules/preview \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Models

Error

FieldTypeDescription
error requiredobject

PreviewRoutingRequest

FieldTypeDescription
countrystring
currencystring

PreviewRoutingResponse

FieldTypeDescription
provider requiredstringEmpty when no rule matches (the tenant's default account)
rule_index requiredinteger-1 when no rule matches
owner requiredpayrudder | provider
can_charge requiredboolean

RoutingRules

FieldTypeDescription
rules requiredarray of object

RoutingRulesInput

FieldTypeDescription
rulesarray of object