Skip to main content

Merchant Help Center

 

Affirm Merchant Help Center

iOS SDK

Summary

Affirm offers an iOS SDK that developers can add to their application. The SDK currently supports:

Please contact merchanthelp@affirm.com, or your Affirm contacts, if you have any questions or problems implementing the iOS SDK.

Installation

CocoaPods is the preferred method for installing the Affirm SDK. If you are using CocoaPods, you can set up Affirm by simply adding the following line to your Podfile:

pod 'AffirmSDK'

Alternatively, if you do not want to use CocoaPods, you may clone our GitHub repository and simply drag and drop the AffirmSDK.frameworkfolder into your XCode project.

Promotional Messaging

Monthly Payment Pricing

Monthly Payment Pricing enables you to promote financing options in your App. This messaging is a critical tool to inform customers about the availability of financing and the specific financing terms being offered through Affirm. It can be included on your product category view, product view, and cart view.

Monthly Payment Pricing is shown by creating a Label on your View, then passing that Label, along with other configuration details, to theAffirmAsLowAsmethod writeAffirmAsLowAsToLabel

func writeAffirmAsLowAsToLabel: UILabel, amount: NSDecimal, promoId: NSString, affirmType: AffirmDisplayType, affirmColor: AffirmColorType, configuration: AffirmConfiguration, callback: ^(NSError, BOOL)
  • label: Label to be used when displaying the payment pricing. This can be modified, if needed, in the callback function.
  • amount: NSDecimal representation of the price of the product (or cart).
  • promoId: Provided to you by Affirm.
  • affirmType: Can be one of (AffirmDisplayTypeLogo | AffirmDisplayTypeText | AffirmDisplayTypeSymbol | AffirmDisplayTypeSymbolHollow).
  • affirmColor: Can be one of (AffirmColorTypeBlue | AffirmColorTypeBlack | AffirmColorTypeWhite). This is only required if affirmType is AffirmDisplayTypeText.
  • configuration: Instance of AffirmConfiguration, containing your API Key and the Affirm Domain. The Affirm Domain should be cdn1-sandbox.affirm.com (for Sandbox) or cdn1.affirm.com (for Production).

Note: Monthly Payment Pricing is displayed for amount that is $50 or above.

Product Modal

The Product Modal is shown by displaying an instance of theAffirmSiteModalViewController view controller, passing in a valid Modal ID and Affirm Configuration.

func siteModalControllerWithModalId: NSString, amount: NSDecimal, configuration: AffirmConfiguration
  • modalId: Provided to you by Affirm (optional).
  • amount: NSDecimal representation of the price of the product (or cart).
  • configuration: Instance of AffirmConfiguration, containing your API Key and the Affirm Domain. The Affirm Domain should be cdn1-sandbox.affirm.com (for Sandbox) or cdn1.affirm.com (for Production).
Site-Wide Modal

The Site-Wide Modal is shown by displaying an instance of theAffirmSiteModalViewControllerview controller, passing in a valid Modal ID and Affirm Configuration.

func siteModalControllerWithModalId: NSString, configuration: AffirmConfiguration
  • modalId: Provided to you by Affirm (optional).
  • configuration: Instance of AffirmConfiguration, containing your API Key and the Affirm Domain. The Affirm Domain should be cdn1-sandbox.affirm.com (for Sandbox) or cdn1.affirm.com (for Production).

Affirm Checkout

Checkout creation is the process in which a customer uses Affirm to pay for a purchase in your store. This process is governed by the AffirmCheckoutViewController object, which requires three parameters:

  1. An AffirmCheckoutDelegate object which receives messages when the checkout creation process has succeeded or failed
  2. An AffirmConfiguration object which stores merchant-specific configuration settings
  3. An AffirmCheckout object which describes the purchase itself

Once the AffirmCheckoutViewController has been constructed from the parameters above, you may present it as with any other view controller. This initiates the flow which guides the user through the Affirm checkout process.

The flow ends once the user has successfully confirmed the checkout, canceled the checkout, or encountered an error in the process. In each of these cases, Affirm will send a message to the AffirmCheckoutDelegate along with additional information about the result.

func checkoutControllerWithDelegate: AffirmCheckoutDelegate, configuration: AffirmConfiguration, checkout: AffirmCheckout
  • delegate: Implementation of AffirmCheckoutDelegate
  • configuration: Instance of AffirmConfiguration, containing your API Key and the Affirm Domain. The Affirm Domain should be sandbox.affirm.com (for Sandbox) or affirm.com (for Production).
  • checkout: Instance of AffirmCheckout that contains the required fields for a Consumer to create a loan with Affirm. For specific field requirements, see the Initiate checkout documentation. AffirmItem, AffirmAddress, and AffirmContact are provided to help create the AffirmCheckout instance.

Creating an Authorization

Once the checkout has been successfully confirmed by the user, the AffirmCheckoutDelegate object will receive a checkout_token. This token should be forwarded to your server, which should then use the token to authorize a charge on the user's account. For more details about the server integration, see our API documentation.

Sample Application

A simple demo app which integrates Affirm can be found in the Affirm GitHub repository. CocoaPods is required to build this app.