Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 1.99 KB

README.textile

File metadata and controls

46 lines (36 loc) · 1.99 KB

Objective Merchant

This project is an open-source Objective-C port of the popular Shopify library, active_merchant , which enables developers to process sales transactions in Ruby.

The goal of the project is to duplicate as much of the core functionality from active_merchant as possible, but using Objective-C standards and design guidelines.

Initially, a limited number of processing gateways will be supported… mostly likely Authorize.Net and Paypal.

It is sponsored by Transparent Financial Services at TransFS.com.

Authorize.Net Example

Here is a basic example of how to use this library with the Authorize.Net gateway:


	BillingResponse *response;	
	[BillingBase setGatewayMode:Test];

	BillingCreditCard *card = [[BillingCreditCard alloc] init:[NSDictionary dictionaryWithObjectsAndKeys:
															   @"4111111111111111", @"number",
															   [NSNumber numberWithInt:8], @"month",
															   [NSNumber numberWithInt:2012], @"year",
															   @"Joshua", @"firstName",
															   @"Krall", @"lastName",
															   @"123", @"verificationValue",
															   nil]];
	
	if ([card is_valid])
	{
		AuthorizeNetGateway *gateway = [[AuthorizeNetGateway alloc] init:[NSDictionary dictionaryWithObjectsAndKeys:
																		  @"my_login", @"login",
																		  @"my_tran_key", @"password",
																		  nil]];

		response = [gateway authorize:[NSNumber numberWithInt:200] creditcard:card options:[[NSDictionary alloc] init]];
		if (![response is_success])
			[NSException raise:@"Authorize.Net Gateway Error, authorize:" format:[response message]];
		else {
			response = [gateway capture:[NSNumber numberWithInt:200] authorization:[response authorization] options:[[NSDictionary alloc] init]];
			if (![response is_success])
				[NSException raise:@"Authorize.Net Gateway Error, capture:" format:[response message]];
		}
	}