/pagarme-ios

Pagar.me's iOS API

Primary LanguageObjective-CMIT LicenseMIT

PagarMe

Installation with CocoaPods

pod "PagarMe"

How To

Add to AppDelegate.m - didFinishLaunchingWithOptions
[[PagarMe sharedInstance] setEncryptionKey:@"Your_PagarMe_EncryptionKey"];
Usage
PagarMeCreditCard *pagarMeCreditCard = [[PagarMeCreditCard alloc] initWithCardNumber:@"4111111111111111" cardHolderName:@"Test Card" cardExpirationMonth:@"10" cardExpirationYear:@"20" cardCvv:@"123"];

if ([pagarMeCreditCard hasErrorCardNumber]) {
    // Error with CardNumber
}
else if ([pagarMeCreditCard hasErrorCardHolderName]) {
    // Error with CardHolderName
}
else if ([pagarMeCreditCard hasErrorCardCVV]) {
    // Error with CardCVV
}
else if ([pagarMeCreditCard hasErrorCardExpirationMonth]) {
    // Error with CardExpirationMonth
}
else if ([pagarMeCreditCard hasErrorCardExpirationYear]) {
    // Error with CardExpirationYear
}
else {
    // Validated all Fields!
    [pagarMeCreditCard generateHash:^(NSError *error, NSString *cardHash) {
        if(error) {
            NSLog(@"Error: %@", error);
            return;
        }
        NSLog(@"CardHash Generated: %@", cardHash);
    }];
}

Support

If you have any problem or suggestion please open an issue here.

License

Check here.