import Shoply from "@shoplygg/node";
const shoply = new Shoply({ apiKey: process.env.SHOPLY_API_KEY });
const result = await shoply.routing.updateRule("RULE_ID", {
kind: "country",
action: "only",
provider: "nmi",
});<?php
require 'vendor/autoload.php';
$shoply = new Shoply\Client(['apiKey' => getenv('SHOPLY_API_KEY')]);
$result = $shoply->routing->updateRule('RULE_ID', [
'kind' => 'country',
'action' => 'only',
'provider' => 'nmi',
]);
import shoply
client = shoply.Client() # reads SHOPLY_API_KEY
result = client.routing.updateRule("RULE_ID", kind="country", action="only", provider="nmi")
curl --request PUT \
--url https://api.shoply.gg/v1/stores/{storeId}/payment-routing/rules/{ruleId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"provider": "nmi",
"countries": [
"DE",
"FR"
],
"amount": 200
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.shoply.gg/v1/stores/{storeId}/payment-routing/rules/{ruleId}"
payload := strings.NewReader("{\n \"provider\": \"nmi\",\n \"countries\": [\n \"DE\",\n \"FR\"\n ],\n \"amount\": 200\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.shoply.gg/v1/stores/{storeId}/payment-routing/rules/{ruleId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"provider\": \"nmi\",\n \"countries\": [\n \"DE\",\n \"FR\"\n ],\n \"amount\": 200\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.shoply.gg/v1/stores/{storeId}/payment-routing/rules/{ruleId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"provider\": \"nmi\",\n \"countries\": [\n \"DE\",\n \"FR\"\n ],\n \"amount\": 200\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": null,
"code": null,
"data": {
"set": true,
"settings": {
"enabled": false,
"mode": "share",
"retry": true,
"sticky": true,
"guard": true,
"guardDeclines": 8,
"guardWindow": 20,
"disputeAlert": 0.75
},
"processors": [
{
"provider": "nmi",
"name": "NMI",
"share": 60,
"capMonth": 25000,
"capDay": null,
"minOrder": null,
"maxOrder": null,
"state": "rotation",
"pausedReason": "",
"pausedAt": null,
"month": 0,
"day": 0,
"approved": null,
"disputes": null,
"fee": null
},
{
"provider": "tagada",
"name": "Tagada",
"share": 50,
"capMonth": null,
"capDay": null,
"minOrder": null,
"maxOrder": null,
"state": "rotation",
"pausedReason": "",
"pausedAt": null,
"month": 0,
"day": 0,
"approved": null,
"disputes": null,
"fee": null
}
],
"rules": [
{
"id": "728178f0-e4b4-4a8f-923a-1109ddeb07ef",
"kind": "country",
"countries": [
"DE",
"AT"
],
"amountOp": null,
"amount": null,
"action": "only",
"provider": "nmi"
}
],
"available": [],
"figures": {
"routed": {
"orders": 0,
"volume": 0
},
"approved": null,
"saved": {
"orders": 0,
"volume": 0
},
"disputes": null
},
"limits": {
"rules": 50,
"countries": 100,
"guardWindowMin": 5,
"guardWindowMax": 200
}
}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}Change a rule
Replaces a rule with the one sent. Answers the whole of Payment Routing again, as “Get Payment Routing” does.
Needs the routing.write permission (Change Payment Routing).
import Shoply from "@shoplygg/node";
const shoply = new Shoply({ apiKey: process.env.SHOPLY_API_KEY });
const result = await shoply.routing.updateRule("RULE_ID", {
kind: "country",
action: "only",
provider: "nmi",
});<?php
require 'vendor/autoload.php';
$shoply = new Shoply\Client(['apiKey' => getenv('SHOPLY_API_KEY')]);
$result = $shoply->routing->updateRule('RULE_ID', [
'kind' => 'country',
'action' => 'only',
'provider' => 'nmi',
]);
import shoply
client = shoply.Client() # reads SHOPLY_API_KEY
result = client.routing.updateRule("RULE_ID", kind="country", action="only", provider="nmi")
curl --request PUT \
--url https://api.shoply.gg/v1/stores/{storeId}/payment-routing/rules/{ruleId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"provider": "nmi",
"countries": [
"DE",
"FR"
],
"amount": 200
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.shoply.gg/v1/stores/{storeId}/payment-routing/rules/{ruleId}"
payload := strings.NewReader("{\n \"provider\": \"nmi\",\n \"countries\": [\n \"DE\",\n \"FR\"\n ],\n \"amount\": 200\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.shoply.gg/v1/stores/{storeId}/payment-routing/rules/{ruleId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"provider\": \"nmi\",\n \"countries\": [\n \"DE\",\n \"FR\"\n ],\n \"amount\": 200\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.shoply.gg/v1/stores/{storeId}/payment-routing/rules/{ruleId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"provider\": \"nmi\",\n \"countries\": [\n \"DE\",\n \"FR\"\n ],\n \"amount\": 200\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": null,
"code": null,
"data": {
"set": true,
"settings": {
"enabled": false,
"mode": "share",
"retry": true,
"sticky": true,
"guard": true,
"guardDeclines": 8,
"guardWindow": 20,
"disputeAlert": 0.75
},
"processors": [
{
"provider": "nmi",
"name": "NMI",
"share": 60,
"capMonth": 25000,
"capDay": null,
"minOrder": null,
"maxOrder": null,
"state": "rotation",
"pausedReason": "",
"pausedAt": null,
"month": 0,
"day": 0,
"approved": null,
"disputes": null,
"fee": null
},
{
"provider": "tagada",
"name": "Tagada",
"share": 50,
"capMonth": null,
"capDay": null,
"minOrder": null,
"maxOrder": null,
"state": "rotation",
"pausedReason": "",
"pausedAt": null,
"month": 0,
"day": 0,
"approved": null,
"disputes": null,
"fee": null
}
],
"rules": [
{
"id": "728178f0-e4b4-4a8f-923a-1109ddeb07ef",
"kind": "country",
"countries": [
"DE",
"AT"
],
"amountOp": null,
"amount": null,
"action": "only",
"provider": "nmi"
}
],
"available": [],
"figures": {
"routed": {
"orders": 0,
"volume": 0
},
"approved": null,
"saved": {
"orders": 0,
"volume": 0
},
"disputes": null
},
"limits": {
"rules": 50,
"countries": 100,
"guardWindowMin": 5,
"guardWindowMax": 200
}
}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}{
"success": false,
"message": "<string>",
"code": "<string>",
"data": null,
"errors": {}
}Authorizations
A secret API key, made under Developers in the dashboard: Authorization: Bearer shoply_sk_...
Headers
A word of your own for this one change, up to 180 letters, digits, dots, dashes, underscores and colons. Sent again with the same key, the request is not carried out twice: the first answer comes back, with Idempotent-Replay: true.
Path Parameters
The store's ID. A key reaches the store it was made in: GET /key answers which.
The rule.
Body
What it looks at: the buyer's country, or the order's amount.
country, amount only: such orders go to this processor and no other. never: they never go to it.
only, never The processor the rule is about, one in the routing.
"nmi"
For country: up to 100 countries, as two-letter codes.
["DE", "FR"]
For amount: whether it is about orders over the amount or under it.
over, under For amount: the amount, in the store's currency.
200

