On this system webauth is used for incorperating the platforms promotional products into a websites payment screen with greater ease. Webauth loads all of a customers gift cards, vouchers and loyalty accounts specific to your company onto a selection screen. This then gets communicated back to the customers payment screen via websockets so that they can use the product on your website
There are certain security considerations when working with our webauth system. We therefore break the system into two sections to get it setup, the backend code and the front end. The system takes a secure approach to providing the site with a promotional item.
To use webauth the first thing you need to do is acquire the token. This token is the webauth token which sets up the webauth front end. You acquire it by doing a post call to get the token. It doesn't have to be done in PHP or even use curl. You can use another web request library and even a different language if you need to. But here is an example using PHP:
$curl = curl_init();
$url = 'https://nsbizsol.com/api/PosApi/WebCartAuth/getServerToken';
$data = [
'apiKey' => '123e4567-e89b-12d3-a456-426655440000'
'organizationId' => '123e4567-e89b-12d3-a456-426655440000'
];
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($curl);
$decoded = json_decode($result)
if ($decoded->success == true)
{
$token = $decoded->token;
}
else
{
$errors = $decoded->errors;
}
curl_close($curl);
Once you've obtained the webauth token you can new generate the script tag to initialize the socket interface that your page will communicate with to apply the promotional items.
To call the webauth login screen all you need to do is call the following javascript function in a anchor or button control. An example of this is as follows:
Once you've initilaized the front end script by adding the tag above to your payment page you can now create event listeners to listen to your events. The following are prototypes for event listeners. These event listeners provide an interface to utilize the webauth system to populate fields on your payment screen fields. You will need to add additional fields to your payment page to handle each function. These can be hidden fields if you would like. But its probably best to make them viewable by the user since it is their promotional item that will be displayed. However, from here you will have to initiate a transaction on your sites backend to trigger a charge using a rest call.
<script type="text/javascript" >
document.addEventListener('nsWebCartApplyGiftcard', function (event) {
var giftCardId = event.gift_card_id;
var ccv = event.ccv;
var chargeAmount = event.charge;
// Place code to populate fields here.
});
document.addEventListener('nsWebCartApplyPointsAccount', function (event) {
var pointsAccountId = event.points_account_id;
// Place code to populate points account fields here.
});
document.addEventListener('nsWebCartApplyStampCard', function (event) {
var stampCardId = event.stamp_card_id;
// Place code to populate stamp card field.
});
document.addEventListener('nsWebCartApplyVoucher', function (event) {
var voucherId = event.sold_voucher_id;
var ccv = event.ccv;
// Place code to populate voucher fields here.
});
The following part of this is fundamentally the tutorial for how to use the POS API. You will need to use the POS API to process transactions on the webauth API. So it doesn't matter if its a POS system or a website you would use the same API for processing transactions.
To process transactions on the back end you will utilize your organization ID and API key. You can get these items in the general settings screen in the merchant portal if you are logged in as a merchant admin. If you have just signed up. The merchant admin account is the default account that is created when you first sign up for the platform. If you are not the holder of the admin account for your organization please inform them so that they can get you the specific information. This information is not tied to any specific user account but to the organization. Do not share the api key or organizationID with anyone outside your organization or with someone who has no reason to have it. These items are secret keys used to identify your companies websites and POS systems to our platform so that you can process transactions through these software platforms.
The following is an example of how to process transactions using the POS api:
$curl = curl_init();
$url = 'https://nsbizsol.com/api/PosApi/Giftcards/debit_gift_card';
$data = [
'api_key' => '123e4567-e89b-12d3-a456-426655440000',
'organization_id' => '123e4567-e89b-12d3-a456-426655440000',
'gift_card_id' => '123e4567-e89b-12d3-a456-426655440000'
'ccv' => '000'
];
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($curl);
$decoded = json_decode($result)
if ($decoded->success == true)
{
$transactionResult = $decoded->result;
}
else
{
$errors = $decoded->errors;
}
curl_close($curl);