Code Monkey home page Code Monkey logo

balanced-ios's Introduction

balancedlogo

Build Status

iOS library for tokenizing credit card and bank accounts with Balanced Payments.

Current version : 1.0.1

v1.x requires Balanced API 1.1. Use v0.x for Balanced API 1.0.

Please refer to the following documentation sections for field documentation:

It's also recommended to review the best practices section of the Balanced documentation.

Requirements

  • ARC
  • CoreTelephony.framework

Installation

  • Download the pre-built library.
  • Add balanced.a to your project and to Build Phases -> Link Binary With Libraries.
  • Add CoreTelephony.framework to Build Phases -> Link Binary With Libraries.

Headers

includes folder

The includes folder is automatically included in the project's header search path.

  • Copy the include folder to your project (or include/balanced to your existing include folder). Drag the folder to your project to add the references.

If you copy the files to a location other than includes you'll probably need to add the path to User Header Search Paths in your project settings.

Direct copy

You can copy the headers directly into your project and add them as direct references.

  • Drag the contents of include/balanced to your project (select copy if needed)

Usage

#import "Balanced.h" - Tokenizing methods
#import "BPBankAccount.h" - Bank Accounts
#import "BPCard.h" - Cards

Create a marketplace object

Instantiate a balanced instance. Balanced instances do not need a marketplace URI since Balanced API 1.1 no longer requires authenticated tokenization. For you this means you'll get back a response containing a card href and other attributes. Send the href to your server.

Balanced *balanced = [[Balanced alloc] init];

Create a card

Please refer to the official Balanced documentation for field documentation.

With only required fields
Balanced *balanced = [[Balanced alloc] init];
[balanced createCardWithNumber:@"4242424242424242"
               expirationMonth:8
                expirationYear:2025
                     onSuccess:^(NSDictionary *response) {
                     }
                       onError:^(NSError *error) {
                       }];
With optional fields

Use an NSDictionary for additional card fields you wish to specify.

NSDictionary *optionalFields = @{
                                 BPCardOptionalParamSecurityCodeKey:@"123",
                                 BPCardOptionalParamNameKey:@"Johann Bernoulli",
                                 BPCardOptionalParamStreetAddressKey:@"123 Main Street",
                                 BPCardOptionalParamPostalCodeKey:@"11111"
                                };
Balanced *balanced = [[Balanced alloc] init];
[balanced createCardWithNumber:@"4242424242424242"
               expirationMonth:8
                expirationYear:2025
                     onSuccess:^(NSDictionary *response) {
                     }
                       onError:^(NSError *error) {
                       }
                optionalFields:optionalFields];
Example response
{
    "cards": [
        {
            "href": "/cards/CC2sx82S4zn4ECxbOloIRDxS",
            "id": "CC2sx82S4zn4ECxbOloIRDxS",
            "links": {}
        }
    ],
    "links": {},
    "status_code": 201
}

Create a bank account object

With only required fields
Balanced *balanced = [[Balanced alloc] init];
[balanced createBankAccountWithRoutingNumber:@"053101273"
                               accountNumber:@"111111111111"
                                 accountType:BPBankAccountTypeChecking
                                        name:@"Johann Bernoulli"
                                   onSuccess:^(NSDictionary *responseParams) {
                                   }
                                     onError:^(NSError *error) {
                                     }];
With optional fields

Use an NSDictionary for additional card fields you wish to specify.

NSDictionary *optionalFields = @{ BPCardOptionalParamMetaKey:@"Test" };
Balanced *balanced = [[Balanced alloc] init];
[balanced createBankAccountWithRoutingNumber:@"053101273"
                               accountNumber:@"111111111111"
                                 accountType:BPBankAccountTypeChecking
                                        name:@"Johann Bernoulli"
                                   onSuccess:^(NSDictionary *responseParams) {
                                   }
                                     onError:^(NSError *error) {
                                     }
                              optionalFields:optionalFields];
Example response
{
    "bank_accounts": [
        {
            "href": "/bank_accounts/BA7uJx0yPIqAZXxpiKq5LY2y",
            "id": "BA7uJx0yPIqAZXxpiKq5LY2y",
            "links": {}
        }
    ],
    "links": {},
    "status_code": 201
}

Contributing

Tests

Please include tests with all new code. Also, all existing tests must pass before new code can be merged.

balanced-ios's People

Contributors

ericlewis avatar mansaj avatar remear avatar wes321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

balanced-ios's Issues

Card tokenization doesn't include security code

Self explanatory.

Huge issues. We had multiple card failures when customers tried to tokenize cards. Kind of took it for granted that this would have been in the library from the get go.

Best Practices for initWithMarketplaceURI

It seems like storing a string literal of your marketplace URI on the client is a pretty big security risk (you could pull the string literal out of your binary). Are there any suggested best practices for this?

Unable to compile framework

Checking this out there's no Balanced.framework folder, and attempting to build brings up the error: "target specifies product type 'com.apple.product-type.framework.static', but there's no such product type for the 'iphoneos' platform"

thank you

Static Library

The framework approach that's currently being used in balanced-ios is cumbersome and has proven to be a barrier for new contributors. It also completely blocks any hope of testing with travis-ci since the project requires the installation of Xcode templates for the project to compile correctly.

I've rebuilt the project to compile a static library and the changes can be found in the staticlib branch. To use it, balanced.a and the headers must be copied into iOS projects. I soon discovered there is a bug when running tests from the command line. SSL requests fail with and invalid certificate error, but the same tests pass when run from within Xcode. I've implemented a macro to disable certificate checking only for command line test runs.

I'd like feedback on the following:

  • Ensure certificate checking is in fact happening in all builds of the library other than the command line
  • Ensure the static library works in both simulator and device runs of iOS projects
  • Any other issues overlooked during the conversion to building a static library

security code is not a required parameter

security_code is not a required parameter. Therefore, it probably should not be a parameter required when creating a Card. Leave it to be specified in optionalFields.

Framework download area

We need a download location for pre-built versions of Balanced.framework so users can download it and drop it into their projects without having to build the project themselves.

BPUtilities queryStringFromParameters causing EXC_BAD_ACCESS

Not sure how the memory issue was happening, but the following fixed the issue with this pull request: #17

+ (NSString *)queryStringFromParameters:(NSDictionary *)params {
    NSMutableString *queryString = [NSMutableString string];
    [params enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
        NSString* contentToAppend = [NSString stringWithFormat: @"&%@=%@", obj, key];
        [queryString appendString:contentToAppend];
    }];
    return queryString;
}

Is there a way to build a target-agnostic version of Balanced.framework

From a customer:

The balanced-ios project builds Balanced.framework Library for a specific target (simulator or device).

I can choose to build the framework for the simulator and add it to my project to run on the simulator.

Then if I need to build my app on a device I need to:

  • Delete the existing Balanced.framework from my project
  • Rebuild balanced-ios for a device
  • Add the built Balanced.framework back to my project.

Then I have to do the same process to go back to building against the simulator.

Is there a way to build a target-agnostic version of Balanced.framework? Or a way to build both and have it decide at runtime which version to use?

Reduce Friction in Collecting Card Info

Currently, there are 3 main ways to collect card information in the mobile context:

  1. Card Reader (Square)
  2. Type it in
  3. Visually scan the card (card.io)

Card readers are hard, because no one has one. Square is very nice in sending them out for free, but if I'm an app developer, the hardware portion of distributing card scanners is way too much work. I'm not building it.

Typing it in is hard. There's a lot of characters, and a lot of different fields you need to fill in. This seems like a lot of friction, and a very large spot to lose users.

Visually scanning the card with something like card.io is a great idea, but completely flops in practice. I created a test app with card.io ( and tried out some apps that use it ), and it actually took me just as long to get the card to scan as it does to type it in. And then I still had to type in the expiration date, name, and CVC.


This isn't actually an issue with balanced, or with the balanced-ios library, but it is an issue for me as I consider making apps that would leverage balanced. I've probably gone through 3 app ideas in the last month that would have used balanced, and gave up on them because I decided there was too much friction in entering card info. Just a thought, and it seems like balanced is someone who would be interested in this.

Build Issue

We received this from a customer:

The iOS repo: https://github.com/balanced/balanced-ios is failing to build.
I get the following error:

Target specifies product type
'com.apple.product-type.framework.static', but there's no such product type
for the 'iphonesimulator' platform

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.