{"_id":"59b6b1eebc195b003ca7a9b4","category":{"_id":"59b6b1ecbc195b003ca7a984","version":"59b6b1ecbc195b003ca7a981","project":"57336fd5a6a9c40e00e13a0b","__v":0,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-05-19T19:19:37.628Z","from_sync":false,"order":2,"slug":"hosted-payment-fields","title":"Hosted Payment Fields"},"user":"560d5913af97231900938124","project":"57336fd5a6a9c40e00e13a0b","parentDoc":null,"version":{"_id":"59b6b1ecbc195b003ca7a981","project":"57336fd5a6a9c40e00e13a0b","__v":1,"createdAt":"2017-09-11T15:55:24.925Z","releaseDate":"2017-09-11T15:55:24.925Z","categories":["59b6b1ecbc195b003ca7a982","59b6b1ecbc195b003ca7a983","59b6b1ecbc195b003ca7a984","59b6b1ecbc195b003ca7a985","59b6b1ecbc195b003ca7a986","59b6b1ecbc195b003ca7a987","59b6b1ecbc195b003ca7a988","59b6b1ecbc195b003ca7a989","59b6b1ecbc195b003ca7a98a","59b6b1ecbc195b003ca7a98b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"3.22.2 Release","version_clean":"8976.0.0-Tools","version":"8976-Tools"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-05-19T19:24:48.118Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"language":"text","code":""}]},"settings":"","examples":{"codes":[]},"method":"post","auth":"optional","params":[],"url":"/payment-fields-tokens"},"isReference":true,"order":5,"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 an 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.","excerpt":"","slug":"create-hosted-payment-fields-token","type":"post","title":"Create Hosted Payment Fields Token"}

postCreate Hosted Payment Fields Token


Definition

{{ api_url }}{{ page_api_url }}

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 an 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 '

Response Example

HTTP/ 1.1 201 Created
Location: https://sandbox.bluesnap.com/services/2/payment-fields-tokens/12345abcde*********

API Explorer

To 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.


User Information

Try It Out


post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}