Support Services

Create a Token in Web Services


Creating Tokens Via Web Services

This article will reference relative information to the subject within our Rest API Web Services located here:

https://restdocs.forte.net/?version=latest#ed3aaeec-7aa3-46c1-ba01-941e13e2a5f4  


When creating tokens using the Rest API Web Services, these can fall into two categories. 

Those two categories being:

  • Customer Tokens
  • Paymethod Tokens

The different tokens have their own requirements in order to create a valid 'POST' call.


First, there is a Cleintless Paymethod Token which only includes the customer's payment information and returns only the Paymethod Token.

The endpoint for this request is below:

"https://sandbox.forte.net/api/v3/organizations/org_{{organizationID}}/locations/loc_{{locationID}}/paymethods"

Here are the requirements for creating this type of token:


Credit Card:

  • "name_on_card" : "John Smith",
  • "card_type" : "visa",
  • "account_number" : "4111111111111111",
  • "expire_month" : 12,
  • "expire_year" : 2020,
  • "card_verification_value" :  "123"

All of these parameters belong to the 'Card' object.


ACH/ECheck:

  • "account_holder" : "John Smith",
  • "account_number" : "1111111111111",
  • "routing_number" : "021000021",
  • "account_type" : "checking"

All of these parameters belong to the 'echeck' object.

The response to these calls will include all of the information from the original call but will provide the Paymethod Token with the value behind the "mth_{string paymethod token"


Moving forward, the next token which has more requirements is creating a Customer Token.

Every customer must have these two variables:


  • 'first_name' : 'John'
  • 'last_name' : 'Smith'

From there you will create the 'addresses' object.


  • "first_name" : "John",
  •  "last_name" : "Smith",
  •  "company_name" : "Brown Associates", (Optional)
  •  "phone" : "444-444-4444", (Optional)
  •  "email" : "e.brown@brown.net", (Optional)
  •  "address_type" : "default_billing",
  •              "physical_address": (this will be setting the actual address for the customer token)
  •                      "street_line1" : "123 Hill Valley Rd.",
  •                      "street_line2" : "APT 1001",
  •                      "locality" : "Hill Valley",
  •                      "region" : "CA",
  •                      "postal_code" : "95420"

Within this call, you can create a Paymethod Token attached to this Customer Token by including the same parameters after the 'addresses' object with the additional variable.

Below is an example of a Rest call that will create a Client Token with an attached Paymethod.


Post new Customer Token with Paymethod:


<?php

        $base_url = 'https://sandbox.forte.net/api/v3';

        $organization_id  = 'org_{Insert Organization ID}';

        $location_id = 'loc_{Insert Location ID}';

        $api_access_id = '{Insert API Access ID}';

        $api_secure_key = '{Insert API Secure Key}';


    $auth_token        = base64_encode($api_access_id . ':' . $api_secure_key);

    $endpoint          = $base_url . '/organizations/' . $organization_id . '/locations/' . $location_id . '/customers';

    echo $auth_token;

    $params = array(

            "first_name" => "Emmett",

              "last_name" => "Brown",

               "company_name" => "Brown Associates",

               "addresses" => array( array(

                  "label" => "Brown Shipping",

                 "first_name" => "Emmett",

                 "last_name" => "Brown",

                 "company_name" => "Brown Associates",

                 "phone" => "444-444-4444",

                 "email" => "ebrown@brown.net",

                 "address_type" => "default_billing",

                 "physical_address" => array(

                    "street_line1" => "123 Hill Valley Rd.",

                    "street_line2" => "APT 1001",

                    "locality" => "Hill Valley",

                    "region" => "CA",

                    "postal_code" => "95420"

                    )

                     )

                  ),

              "paymethod" => array(

                "label" => "primary",

                 "notes" => "Business CC",

                 "card" => array(

                    "account_number" => "4111111111111111",

                    "expire_month" => 10,

                    "expire_year" => 2020,

                    "card_verification_value" => "693",

                    "card_type" => "visa",

                    "name_on_card" => "Emmett L. Brown"

                 )

              )

        );          

    

$ch = curl_init($endpoint);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_VERBOSE, 1);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    curl_setopt($ch, CURLOPT_TIMEOUT, 30);

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');                

    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));     

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(

        'Authorization: Basic ' . $auth_token,

        'X-Forte-Auth-Organization-id: ' . $organization_id,

        'Accept:application/json',

        'Content-type: application/json'

    ));

    

    $response = curl_exec($ch);

    $info = curl_getinfo($ch);

    curl_close($ch);

    $data = json_decode($response);

    echo '<pre>';

    print_r('HttpStatusCode: ' . $info['http_code'] . '<br><br>');

    print_r($data);

    echo '</pre>';

?>


For any additional information or guidance in working with our Rest API, please email us at integration@forte.net to receive direct support!





 


 


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.