Integrating the Mobile SDK for iOS into your app
The Prosper Borrower SDK is a native SDK that allows your customers to apply for a loan within your app in a seamless and convenient way.
With the Prosper Borrower SDK, you can refer your customers to receive loan offers through Prosper. After receiving the loan offers, the customer can select an offer, create a Prosper account, and complete a loan application immediately. After the loan application has been completed, Prosper initiates loan verification and generates a loan listing for funding by investors.
Prosper Borrower SDK for iOS requirements
The Prosper Borrower SDK supports iOS 9 or higher versions.
You must use Xcode 9 or higher to build your project with the SDK.
This release contains the following:
- BorrowerFramework – folder containing the ProsperBorrowerSDK.framework.
- ProsperBorrowerSDKSample – a sample app that demonstrates how to launch the ProsperBorrowerSDK from within an app to get a loan quote and apply for a loan.
You install the SDK by adding a Cocoapod podfile within your project that references the Prosper Borrower SDK podspec. The podfile will automatically download the required third-party frameworks/libraries and link them to your build. It will also download the Prosper Borrower SDK (BorrowerFramework and ProsperBorrowerSDKSample), placing it into your project.
Before you get started…
There are just a couple of things you need to do before you can go live with the Prosper Borrower SDK. It’s not much, but it’ll make your experience easier.
- Get client keys from Prosper.
These are available for approved partners only. To become a Prosper partner, just contact us at [email protected] to apply and request keys for testing the SDK with your app.After approval, we’ll reply with the following keys, that you’ll need when integrating and testing the SDK with your app. The keys work on both the iOS and Android versions of the Prosper Borrower SDK.
- Client_Id
- Client_Secret
- Ref_AC
- Ref_MC
- Partner_Source_Code
- Client_Reference_Id
The first two keys are tied to your app when making API calls. They are used to authenticate your app.
The middle two keys associate your app as the referring partner when we generate a loan listing. Without these keys, you will not be able to integrate. You’ll set these keys in the SDK initialization method. We’ll show you where to set them a little later in this guide.
The last two keys associate the loan applicant with your client app. You’ll need to pass these keys if you decide to send us a loan applicant’s complete information to generate loan offers. More on this later. - Follow the instructions for installing and integrating the SDK in this guide.
You install the SDK by adding a Cocoapod podfile within your project that references the Prosper Borrower SDK podspec. The podfile will automatically download the required third-party frameworks/libraries and link them to your build. It will also download the Prosper Borrower SDK, placing it into your project.
- Test your integration on the Prosper Sandbox environment.
The keys you received in step 1 above work on the Prosper Sandbox environment. All of your initial testing will happen on our Sandbox environment, which is a mirror of our Production environment.
When everything is working well end to end, drop us another email ([email protected]) with a request for Production keys to go live. This new set of keys are configured to work on the Prosper Production environment. Again, these keys will work for both the iOS and Android versions of the Prosper Borrower SDK.
- Update your new Production keys in the SDK initialization method to go live on the Production environment.
SDK User Flows
User flow one: Prosper Borrower SDK displays loan offers after collecting user info
The diagram below shows the flow between your app and the Prosper Borrower SDK throughout the loan offer and application process. In this flow, your app does not collect the user information required to generate loan offers through Prosper. Instead, your app launches the Borrower SDK, leaving user information collection and loan offer display and selection to the Prosper Borrower SDK.
Note: in this flow, you may have some information about the user that you can send to Prosper, but you may not have all required information to generate offers and display them within your app.
User flow two: Your app collects user information and displays loan offers
The diagram below shows the flow between your app and the Prosper Borrower SDK throughout the loan offer and application process. In this flow, your app collects user information required to generate loan offers through Prosper. You pass this user information to the Prosper Borrower SDK. Prosper generates a list of personalized loan offers you can present to the user. You then launch the Borrower SDK when the user selects from the list of personalized loan offers.
Consumer experience in your app with the Prosper SDK
The following screens show the flow of the Prosper Borrower SDK on iOS. The first image represents an app displaying a list of personalized loan offers to a customer. Once the customer selects a loan offer, the app launches the Prosper Borrower SDK, allowing the customer to complete the loan application.
Installing the Prosper Borrower SDK using CocoaPods
Before you can integrate the Prosper Borrower SDK into your app, you must use CocoaPods to download and install third-party libraries that the Prosper Borrower SDK is dependent on.
CocoaPods is an open-source dependency manager for iOS apps, which automates and simplifies the process of using third-party libraries like AFNetworking in your projects.
Note: If you already have CocoaPods installed, you can skip to Step 2.
- Step 1: Download CocoaPods
CocoaPods is distributed as a ruby gem, and is installed by running the following commands in the Terminal:$ sudo gem install cocoapods $ pod setup
- Step 2: Create a Podfile
Project dependencies to be managed by CocoaPods are specified in a file called Podfile. Create this file in the same directory as your Xcode project (.xcodeproj) file:$ touch Podfile $ open -a Xcode Podfile
Copy and paste the following lines into the Podfile. This references the ProsperBorrowerSDK podspec:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' pod 'ProsperBorrowerSDK'
- Step 3: Install Dependencies and bring the SDK into your project
The last step in installing the SDK is to run pod install.
$ pod install
This will pull in the third-party libraries/frameworks, link them, install the Prosper Borrower SDK BorrowerFramework and ProsperBorrowerSDKSample files in your project, and either create or update an Xcode workspace for your project <_YourProjectName_>.xcworkspace.
Going forward, you should open this Xcode workspace when working.
Import the ProsperBorrowerSDK module in your project
You should import the ProsperBorrowerSDK module anywhere within your app where you may want to call the Prosper Borrower SDK.
#import ProsperBorrowerSDK
Set other settings for your client bundle
- In your client bundle’s information property list file (info.plist), change the boolean setting for the “View controller-based status bar appearance” property to “YES”.
- In your client bundle’s Capabilities, enable “Keychain Sharing”.
Additionally, set any Keychain Groups to which you want to extend the Keychain Sharing capabilities.
Initialize the Prosper SDK for iOS
Add PMIProsperConfig.initWithClientId as the first part of your didFinishLaunchingWithOptions method. This insures you have the correct authentication values for the Prosper environment in which you are launching the SDK:
Initializing SDK configuration settings using Objective C:
// Initialize the Prosper Config parameters on the Production environment [PMIProsperConfig initWithClientId:@"<your_client_id>" clientSecret:@"<your_client_secret>" refMC:@"<your_REF_mc>" refAC:@"<your_REF_mc>" prodCredentials:YES];
Initializing SDK configuration settings using Swift:
// Initialize the Prosper Config parameters on the Production environment PMIProsperConfig.initWithClientId("<your_client_id>", clientSecret: "<your_client_secret>", refMC: "<your_REF_mc>", refAC: "<your_REF_mc>", prodCredentials: true)
In the above examples prodCredentials will take one of the following values
Language | Possible values for prodCredentials |
---|---|
Objective C | YES | NO |
Swift | true | false |
If set to “NO” or “false”, when the client is launched, the SDK will point to Prosper’s Sandbox environment for authentication and API requests. Use this setting during your initial integration and testing of the Prosper Borrower SDK with you app.
If set to “YES” or “true”, when the client is launched, the SDK will point to Prosper’s Production environment for authentication and API requests. Use this setting when you are ready to go live with the Prosper Borrower SDK integrated into your app.
You’re all set! At this point, the Prosper Borrower SDK is installed and set up. You can now invoke the Prosper Borrower SDK and get personalized loan offers for users through Prosper.
Collecting loan applicant information for loan offers
To generate personalized loan offers for a user, Prosper requires 14 pieces of information about the loan applicant.
We’ll show you how to send this information to the SDK a bit later, but this list can help you decide whether you want to collect this information from your app, or let the SDK collect the information. Even if you have a small subset of this information, it may help to pass it to the SDK to speed the loan application process.
User info required to generate loan offers:
- Loan Amount
- Loan Purpose
- First Name
- Last Name
- Date Of Birth (DOB)
- Street Address
- City
- State
- Zip-code
- Employment Status
- Annual Income
- Client Reference Id
- Partner Source Code
To speed up the creation of a loan listing, Prosper can also accept additional information about the loan applicant:
- Primary phone number
- Secondary phone number
- Employer name
- Employer phone number
- Work phone number
- Employer start date
- Occupation type
- Social security number
- Bank account number
- Bank routing number
- Credit range value
Select the user flow that best matches your development needs.
There are two user flows to choose from, described previously:
- Prosper Borrower SDK displays loan offers after collecting borrower info – You either cannot or do not want to collect the 12 required pieces of information from users within your app. You are OK with relinquishing control to the Prosper Borrower SDK for collecting this information, and displaying the personalized loan offers to the user.
In this case, you will initialize the Prosper Borrower SDK, passing in a nil value for user details. The Prosper Borrower SDK takes care of the rest.
Note: If your app has collected a subset of the 12 required fields (or additional fields), you can pass them to the SDK, and the SDK will collect any missing information.
- Your app collects user information and displays loan offers – You may want to have tight control over how (and how many) loan offers are presented to your users. Prosper provides the PMIProspectOffersAPIService API to get a list of personalized loan offers you can present to your users.
In this case, you will collect the information above, construct a PMIBorrowerInfo object with this information, and pass the object in a call to the PMIProspectOffersAPIService API. You can then display one or more personalized loan offers returned by the API within your app. When a user selects the offer, you will launch the SDK with that selected loan offer. The Prosper Borrower SDK will take care of the rest.
Prosper Borrower SDK displays loan offers after collecting user info
If you cannot or do not want to collect all 12 pieces of user information to generate loan offers, you can launch the Borrower SDK, allowing the Prosper Borrower SDK to collect this information and present the loan offers to the user.
Passing no user information fields
The following example shows the first case, where you are passing no borrower info fields to the SDK.
Using Objective C:
You will initialize the SDK with the initWithDetails method input set to nil:
PMIBorrowerViewController *borrowerViewController = [[PMIBorrowerViewController alloc] initWithDetails:nil delegate:self]; [self presentViewController:borrowerViewController animated:YES completion:nil];
Using Swift:
You will initialize the SDK with the details set to nil:
let borrowerViewController = PMIBorrowerViewController.init(details: nil, delegate: self) self.presentViewController(borrowerViewController, animated: true, completion: nil)
The Prosper Borrower SDK will then take control, guiding the user through several screens, collecting the 12 pieces of information, requesting that the user create a Prosper account, and presenting a set of pre-approved personalized loan offers the user can select from.
Passing some user information fields
In the case where you are passing only some of the 14 user info fields (and possibly some additional fields), you will initialize the SDK passing a requestParams object of type PMIBorrowerInfo to the initWithDetails method:
Once you collect this information from your user, you construct a PMIBorrowerInfo object for the loan applicant.
Using Object C:
// Full object with required 14 fields shown. // In your case, only some of the required user info fields collected PMIBorrowerInfo *borrowerInfo = [[PMIBorrowerInfo alloc] init]; borrowerInfo.loanAmount = @35000; borrowerInfo.loanPurposeId = PMIHomeImprovement; borrowerInfo.employmentStatusId = PMIEmployed; borrowerInfo.firstName = @"Monise"; borrowerInfo.lastName = @"Kelly"; borrowerInfo.dateOfBirth = @"01/01/1965"; borrowerInfo.address1 = @"14511 Star Cross Trl"; borrowerInfo.city = @"Helotes"; borrowerInfo.state = @"TX"; borrowerInfo.zipCode = @"78023"; borrowerInfo.annualIncome = @80000; borrowerInfo.email = @"[email protected]"; borrowerInfo.partnerSourceCode = <ValueGivenToYou>; borrowerInfo.clientReferenceId = <ValueGivenToYou>; // Optional additional borrower info to pass to Prosper Borrower SDK borrowerInfo.primaryPhoneNumber = "4085550175"; borrowerInfo.secondaryPhoneNumber = "4085550235"; borrowerInfo.employerName = @"City Hospital"; borrowerInfo.employerPhoneNumber = @"4085550199"; borrowerInfo.workPhoneNumber = @"4085550100"; borrowerInfo.employerStartDate = @"04/2010"; borrowerInfo.occupationType = PMIDoctor; borrowerInfo.ssnNumber = @"666720553"; borrowerInfo.bankAccountNumber = @"32423435345435"; borrowerInfo.bankRoutingNumber = @"121000248"; borrowerInfo.creditRangeId = PMIExcellentCredit;
Using Swift:
// Full object with required 14 fields shown. // In your case, only some of the required user info fields collected let borrowerInfo:PMIBorrowerInfo = PMIBorrowerInfo.init() borrowerInfo.loanAmount = 35000 borrowerInfo.loanPurposeId = PMIHomeImprovement.rawValue borrowerInfo.employmentStatusId = PMIEmployed.rawValue borrowerInfo.firstName = "Monise" borrowerInfo.lastName = "Kelly" borrowerInfo.dateOfBirth = "01/01/1965" borrowerInfo.address1 = "14511 Star Cross Trl" borrowerInfo.city = "Helotes" borrowerInfo.state = "TX" borrowerInfo.zipCode = "78023" borrowerInfo.annualIncome = 80000 borrowerInfo.email = "[email protected]" borrowerInfo.partnerSourceCode = <ValueGivenToYou> borrowerInfo.clientReferenceId = <ValueGivenToYou> // Optional additional borrower info to pass to Prosper Borrower SDK borrowerInfo.primaryPhoneNumber = "4085550175" borrowerInfo.secondaryPhoneNumber = "4085550235" borrowerInfo.employerName = "City Hospital" borrowerInfo.employerPhoneNumber = "4085550199" borrowerInfo.workPhoneNumber = "4085550100" borrowerInfo.employerStartDate = "04/2010" borrowerInfo.occupationType = PMIDoctor.rawValue borrowerInfo.ssnNumber = "666720553" borrowerInfo.bankAccountNumber = "32423435345435" borrowerInfo.bankRoutingNumber = "121000248" borrowerInfo.creditRangeId = PMIExcellentCredit.rawValue
Note: For a full list of values that can be entered for creditRangeId, loanPurposeId, employmentStatusId and occupationType, refer to the PMIBorrowerConstants.h file in the Headers directory of the ProsperBorrowerSDK framework.
Using Objective C:
PMIBorrowerViewController *borrowerViewController = [[PMIBorrowerViewController alloc] initWithDetails:borrowerInfo delegate:self]; [self presentViewController:borrowerViewController animated:YES completion:nil];
Using Swift:
let borrowerViewController = PMIBorrowerViewController.init(details: borrowerInfo, delegate: self) self.presentViewController(borrowerViewController, animated: true, completion: nil)
The Prosper Borrower SDK will then take control, guiding the user through several screens, collecting the 12 pieces of information, requesting that the user create a Prosper account, and presenting a set of pre-approved personalized loan offers the user can select from.
User selects and completes the loan offer
Pre-approved loan offers generated by the Prosper Borrower SDK require user consent and user acceptance of the Prosper Marketplace Terms and Conditions for the loan to become an active listing for funding.
Once the loan offer is selected, the Prosper Borrower SDK guides the user through the process, displaying Prosper Marketplace Terms and Conditions and requiring consent and acceptance as part of the user experience.
Your app collects user information and displays loan offers
The Prosper Borrower SDK provides the PMIProspectOffersAPIService API to get a list of loan offers for your users. Getting a list of loan offers is a two-step process.
Step 1: Collect loan applicant information
To generate the loan offers, Prosper requires 14 pieces of information about the loan applicant:
- Loan Amount
- Loan Purpose
- First Name
- Last Name
- Date Of Birth (DOB)
- Street Address
- City
- State
- Zip code
- Employment Status
- Annual Income
- Client Reference Id
- Partner Source Code
To speed up the creation of a loan listing, Prosper will also accept additional information about the loan applicant.
- Primary phone number
- Secondary phone number
- Employer name
- Employer phone number
- Work phone number
- Employer start date
- Occupation type
- Social security number
- Bank account number
- Bank routing number
- Credit range value
Once you collect this information from your user, you construct a PMIBorrowerInfo object for the loan applicant.
Using Objective C:
// Building borrower info object with 12 required fields PMIBorrowerInfo *borrowerInfo = [[PMIBorrowerInfo alloc] init]; borrowerInfo.loanAmount = @35000; borrowerInfo.loanPurposeId = PMIHomeImprovement; borrowerInfo.employmentStatusId = PMIEmployed; borrowerInfo.firstName = @"Monise"; borrowerInfo.lastName = @"Kelly"; borrowerInfo.dateOfBirth = @"01/01/1965"; borrowerInfo.address1 = @"14511 Star Cross Trl"; borrowerInfo.city = @"Helotes"; borrowerInfo.state = @"TX"; borrowerInfo.zipCode = @"78023"; borrowerInfo.annualIncome = @80000; borrowerInfo.email = @"[email protected]"; borrowerInfo.partnerSourceCode = <ValueGivenToYou>; borrowerInfo.clientReferenceId = <ValueGivenToYou>; // Optional additional borrower info to pass to Prosper Borrower SDK borrowerInfo.primaryPhoneNumber = "4085550175"; borrowerInfo.secondaryPhoneNumber = "4085550235"; borrowerInfo.employerName = @"City Hospital"; borrowerInfo.employerPhoneNumber = @"4085550199"; borrowerInfo.workPhoneNumber = @"4085550100"; borrowerInfo.employerStartDate = @"04/2010"; borrowerInfo.occupationType = PMIDoctor; borrowerInfo.ssnNumber = @"666720553"; borrowerInfo.bankAccountNumber = @"32423435345435"; borrowerInfo.bankRoutingNumber = @"121000248"; borrowerInfo.creditRangeId = PMIExcellentCredit;
Using Swift
// Building borrower info object with 14 required fields let borrowerInfo:PMIBorrowerInfo = PMIBorrowerInfo.init() borrowerInfo.loanAmount = 35000 borrowerInfo.loanPurposeId = PMIHomeImprovement.rawValue borrowerInfo.employmentStatusId = PMIEmployed.rawValue borrowerInfo.firstName = "Monise" borrowerInfo.lastName = "Kelly" borrowerInfo.dateOfBirth = "01/01/1965" borrowerInfo.address1 = "14511 Star Cross Trl"; borrowerInfo.city = "Helotes" borrowerInfo.state = "TX" borrowerInfo.zipCode = "78023" borrowerInfo.annualIncome = 80000 borrowerInfo.email = "[email protected]" borrowerInfo.partnerSourceCode = <ValueGivenToYou> borrowerInfo.clientReferenceId = <ValueGivenToYou> // Optional additional borrower info to pass to Prosper Borrower SDK borrowerInfo.primaryPhoneNumber = "4085550175" borrowerInfo.secondaryPhoneNumber = "4085550235" borrowerInfo.employerName = "City Hospital" borrowerInfo.employerPhoneNumber = "4085550199" borrowerInfo.workPhoneNumber = "4085550100" borrowerInfo.employerStartDate = "04/2010" borrowerInfo.occupationType = PMIDoctor.rawValue borrowerInfo.ssnNumber = "666720553" borrowerInfo.bankAccountNumber = "32423435345435" borrowerInfo.bankRoutingNumber = "121000248" borrowerInfo.creditRangeId = PMIExcellentCredit.rawValue
Note: For a full list of values that can be entered for creditRangeId, loanPurposeId, employmentStatusId and occupationType, refer to the PMIBorrowerConstants.h file in the Headers directory of the ProsperBorrowerSDK framework.
Step 2. Call the PMIProspectOffersAPIService to get marketplace loan offers
In this step, you will pass the PMIBorrowerInfo (borrowerInfo) object you constructed in Step 1 to get a list of loan offers.
Using Objective C:
[PMIProspectOffersAPIService getMarketPlaceOffers:borrowerInfo withCompletionBlock:^(PMIProspectOffersResponse *servicesRespObj) { // Get the loanofferlist object from the PMILoanOffersResponse if(nil == servicesRespObj.responseError) { PMILoanOfferList *loanOfferList = servicesRespObj.loanOfferList; if (loanOfferList.offers) { NSArray *offers = servicesRespObj.loanOfferList.offers; } } else { // Log the error response PMIResponseError *error = [servicesRespObj responseError]; NSLog(@"Error Description = %@",[error getErrorDescription]); NSLog(@"Server Error code = %@",[error getServerErrorCode]); } }];
Using Swift:
PMIProspectOffersAPIService.getMarketPlaceOffers(borrowerInfo, withCompletionBlock: { (offersResponse:PMIProspectOffersResponse!) -> Void in self.loadingView.hidden = true if let offerList:PMILoanOfferList = offersResponse.loanOfferList { } else { let alert:UIAlertView = UIAlertView(title: "Error", message:offersResponse.responseError.getErrorDescription(), delegate: nil, cancelButtonTitle: "Ok") alert.show() } })
The code above returns an Offers list object. The list contains different loan offers for which the user has been pre-approved. These offers range between different interest rates, APRs and length of term. It is up to your development team to determine the offers to display to the user. If the call is unsuccessful, you will receive an error from the PMILoanOffersAPIService.
User selects loan offer
Once the user selects the offer, you pass the selected offer to the PMIBorrowerViewController, which will guide the user through the loan application process.
To access a particular offer by index, you can do something like this in the OffersCallback success. In the following code, the first offer has been selected:
Using Objective C:
PMILoanOffer *userSelectedoffer = [offers objectAtIndex:0]; PMIBorrowerViewController *controller = [[PMIBorrowerViewController alloc] initWithOffer: userSelectedoffer delegate:self]; [self presentViewController:controller animated:YES completion:nil];
Using Swift:
let offer:PMILoanOffer = offers[0] as! PMILoanOffer let viewController:OfferViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("OfferViewController") as! OfferViewController viewController.loanOffer = offer self.navigationController?.pushViewController(viewController, animated: true)
User completes the loan offer
Pre-approved loan offers generated by the Prosper Borrower SDK require user consent and user acceptance of the Prosper Marketplace Terms and Conditions for the loan to become an active listing for funding. The Prosper Borrower SDK guides the user through the process, displaying Prosper Marketplace Terms and Conditions and requiring consent and acceptance as part of the user experience.
Adding delegate methods
Your view controller should conform to the PMIBorrowerDelegate protocol and implement the delegate methods.
Using Obejctive C:
@interface PMIBorrowerViewController :UIViewcontroller <PMIBorrowerDelegate> @end
Using Swift:
class OfferViewController: UIViewController, PMIBorrowerDelegate { }
Add the following PMIBorrowerDelegate method to your view controller. This method is called after the PMIBorrowerViewController is closed, giving status.
Using Obejctive C:
- (void)borrowerViewController:(PMIBorrowerViewController *)borrowerViewController loanProcessedStatus:(BorrowerLoanStatus)status { if(status == PMIBorrowerLoanSuccess) { NSLog(@"Loan application was successfully processed."); } else if(status == PMIBorrowerLoanCancelled) { NSLog(@"Loan application process cancelled"); } else if(status == PMIBorrowerTimedOut) { NSLog(@"Loan process timed out due to an inactive user session"); } else if(status == PMIBorrowerLoanError) { NSLog(@"Loan process timed out due to a loan error"); } }
Using Swift:
func borrowerViewController(borrowerViewController:PMIBorrowerViewController, loanProcessedStatus loanStatus:BorrowerLoanStatus) { var status:String = "" if loanStatus == PMIBorrowerLoanSuccess { status = "Loan application was successfully processed." } else if loanStatus == PMIBorrowerLoanCancelled { status = "Loan application process cancelled." } else if loanStatus == PMIBorrowerTimedOut { status = "Loan process timed out due to an inactive user session." } else if loanStatus == PMIBorrowerLoanError { status = "Loan process timed out due to a loan error." } let alert:UIAlertView = UIAlertView(title: "Alert", message: status, delegate: nil, cancelButtonTitle: "Cancel") alert.show() self.navigationController?.popToRootViewControllerAnimated(true) }
Sample app
A sample app can be found in the ProsperBorrowerSDKSample folder. The sample app demonstrates how to integrate the Prosper Borrower SDK.
You can use the instructions within this guide to see how the SDK works. Remember to request app keys before trying out the sample app. You’ll need them to run the sample app.
Contact us
Do you have any questions, comments for us, or problems integrating the Prosper Borrower SDK into your app?
Contact us at [email protected]