USAePay-iOS UI Library

The USAePay-iOS UI Library allows developers to implement our payment gateway within their iOS apps (iPhone & iPad). The library is designed to give developers the tools necessary to create a highly customized payment applications. Developers can choose to use our pre-made “UIView” that contains all the necessary credit card payment fields, or creating their own credit card payment UIView.

The library supports iOS 7.0+.

Download: USAePayLibrary1.5.zip. It contains two example projects and the Library itself.

Read the Start Guide below to learn how to add the library into your new/existing projects.

Once you added the library into the project. Use this code snippet to help you get started.

#import "iPhoneViewController.h"
#import "Constants.h"

@implementation iPhoneViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    Constants *shareManager = [Constants sharedManager];

    /*
     * These are the required information, which need to initialize
     * Before doing any transactions
     */
    shareManager.isProduction = true;
    shareManager.sourceKey = @"253idtPXb6aXvaX3LdSM1SDLIn12ARCI";
    shareManager.pinNum = @"1234";


}

CreditCardPayment Methods

Method Description
verifyCreditCard Verify credit card number
checkExpDate Verify credit card expiration date
processCCPayment Process credit card payment
finishProcessingPayment Delegate method, when payment is finished processing

ueConnection Methods

Method Description
isConnected Checks for internet connection

Methods

verifyCreditCard

Verify the credit card number

Description

This method takes in the credit card number as a string. Then it runs through a verification algorithm checking to see if the credit card is valid or invalid.

The method returns true if the credit card is valid. Returns false if the credit card is invalid.

Code Snippet

- (void)checkCreditCard
{
   CreditCardPayment *ccPayment = [[CreditCardPayment alloc]init];

   NSString *creditCardValue = @"5555444433332226";

   if([ccPayment verifyCreditCard:creditCardValue])
    {
        NSLog(@"credit card is valid");
    }

    else
    {
        NSLog(@"Credit card is invalid");
    }
}

checkExpDate

Verify the expiration date of a credit card

Description

This method takes in the credit card expiration date as a string. The date has a format of two digits for month and year. The month and year are not required to have a separator.

ie. 09/15
ie. 0915
ie. 09.15
ie. 09-15

It takes all the above form as a valid expiration date input.

The method will calculate the input date against the current date. It returns true if the expiration date is valid. Returns false if the expiration date is invalid.

Code Snippet

-(void)checkExpDate
{
    CreditCardPayment *ccPayment = [[CreditCardPayment alloc]init];

    NSString *expDate = @"09-15";

    if([ccPayment verifyExpDate:expDate])
    {
        NSLog(@"Expiration date is valid");
    }

    else
    {
        NSLog(@"Expiration date is invalid");
    }
}

processCCPayment

Process credit card payment

Description

The method doesn’t need any parameter values. Before you call this method, make sure you have these values set

Required
    1) creditCardNumber
    2) creditCardExpDate
    3) creditCardCVV
    4) creditCardHolderName
    5) creditCardAvsStreet
    6) creditCardAvsZip
    7) creditCardChargeAmount
Optional
    8) invoiceNumber

Once all the above required values have set, we can call processCCPayment() method to process a credit card transaction

Code Snippet

-(void)processTransaction
{
    CreditCardPayment *ccPayment = [[CreditCardPayment alloc]init];

    ccPayment.creditCardNumber = @"5555444433332226";
    ccPayment.creditCardExpDate = @"0916";
    ccPayment.creditCardCVV = @"123";
    ccPayment.creditCardHolderName = @"test name";
    ccPayment.creditCardAvsStreet = @"123 test street";
    ccPayment.creditCardAvsZip = @"90012";
    ccPayment.creditCardChargeAmount = @"22.50";

    [ccPayment processCCPayment];

}

finishProcessingPayment

Delegate method, when payment is finished processing

Description

This method gets call once the payment is finished processing. It contains a uesoapTransactionResponse parameter that holds the processing result information. Read uesoapTransactionResponse.h for all the return description.

Code Snippet

-(void)processTransaction
{
    CreditCardPayment *ccPayment = [[CreditCardPayment alloc]init];

    //Needed to set the delegate to self in order for the callback method to work
    ccPayment.delegate = self;

    ccPayment.creditCardNumber = @"5555444433332226";
    ccPayment.creditCardExpDate = @"0916";
    ccPayment.creditCardCVV = @"123";
    ccPayment.creditCardHolderName = @"test name";
    ccPayment.creditCardAvsStreet = @"123 test street";
    ccPayment.creditCardAvsZip = @"90012";
    ccPayment.creditCardChargeAmount = @"22.50";

    [ccPayment processCCPayment];

}

/*
 * This delegate method gets call when the payment is finished processing
 * It will return the processing result regarding to the transaction
 * Such ass Approved, failed, error and etc..
 * response.Result is one of the property, please go to uesoapTransactionResponse.h
 * For a list of all the available properties
 */
-(void)finishProcessingPayment :(uesoapTransactionResponse *)response
{
    NSLog(@"Credit Card Status: %@", response.Result);
}

isConnected

Check for internet connectivity

Description

The method returns true if there is internet connection. Returns false if there is no internet connection.

Code Snippet

-(void)checkInternet
{
   if([ueConnection isConnected])
    {
       NSLog(@"There is internet");
    }

    else
    {
       NSLog(@"There is no internet");

    }
}

Start Guide

Getting started with the USAePay-iOS UI Library

Step 1

  • Create a new xcode-project

1

Step 2

  • Select Next

2

Step 3

  • Enter a product name, (you can input any name you like, in this case, we have “CCProcessingView”)

3

Step 4

  • Select next, save the project to any directories you like. Now we have created a new project

4

Step 5

  • Now right click, select “New Group” to create a new folder, name it “USAePayLibrary”

5

Step 6

  • You should see a new folder call USAePayLibrary on the left side menu

6

Step 7

  • If you haven't unzip the library you downloaded, please unzip it and you will see three files

7

Step 8

  • Drag the Library folder to the project into USAePayLibrary Folder

8

Step 9

  • Make sure “Copy items into destination group’s folder(if needed)” is selected, and the targets “CCProcessingView” is selected

9

Step 10

  • Click finish, and you will see the library added to the project

Step 11

  • One last thing, add -all_load to Linker Flags
    • a) Go to the target, then go to Build Settings

11a

  • b) Type in “Other” in the search field, then go down to "Other Linker Flags"

11b

  • c) Double click on “Other Linker Flags” opens a drop down menu

11c

  • d) Click the add button, type in "-all_load"

11d

  • e) Saves it, your final build setting should look like this

11e

  • f) Thats it, you can start using the library. There is a "Settings.bundle" on the left, if you don't know what that is, just ignore it. It doesn't affect the project or the code if you don't have it.

Change Log

Date Version Change
02/2019 1.5 Added in new support to handle longer invoice number