{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/payment-fields-tokens","auth":"optional","results":{"codes":[{"language":"text","code":""}]},"settings":"","examples":{"codes":[]},"method":"post","params":[]},"next":{"description":"","pages":[]},"title":"Create Hosted Payment Fields Token","type":"endpoint","slug":"create-hosted-payment-fields-token","excerpt":"","body":"[block:html]\n{\n \"html\": \"<script>\\n // hide body textbox of API Explorer\\n $(document).ready(function() {\\n $(\\\"textarea[placeholder='Body Content']\\\").hide(); \\n }); \\n</script>\"\n}\n[/block]\nWhen using [Hosted Payment Fields](doc:hosted-payment-fields), you will need to obtain a unique Hosted Payment Fields token for each session, and then use that in your checkout form. BlueSnap will save the shopper's payment information and associate it with the token, and you can include the token in your API requests in order to process card transactions or create or update vaulted shoppers.\n\nFor detailed instructions, see [Implementing Hosted Payment Fields in your checkout form](hosted-payment-fields#section-implementing-hosted-payment-fields-in-your-checkout-form).\n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"The Hosted Payment Fields Token will expire after 60 minutes.\",\n \"title\": \"Token expiration\"\n}\n[/block]\n###Request Content\nTo create a Hosted Payment Fields token, simply send a POST request to:\nSandbox: `https://sandbox.bluesnap.com/services/2/payment-fields-tokens`\nProduction: `https://ws.bluesnap.com/services/2/payment-fields-tokens`\n\n###Response Details\nThe response will provide the token in the location header, as follows: \n`location: BLUESNAPDOMAINPATH/services/2/payment-fields-tokens/HOSTEDFIELDTOKENID`\n\n<hr>\n\n##Examples\n\n###Request Example\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"curl -v -X POST https://sandbox.bluesnap.com/services/2/payment-fields-tokens \\\\\\n-H 'Content-Type: application/json' \\\\\\n-H 'Accept: application/json' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\",\n \"language\": \"curl\",\n \"name\": \"Create Hosted Payment Fields Token Request\"\n }\n ]\n}\n[/block]\n###Response Example\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"HTTP/ 1.1 201 Created\\nLocation: https://sandbox.bluesnap.com/services/2/payment-fields-tokens/12345abcde*********\",\n \"language\": \"http\",\n \"name\": \"Create Hosted Payment Fields Token Response: 201 Created\"\n }\n ]\n}\n[/block]\n##API Explorer\nTo generate a test Hosted Payment Fields token, which you can use in test requests within this documentation, use the API Explorer below. Click **Try It!** to run the call.","updates":[],"order":1,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"603fec227146110018e1da5c","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Hosted Payment Fields","slug":"hosted-payment-fields","order":9,"from_sync":false,"reference":true,"_id":"603fec227146110018e1da3f","version":"603fec227146110018e1daaf","project":"57336fd5a6a9c40e00e13a0b","createdAt":"2016-05-19T19:19:37.628Z","__v":0},"user":"560d5913af97231900938124","project":"57336fd5a6a9c40e00e13a0b","parentDoc":null,"version":{"version":"8976-Tools","version_clean":"8976.0.0-Tools","codename":"3.37 Release","is_stable":false,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["603fec227146110018e1da3d","603fec227146110018e1da3e","603fec227146110018e1da3f","603fec227146110018e1da40","603fec227146110018e1da41","603fec227146110018e1da42","603fec227146110018e1da43","603fec227146110018e1da44","603fec227146110018e1da45","603fec227146110018e1da46","603fec227146110018e1da47","603fec227146110018e1da48","5b34c737e0dca2000311de6a","603fec227146110018e1da49","603fec227146110018e1da4a","603fec227146110018e1da4b","603fec227146110018e1da4c","603fec227146110018e1da4d","603fec227146110018e1da4e","603fec227146110018e1da4f"],"_id":"603fec227146110018e1daaf","project":"57336fd5a6a9c40e00e13a0b","__v":0,"forked_from":"6019bc72944282005e966fd4","createdAt":"2018-04-23T15:17:35.680Z","releaseDate":"2018-04-23T15:17:35.680Z"},"createdAt":"2016-05-19T19:24:48.118Z","githubsync":"","__v":0}
postCreate Hosted Payment Fields Token
Definition
Documentation
When using Hosted Payment Fields, you will need to obtain a unique Hosted Payment Fields token for each session, and then use that in your checkout form. BlueSnap will save the shopper's payment information and associate it with the token, and you can include the token in your API requests in order to process card transactions or create or update vaulted shoppers.
For detailed instructions, see Implementing Hosted Payment Fields in your checkout form.
Token expiration
The Hosted Payment Fields Token will expire after 60 minutes.
Request Content
To create a Hosted Payment Fields token, simply send a POST request to:
Sandbox: https://sandbox.bluesnap.com/services/2/payment-fields-tokens
Production: https://ws.bluesnap.com/services/2/payment-fields-tokens
Response Details
The response will provide the token in the location header, as follows:location: BLUESNAPDOMAINPATH/services/2/payment-fields-tokens/HOSTEDFIELDTOKENID
Examples
Request Example
curl -v -X POST https://sandbox.bluesnap.com/services/2/payment-fields-tokens \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
HTTP/ 1.1 201 Created
Location: https://sandbox.bluesnap.com/services/2/payment-fields-tokens/12345abcde*********