Instructions: Setting a PIN

Using the Bond card management SDK to set a customer's card PIN.

Sample pseudocode for setting a card's PIN

Setting up card PIN fields in HTML

You can use BondCards from the Bond Web SDK to insert <form> fields with IDs into an HTML page to capture PIN details using <div> elements. The sample pseudocode shown below captures PIN details.

<form id="cc-form">
  <div class="field">
    New PIN
    <div id="cc-new-pin" class="card-field"></div>

Using the BondCards SDK in your script file

Before you can use the BondCards SDK in you scripts, you need to:

  1. Import the SDK
  2. Get temporary security tokens
  3. Initialize the BondCards class

1. Importing the SDK

Import with

  import { BondCards } from 'bond-sdk-web';

using node.js or

  import { BondCards } from '';

using the CDN.

2. Getting temporary security tokens

Use the sample code shown below with the API to get temporary tokens by making a call to the backend.

curl --request POST \
  --url \
  --header 'Content-Type: application/json' \
  --header 'Identity: YOUR_IDENTITY' \
  --header 'Authorization: YOUR_AUTHORIZATION' \
  --data '{"customer_id": "YOUR_CUSTOMER_ID"}'
import requests

url = ""

headers = { "Content-type": "application/json", "Identity": "YOUR_IDENTITY", "Authorization": "YOUR_AUTHORIZATION" }

payload = { 'customer_id': 'YOUR_CUSTOMER_ID' }

response =, headers=headers, json=payload)

uri = URI.parse("")
params = {'customer_id' => 'YOUR_CUSTOMER_ID'}
headers = {

http =, uri.port)
response =, params.to_json, headers)
output = response.body
puts output
const fetch = require('node-fetch');

let url = '';
let options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Identity': 'YOUR_IDENTITY',
    'Authorization': 'YOUR_AUTHORIZATION'
  body: { 'customer_id': 'YOUR_CUSTOMER_ID' }

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error('error:' + err));
// Client-side example for quick testing.
// You would call this from your backend in production

fetch("", {
  method: "POST",
  headers: {
    "Content-type": "application/json",
    "Identity": "YOUR_IDENTITY",
    "Authorization": "YOUR_AUTHORIZATION",
  body: {
    "customer_id": "YOUR_CUSTOMER_ID",
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .addHeader("Content-Type", "application/json")
  .addHeader("Identity", "YOUR_IDENTITY")
  .addHeader("Authorization", "YOUR_AUTHORIZATION")
                        "{\"customer_id\": \"" + YOUR_CUSTOMER_ID + "\"}"

Response response = client.newCall(request).execute();
var client = new RestClient("");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Identity", "YOUR_IDENTITY");
request.AddHeader("Authorization", "YOUR_AUTHORIZATION");
request.AddParameter("application/json", {"customer_id": "YOUR_CUSTOMER_ID"}, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

3. Initializing the BondCards class

  const bondCards = new BondCards({ live: true });

4. Calling bondCards.field()

On an event such as a page load, you can call bondCards.field() for each <div> where you want a user to enter PIN data.
You need to send the following:

  • HTML/CSS selector of the <div> where you want the form field to be inserted
  • Field type:
    • new_pin

Calling bondCards.field() example

    selector: "#cc-new-pin",
    type: "new_pin",
  .catch((error) => {
    console.error("error", error);

5. Adding an event listener

Add an event listener to call BondCards when the form is submitted.
You need to send the following:

  • card_id
  • Temporary Identity and Authorization tokens.
  • Form field values (new_pin is a required field).
  • A callback function you want executed when the HTTP request has completed successfully.
  • A callback function you want triggered when a field is invalid or upon an error.

Adding an event listener example

document.querySelector("#cc-form").addEventListener("submit", (e) => {
    cardId: 'YOUR_CARD_ID',
    identity: 'YOUR_IDENTITY',
    authorization: 'YOUR_AUTHORIZATION',
    newPin: document.getElementById("cc-new-pin").value,
    successCallback: function (status, data) {
      console.log('Successfully set new pin as: ', data.new_pin);
    errorCallback: function (errors) {