• Stars
    star
    26
  • Rank 899,129 (Top 19 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Provide mobile in-app payments functionality within your iOS application.

Authorize.Net Accept Mobile SDK for iOS

This SDK allows mobile developers to provide credit card payment functionality within their iOS applications, without having to pass sensitive card data back to their application backend servers. For more information on including payments in your mobile application see our InApp Payments Guide

SDK Installation

CocoaPods

    pod 'AuthorizeNetAccept'  

Manual Installation

Include the AcceptSDK.framework in the application. In Xcode, select the main project file for the target. In the "General" section of the project's properties, scroll down to "Embedded Binaries", press the plus sign (+), and select the framework.

Once included, make sure in “Build Settings” tab, in section “Search Paths”, the path to these frameworks are added correctly.

SDK Usage

Initialize the SDK and set the data to be dispatched directly to Authorize.Net

        
        let handler = AcceptSDKHandler(environment: AcceptSDKEnvironment.ENV_TEST)
        
        let request = AcceptSDKRequest()
        request.merchantAuthentication.name = kClientName
        request.merchantAuthentication.clientKey = kClientKey
        
        request.securePaymentContainerRequest.webCheckOutDataType.token.cardNumber = self.cardNumberBuffer
        request.securePaymentContainerRequest.webCheckOutDataType.token.expirationMonth = self.cardExpirationMonth
        request.securePaymentContainerRequest.webCheckOutDataType.token.expirationYear = self.cardExpirationYear
        request.securePaymentContainerRequest.webCheckOutDataType.token.cardCode = self.cardVerificationCode

Register the callback and call getTokenWithRequest

        handler!.getTokenWithRequest(request, successHandler: { (inResponse:AcceptSDKTokenResponse) -> () in
            dispatch_async(dispatch_get_main_queue(),{
                self.updateTokenButton(true)

                self.activityIndicatorAcceptSDKDemo.stopAnimating()
                print("Token--->%@", inResponse.getOpaqueData().getDataValue())
                var output = String(format: "Response: %@\nData Value: %@ \nDescription: %@", inResponse.getMessages().getResultCode(), inResponse.getOpaqueData().getDataValue(), inResponse.getOpaqueData().getDataDescriptor())
                output = output + String(format: "\nMessage Code: %@\nMessage Text: %@", inResponse.getMessages().getMessages()[0].getCode(), inResponse.getMessages().getMessages()[0].getText())
                self.textViewShowResults.text = output
                self.textViewShowResults.textColor = UIColor.greenColor()
            })
        }) { (inError:AcceptSDKErrorResponse) -> () in
            self.activityIndicatorAcceptSDKDemo.stopAnimating()
            self.updateTokenButton(true)

            let output = String(format: "Response:  %@\nError code: %@\nError text:   %@", inError.getMessages().getResultCode(), inError.getMessages().getMessages()[0].getCode(), inError.getMessages().getMessages()[0].getText())
            self.textViewShowResults.text = output
            self.textViewShowResults.textColor = UIColor.redColor()
            print(output)
        }

Using the Accept Payment Token to Create a Transaction Request

Your server constructs a transaction request using the Authorize.Net API, placing the encrypted payment information that it received in previous step in the opaqueData element.

   {
    "createTransactionRequest": {
        "merchantAuthentication": {
            "name": "YOUR_API_LOGIN_ID",
            "transactionKey": "YOUR_TRANSACTION_KEY"
        },
        "refId": "123456",
        "transactionRequest": {
            "transactionType": "authCaptureTransaction",
            "amount": "5",
            "payment": {
                "opaqueData": {
                    "dataDescriptor": "COMMON.ACCEPT.INAPP.PAYMENT",
                    "dataValue": "PAYMENT_NONCE_GOES_HERE"
                }
            }
        }
    }
}

Using from Objective-C

Calling the SDK from Objective-C should be simple and intuitive:

    AcceptSDKHandler *handler = [[AcceptSDKHandler alloc] initWithEnvironment:AcceptSDKEnvironmentENV_TEST];
    AcceptSDKRequest *request = [[AcceptSDKRequest alloc] init];
    request.merchantAuthentication.name = @""; //name
    request.merchantAuthentication.clientKey = @""; //clientkey
   
    request.securePaymentContainerRequest.webCheckOutDataType.token.cardNumber = @""; //cardnumber
    request.securePaymentContainerRequest.webCheckOutDataType.token.expirationMonth = @"";
    request.securePaymentContainerRequest.webCheckOutDataType.token.expirationYear = @"";
    request.securePaymentContainerRequest.webCheckOutDataType.token.cardCode = @"";
   
    [handler getTokenWithRequest:request successHandler:^(AcceptSDKTokenResponse * _Nonnull token) {
        NSLog(@"success %@", token.getOpaqueData.getDataValue);
    } failureHandler:^(AcceptSDKErrorResponse * _Nonnull error) {
        NSLog(@"failed... );
    }];

Sample Application

We have a sample application which demonstrates the SDK usage:
https://github.com/AuthorizeNet/accept-sample-ios

Apple In-App Purchase API

Please remember that you are required to use Apple’s In-App Purchase API to sell virtual goods such as premium content for your app, and subscriptions for digital content. Specifically, Apple’s developer terms require that the In-App Purchase API must be used for digital “content, functionality, or services” such as premium features or credits. See https://developer.apple.com/app-store/review/guidelines/ for more details.

More Repositories

1

sdk-php

PHP SDK for Authorize.Net API
PHP
402
star
2

sample-code-php

This repository contains working code samples which demonstrate php integration with the Authorize.Net API
PHP
171
star
3

sdk-dotnet

.Net SDK for Authorize.Net API
C#
144
star
4

accept-sample-app

This application provides examples of how to use the Authorize.Net Accept products to integrate secure payment acceptance into your applications.
PHP
93
star
5

sdk-ruby

Ruby SDK for the Authorize.Net API
Ruby
84
star
6

sdk-node

Node.js SDK for the Authorize.Net payments platform.
JavaScript
75
star
7

sample-code-csharp

This repository contains working code samples which demonstrate C# integration with the Authorize.Net API
C#
71
star
8

sample-code-node

Sample code for the Authorize.Net Node.js SDK
JavaScript
54
star
9

sdk-python

Python SDK for the Authorize.Net API
Python
50
star
10

sample-code-python

This repository contains working code samples which demonstrate python integration with the Authorize.Net API
Python
45
star
11

sdk-java

Java SDK for Authorize.Net API
Java
43
star
12

inperson-sdk-ios

Card-present, in-person SDK for Authorize.Net.
Objective-C
37
star
13

sample-code-java

This repository contains working code samples which demonstrate java integration with the Authorize.Net API
Java
35
star
14

sample-code-ruby

This repository contains working code samples which demonstrate ruby integration with the Authorize.Net API
Ruby
22
star
15

inperson-sdk-android

Mobile SDK for Android point-of-sale applications
Java
21
star
16

accept-sdk-android

Provide mobile in-app payments functionality within your Android application
Java
20
star
17

accept-sample-ios

This is a sample iOS application, demonstrating usage of the Accept Mobile SDK for iOS
Swift
17
star
18

dotnet-core-sdk-beta

.Net Core SDK for Authorize.Net API
C#
15
star
19

webhooks-postman-collection

This repository contains a postman collection which allows you to easily configure and manage Authorize.Net Webhooks.
12
star
20

inperson-sdk-windows

.NET SDK for Windows point-of-sale applications.
C#
11
star
21

accept-sample-android

This is a sample Android application, demonstrating usage of the Accept Mobile SDK for Android
Java
7
star
22

webhooks-sample-app

This sample application demonstrates the configuration and usage of Authorize.Net webhooks
JavaScript
6
star
23

oauth-sample-app

This repository contains a sample application which demonstrates connecting to Authorize.Net using the OAuth 2.0 authentication standard.
JavaScript
5
star
24

accept-sample-ios-objectivec

Objective-C version of the Accept Mobile sample code
Objective-C
1
star