LLSR API - Gift Card (GC) port docs and examples.
This document explains the simple use of the gift card port, its methods and limitations.
Full details of this port, its methods and responses and those of all other ports and methods, can be found by viewing the WSDL file here.
Connecting to the API
This and all LLSR API's are written in PHP but use a standard SOAP service to present ports to users. The code below shows how to get a SOAP connection resource object in PHP.
try{
$client = new
SoapClient('https://api.skilouise.com/GC-API.php?WSDL',array('trace'
=> false,'exceptions' => false));
}catch (SoapFault $sf){
// Handle Soap Faults here
}
The returned client object represents an open port on the API and all that ports available methods can be accessed as if it were a standard PHP object.
Register a gift card (method: register)
All gift cards in Lake Louise systems must be registered with our master list in order to function. The example below shows how this is done.
$response = $client->register($apiKey, $password, $cardNumber,
$amount);
Card number is optional for this function. Sending boolean false instead will cause the API to generate a random gift card number and continue the registration process with that number.
To register a new card you MUST provide an amount to credit to the new account. The amount can be anything from 0.00 up. A false or null value will throw an internal exception and cause the request to fail.
The response from this method is a string containing the gift card number that was registered. If a card number was sent in the request, that same number will be returned. On error this function will throw a soap fault with details of the error.
Generate Bulk numbers (method: registerBulk)
To generate and register more then one gift card user the registerBulk method as shown here.
$response = $client->registerBulk($apiKey, $password, 123, 0.01,
False);
The above code will return a JSON encoded array containing the quantity of card numbers requested. In this case 123 card numbers will generated, registered, activated with a starting balance of $0.01, and then returned in the array.
Setting the final value to true will return a serialized array instead of a JSON encoded array.
Get Card Information (getGiftCard)
The getGiftCard method returns by default a JSON encoded string containing a gift card object with all related data enclosed.
To fetch a gift card object use the code below
$response = $client->getGiftCard($apiKey, $password,
3039001200194188, false, false);
The last two values sent in the code above are optional. The first, set to true to exclude transaction data from the returned object. The second set to true to return a serialized version of the gift card object instead of a JSON encoded string.
Responce
The getGiftCard example above would return the following JSON encoded object. This example has be decoded.
stdClass Object ( [cc_linked] => [member] => [passNumber] =>
[balance] => 5.55 [cardID] => 232935 [cardNumber] => 3039001200194188
[transactions] => Array ( [0] => stdClass Object ( [giftCardID] =>
232935 [transactionID] => 344133 [transType] => INITIAL [amount] =>
5.55 [date] => Apr 20 2014 09:40:21:600AM [authCode] => 03651
[operator] => API TEST USER [terminal] => 99 [payType] => API Payment
) ) [status] => active [cardType] => Gift Card )
Credit a gift card (method: credit)
Use the credit method to credit (aka top up) the given gift card account. The amount must be >= 0.01
$response = $client->credit($apiKey, $password, $cardNumber,
$amount);
Debit a gift card (method: debit)
Use the debit method to debit a card with the given amount. The amount to be debited must be >= 0.01 . Invoice should be a string between 0 and 16 char/num long representing the transaction within the client system.
$response = $client->debit($apiKey, $password, $cardNumber,
$amount, $invoice);
Refunding gift card transactions (method: return)
The return method alows you to refund part or all of an existing gift card charge transaction that was not completed on the current order. The void method can be used if the process is completed on the same order and you wish to undo an entire transaction, though the resulting response will be the same.
$response = $client->return ($apiKey, $password, $amount,
$transactionID)
Voiding gift card transactions (method: cancel)
The cancel method (aka void) enables you to void an existing charge, credit or return transaction. Voids can only be applied to transaction that were completed within the same batch. A batch is a 24 hour period from midnight to midnight. Use the return method for transactions not made on the current batch.
$response = $client->cancel ($apiKey, $password, $amount,
$transactionID)
Responses...
Cancel, Debit, Return and Credit functions should return a process response object with the following parameters
- result : boolean : True if the request was processed correctly else false.
- merchantID : string : The merchant account ID used to process the request.
- transactionDate : date : The date and time the transaction was processed by our payment provider.
- transType : string : The transaction type that was processed.
- PNRef : string : The PNRef number returned for the processed request from our payment provider.
- account : string : The account number sent in the request.
- expiry : int : The expiry date sent in the request.
- cardType : string : The credit card : sent in the request (Visa, Master Card, Amex ...).
- entry : string : How the request was processed. Manual/Auto
- invoice : string : The invoice number sent in the request.
- authCode : string : The auth code returned from our payment provider for the processed request.
- responseCode : int : The Response/result of the process from our payment provider.
- balance : double : If the request was made on a gift card this will contain the remaining balance on the gift card account.
- message : string : Message returned with the result from our payment provider.
- transactionID : string : Our payment provider's transaction number returned for the processed request.
- authAmount : double : The amount authorized by the payment provider.
- amount : double : The amount processed for this request.