Clearent iOS Framework for IDTech VP3300

Objective C Example

Overview Bluetooth Dependencies Package Management Objective C Example Feedback

Set up

The code snippets were pulled from our Demo

Import the framework header


        #import <ClearentIdtechIOSFramework/ClearentIdtechIOSFramework.h>
        

Implement the public delegate - Clearent_Public_IDTech_VP3300_Delegate


        @interface ViewController : UIViewController<UIAlertViewDelegate,Clearent_Public_IDTech_VP3300_Delegate, UIActionSheetDelegate,MFMailComposeViewControllerDelegate>
    

Implement the ClearentManualEntryDelegate. This is used as a back up in case the reader cannot interact with the card.


        @interface ViewController : UIViewController<UIAlertViewDelegate,Clearent_Public_IDTech_VP3300_Delegate, UIActionSheetDelegate,MFMailComposeViewControllerDelegate>,ClearentManualEntryDelegate
    

Implement the successfulTransactionToken method. This method returns a token which represents the credit card and the current transaction request. The token can later be presented to run a payment transaction. When a card is processed (swipe or insert/dip of card with an emv chip), the framework will call successfulTransactionToken method when tokenization is successful.


        - (void)successTransactionToken:(ClearentTransactionToken *)clearentTransactionToken;
    

Monitor for errors. The feedback callback will return different types of messages. Some are meant to be shown to the User (user actions) because the framework is intructing the User to do something (ex- start interacting with the reader- PRESS BUTTON ON READER, INSERT/SWIPE, etc). Some messages are just informational. Some are errors.


        - (void)feedback:(ClearentFeedback *)clearentFeedback;
    

Monitor for when the device is connected. This is useful when showing the connection status.


        -(void) deviceConnected;
    

Monitor for when the device is disconnected. This is useful when showing the connection status.


      -(void) deviceDisconnected;
  

Define the framework objects to interact with


        Clearent_VP3300 *clearentVP3300;
        ClearentManualEntry *clearentManualEntry;
    

Start a Transaction

Initialize the objects. Point to sandbox to test - gateway-sb.clearent.net. Point to prod prior to go live - gateway.clearent.net


        ClearentVP3300Config *config = [[ClearentVP3300Config alloc]init];
        [config setPublicKey:publicKey];
        [config setClearentBaseUrl:baseURL];
        config.contactAutoConfiguration = false;
        config.contactlessAutoConfiguration = false;
        config.contactless = true;

        clearentVP3300 = [[Clearent_VP3300 alloc]  initWithConnectionHandling:self clearentVP3300Configuration:config];

        clearentManualEntry = [[ClearentManualEntry alloc]  init];
        [clearentManualEntry setClearentBaseUrl:baseURL];
        [clearentManualEntry setPublicKey:publicKey];

    

Create an object representing the payment request. Providing the amount is required for certain EMV checks.



    ClearentPayment *clearentPayment = [[ClearentPayment alloc] init];
    [clearentPayment setAmount:theAmount];
    clearentPayment.amtOther = 0;
    clearentPayment.type = 0;
    clearentPayment.timeout = 10;
    clearentPayment.tags = nil;
    clearentPayment.fallback = true;
    clearentPayment.forceOnline = false;

    

Create an object representing the bluetooth connection. It is recommended the bluetooth friendly name is identified prior to starting transactions.


       ClearentConnection *clearentConnection = [[ClearentConnection alloc] initBluetoothWithFriendlyName:self.deviceFriendlyName];
   

Start a transaction. The framework will connect to the reader and messages should start coming back in the feedback delegate. When the framework successfully secures the card data it will callback to the successTransactionToken delegate.


         ClearentResponse *response = [clearentVP3300 startTransaction:clearentPayment clearentConnection:clearentConnection];
         if (response.responseType != RESPONSE_SUCCESS) {
             //Notify user the transaction could not be started.
         }
     

When you are ready to process the payment, do a POST against endpoint /rest/v2/mobile/transactions/sale (for a sale). See Mobile Gateway Documentation for details.

Start a Connection.

Use this from your settings area to identify the reader. There can be potential messages coming back in the feedback delegate.

This will initiate a bluetooth search.


        ClearentConnection *connection = [[ClearentConnection alloc] initBluetoothSearch];
        [clearentVP3300 startConnection:connection];
    

Implement this delegate. When a search is performed any readers it finds will be returned.


        - (void) bluetoothDevices:(NSArray *)bluetoothDevices;