{"_id":"55fa3c3ba663c00d00773dce","__v":16,"project":"54e405191e51932d006abc39","user":"54e4044e8ef7552300409dcb","parentDoc":null,"version":{"_id":"55fa37c88065a10d004e5bb6","project":"54e405191e51932d006abc39","__v":9,"createdAt":"2015-09-17T03:47:20.956Z","releaseDate":"2015-09-17T03:47:20.956Z","categories":["55fa37ca8065a10d004e5bb7","55fa37ca8065a10d004e5bb8","55fa37ca8065a10d004e5bb9","55fa37ca8065a10d004e5bba","55fca6bf34ae7c0d00ab8ea0","55ff80fd9e7ccf0d000a1d93","560220af7435de0d00fabd0d","56107f21bb9d920d00303e70","563e184077681a0d00d96a02","56fafc6596ec7e0e002ac85f","5915e54f7c2c552d008b8549","59499fcd64b5f5002690bbc1"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"REST V3","version_clean":"3.1.0","version":"3.1"},"category":{"_id":"5915e54f7c2c552d008b8549","project":"54e405191e51932d006abc39","version":"55fa37c88065a10d004e5bb6","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-05-12T16:39:43.277Z","from_sync":false,"order":1,"slug":"guides","title":"Resources"},"updates":["56071fc33a93940d002b3f1e"],"next":{"pages":[],"description":""},"createdAt":"2015-09-17T04:06:19.096Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"Client and user authentication information is expected to be included as a header values in your requests. \n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"KEY\",\n    \"h-1\": \"VALUE\",\n    \"h-2\": \"Comments\",\n    \"h-3\": \"Notes\",\n    \"0-0\": \"X-SP-GATEWAY\",\n    \"0-1\": \"`YOUR_CLIENT_ID`|`YOUR_CLIENT_SECRET`\",\n    \"0-2\": \"Your `client_id` and `client_secret` separated by a vertical bar. (required)\",\n    \"0-3\": \"You can send bulk instructions here\",\n    \"1-0\": \"X-SP-USER\",\n    \"1-1\": \"`USER_OAUTH_KEY`|`USER_FINGERPRINT`\",\n    \"1-2\": \"User’s `oauth_key` and device fingerprint separated by a vertical bar. (required)\",\n    \"1-3\": \"Paginated. Search by name and email available\",\n    \"2-1\": \"`USER.IP.ADDR`\",\n    \"2-0\": \"X-SP-USER-IP\",\n    \"2-2\": \"IP Address of the user. (required)\",\n    \"2-3\": \"Allows you to register a new user to SynapsePay\",\n    \"3-0\": \"X-SP-IDEMPOTENCY-KEY\",\n    \"3-1\": \"`IDEMPOTENCY_KEY`\",\n    \"3-2\": \"`idemopotency_key` for safely retrying requests. (optional)\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"POST calls support idempotency for safely retrying requests without accidentally performing the same operation twice. For example, if a request to create a transaction fails due to a network connection error, you can retry the request with the same idempotency key to guarantee that only a single charge is created.\",\n  \"title\": \"Idemopotent Requests\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"\"\n}\n[/block]\n##Client App Initialization\n\nInstead of using the API directly, you can also use our client libraries. Following is how you initialize the environment for the libraries.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import os\\nfrom synapse_pay_rest import Client\\n\\nargs = {\\n    'client_id': os.environ['CLIENT_ID'], # your client id\\n    'client_secret': os.environ['CLIENT_SECRET'], # your client secret\\n    'fingerprint': USER_FINGERPRINT,\\n    'ip_address': USER_IP_ADDRESS, # user's IP\\n    'development_mode': True, # (optional) default False\\n    'logging': False # (optional) logs to stdout if True\\n}\\n\\nclient = Client(**args)\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"const SynapsePay = require('synapsepay');\\nconst Clients = SynapsePay.Clients;\\nconst Helpers = SynapsePay.Helpers;\\n\\nconst client = new Clients(\\n  // client id should be stored as an environment variable\\n  process.env.CLIENT_ID,\\n  // client secret should be stored as an environment variable\\n  process.env.CLIENT_SECRET,\\n  // is_production boolean determines sandbox or production endpoints used\\n  false\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Node.js\"\n    },\n    {\n      \"code\": \"require 'synapse_pay_rest'\\n\\nargs = {\\n  # synapse client_id\\n  client_id:        ENV.fetch('CLIENT_ID'),\\n  # synapse client_secret\\n  client_secret:    ENV.fetch('CLIENT_SECRET'),\\n  # a hashed value, either unique to user or static for app\\n  fingerprint:      FINGERPRINT,\\n  # the user's IP\\n  ip_address:       USER_IP_ADDRESS,\\n  # (optional) requests go to sandbox endpoints if true\\n  development_mode: true,\\n  # (optional) if true logs requests to stdout\\n  logging:          true,\\n  # (optional) file path to write logs to\\n  log_to:           nil\\n}\\n\\nclient = SynapsePayRest::Client.new(args)\",\n      \"language\": \"ruby\"\n    },\n    {\n      \"code\": \"require(dirname(__FILE__) . '/../../init.php');\\n\\nuse SynapsePayRest\\\\Client;\\n\\n$options = array(\\n\\t'oauth_key'=> USER_OAUTH_KEY, # Optional,\\n\\t'fingerprint'=> USER_FINGERPRINT,\\n\\t'client_id'=> CLIENT_ID,\\n\\t'client_secret'=> CLIENT_SECRET,\\n\\t'development_mode'=> true, # true will ping sandbox.synapsepay.com\\n\\t'ip_address'=> USER_IP_ADDRESS\\n);\\n\\n$user_id = USER_ID # optionals\\n\\n$client = new Client($options, $user_id); // $user_id optional\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Please note that you do not need to add `oauth_key` in the options dictionary after the user is created and oauth is performed. The libraries automatically do that for you.\",\n  \"title\": \"Automatic OAuth updates\"\n}\n[/block]","excerpt":"Following are the values you need to set in the header of your API call","slug":"api-initialization","type":"basic","title":"API Initialization"}

API Initialization

Following are the values you need to set in the header of your API call

Client and user authentication information is expected to be included as a header values in your requests. [block:parameters] { "data": { "h-0": "KEY", "h-1": "VALUE", "h-2": "Comments", "h-3": "Notes", "0-0": "X-SP-GATEWAY", "0-1": "`YOUR_CLIENT_ID`|`YOUR_CLIENT_SECRET`", "0-2": "Your `client_id` and `client_secret` separated by a vertical bar. (required)", "0-3": "You can send bulk instructions here", "1-0": "X-SP-USER", "1-1": "`USER_OAUTH_KEY`|`USER_FINGERPRINT`", "1-2": "User’s `oauth_key` and device fingerprint separated by a vertical bar. (required)", "1-3": "Paginated. Search by name and email available", "2-1": "`USER.IP.ADDR`", "2-0": "X-SP-USER-IP", "2-2": "IP Address of the user. (required)", "2-3": "Allows you to register a new user to SynapsePay", "3-0": "X-SP-IDEMPOTENCY-KEY", "3-1": "`IDEMPOTENCY_KEY`", "3-2": "`idemopotency_key` for safely retrying requests. (optional)" }, "cols": 3, "rows": 4 } [/block] [block:callout] { "type": "info", "body": "POST calls support idempotency for safely retrying requests without accidentally performing the same operation twice. For example, if a request to create a transaction fails due to a network connection error, you can retry the request with the same idempotency key to guarantee that only a single charge is created.", "title": "Idemopotent Requests" } [/block] [block:api-header] { "type": "basic", "title": "" } [/block] ##Client App Initialization Instead of using the API directly, you can also use our client libraries. Following is how you initialize the environment for the libraries. [block:code] { "codes": [ { "code": "import os\nfrom synapse_pay_rest import Client\n\nargs = {\n 'client_id': os.environ['CLIENT_ID'], # your client id\n 'client_secret': os.environ['CLIENT_SECRET'], # your client secret\n 'fingerprint': USER_FINGERPRINT,\n 'ip_address': USER_IP_ADDRESS, # user's IP\n 'development_mode': True, # (optional) default False\n 'logging': False # (optional) logs to stdout if True\n}\n\nclient = Client(**args)", "language": "python" }, { "code": "const SynapsePay = require('synapsepay');\nconst Clients = SynapsePay.Clients;\nconst Helpers = SynapsePay.Helpers;\n\nconst client = new Clients(\n // client id should be stored as an environment variable\n process.env.CLIENT_ID,\n // client secret should be stored as an environment variable\n process.env.CLIENT_SECRET,\n // is_production boolean determines sandbox or production endpoints used\n false\n);", "language": "javascript", "name": "Node.js" }, { "code": "require 'synapse_pay_rest'\n\nargs = {\n # synapse client_id\n client_id: ENV.fetch('CLIENT_ID'),\n # synapse client_secret\n client_secret: ENV.fetch('CLIENT_SECRET'),\n # a hashed value, either unique to user or static for app\n fingerprint: FINGERPRINT,\n # the user's IP\n ip_address: USER_IP_ADDRESS,\n # (optional) requests go to sandbox endpoints if true\n development_mode: true,\n # (optional) if true logs requests to stdout\n logging: true,\n # (optional) file path to write logs to\n log_to: nil\n}\n\nclient = SynapsePayRest::Client.new(args)", "language": "ruby" }, { "code": "require(dirname(__FILE__) . '/../../init.php');\n\nuse SynapsePayRest\\Client;\n\n$options = array(\n\t'oauth_key'=> USER_OAUTH_KEY, # Optional,\n\t'fingerprint'=> USER_FINGERPRINT,\n\t'client_id'=> CLIENT_ID,\n\t'client_secret'=> CLIENT_SECRET,\n\t'development_mode'=> true, # true will ping sandbox.synapsepay.com\n\t'ip_address'=> USER_IP_ADDRESS\n);\n\n$user_id = USER_ID # optionals\n\n$client = new Client($options, $user_id); // $user_id optional", "language": "php" } ] } [/block] [block:callout] { "type": "info", "body": "Please note that you do not need to add `oauth_key` in the options dictionary after the user is created and oauth is performed. The libraries automatically do that for you.", "title": "Automatic OAuth updates" } [/block]