Paymentwall website uses cookies to store your browsing preferences on your device. However, cookies do not collect personal information.

For more information about how we use cookies, check our cookie policy

Close

Documentation

New Documentation Getting Started API Libraries APIs Checklists Flows Integrations Mobile SDKs Reference Smart TV SDK SpiderPipe Testing Payments
Contacts
If you still have questions regarding integration, please email us at devsupport@paymentwall.com

Brick iOS SDK

Attachments

Getting Started

Step 1: Install Brick

First, you need download Brick SDK

To add Brick SDK to your project:

  1. In the menubar click "File" then "Add file to YOUR_PROJECT"
  2. Select the "Brick" directory in the downloaded repository.
  3. Make sure 'Copy items into destination group's folder (if needed)' is checked.
  4. Click "Add"
  5. Click on your project, in Targets tab click in "Build Settings"
  6. In the "Header Search Paths" add link to include file of SDK such as "$SOURCE_ROOT/BrickSDK/include"
  7. In the "Library Search Paths" add link to file "BrickSDK.a"

Step 2: Configure your API key

You have to configure Brick with your public key. Specify it in your Appdelegate's -application:didFinishLaunchingWithOptions: method. See example below:

// AppDelegate.m
#import "AppDelegate.h"
#import <Brick/Brick.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [Brick setPublishableKey:@"YOUR_PUBLIC_KEY"];
  return YES;
}
@end

Step 3: Creating a one-time token

First, create the BrickCard object with the card details gathered from the user. BrickCard class stores the card details and also provide you with some method to validate it. 

Next you need to create a one-time token based on the card. Having a BrickCard object you simply call a method to retrieve token. After successful token generation, you will have a token object in your success callback handler. You should then send a token to your backend and complete a charge.

Check the example below:

#import "YourViewController.h"
#import <Brick/Brick.h>
@implementation YourViewController
- (void) getToken {
  BrickCard *card = [BrickCard new];
  card.cardNumber = @"CARD_NUMBER";
  card.cardCVC = @"CARD_CVC";
  card.expMonth = @"EXP_MONTH";
  card.expYear = @"EXP_YEAR";
  [Brick getTokenFromCard:card completion:^(BrickToken *token, NSError *error){
     if(!error){
         NSLog(@"Your token: %@",token.token);
     }
     else {
         NSLog(@"Error: %@",[[error userInfo] valueForKey: BRErrorMessageKey]);
     }
  }];
}
@end

 

Sending the token to your server

When you got the token from block method getTokenFromCard: you need to send it to your server. See the example blow:

// ViewController.m

- (void)sendTokenToServerWithToken:(BrickToken *)token
                          completion:(void (^)(NSString *response))completion {
  NSURL *url = [NSURL URLWithString:@"https://your_api/push_token"];
  NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
  request.HTTPMethod = @"POST";
  NSString *body     = [NSString stringWithFormat:@"brickToken=%@", token.token];
  request.HTTPBody   = [body dataUsingEncoding:NSUTF8StringEncoding];
  [NSURLConnection sendAsynchronousRequest:request
                                     queue:[NSOperationQueue mainQueue]
                         completionHandler:^(NSURLResponse *response,
                                                    NSData *data,
                                                   NSError *error) {
    if (error) {
      completion(nil);
    } else {
      NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
      completion(responseString);
    }
  }];
}

 

This page needs JavaScript
Your browser is
not supported anymore.
Please update to the more recent one.
This page needs JavaScript
This page needs JavaScript.
Please enable it in your browser settings and try again.
Мы используем файлы cookie, чтобы вам было удобнее пользоваться сайтом. Используя сайт Paymentwall, вы соглашаетесь с нашей Политикой использования файлов cookie.