Documentation
Mobiamo iOS SDK
Accept in-app payments with Paymentwall’s advanced mobile payment solution. Mobiamo is a mobile carrier billing platform with global coverage. Our iOS SDK was designed to enable 1-click payments via mobile carrier billing within your mobile application.
All you have to do is to import the library into your iOS project and start using our SDK to accept in-app payments. It is quick and easy! We'll guide you through the process here.
How does it work ?
- The customer can make a purchase, simply by clicking on the buy button inside your application.
- The Mobiamo SDK is called at this moment and displays a pop up dialog with the payment information.
- User confirms the payment simply by clicking on the “Buy” button.
- The payment is completed and your callback function is triggered to handle its result. We will also notify your backend about this event.
Requirements
- MessageUI.framework
- CoreTelephony.framework
Credentials
Your mobile integration requires a Project key.
You can obtain these Paymentwall API credentials in the application settings of your Merchant Account at paymentwall.com
Add SDK to your project
- In the menubar click "File" then "Add file to YOUR_PROJECT".
- Select the "MobiamoSDK" directory in the downloaded repository.
- Make sure 'Copy items into destination group's folder (if needed)' is checked.
- Click "Add"
- Click on your project, in Targets tab click in "Build Settings"
- In the "Header Search Paths" add link to include file of SDK such as "$SOURCE_ROOT/MobiamoSDK/include"
- In the "Library Search Paths" add link to file "MobiamoSDK.a"
- In "Build Phases" tab add "MobiamoResources.bundle" to "Copy Bundle Resources"
Accepting your first payment
Import
Objective-C
#import "MobiamoSDK.h"
Swift
Add this command to your Bridging-Header.h file
#import "MobiamoSDK.h"
Create Mobiamo request
Firstly, you need to provide your project key and set your product's id and name. Both can be strings up to 255 characters. Secondly, you should also specify the user identifier; it can be your internal in-app ID of the user or any other identifier. Last but not least, please contact PW supporting team to activate in backend by allowing mobiamo pinless for your project. See example below:
Objective-C
[MobiamoSDK setApplicationKey: YOUR_APPLICATION_HERE userID:YOUR_USER_ID productID:PRODUCT_ID productName:PRODUCT_NAME price: PRICE andCurrency:CURRENCY];
Swift
MobiamoSDK.setApplicationKey(YOUR_APPLICATION_HERE, userID: YOUR_USER_ID, productID: PRODUCT_ID, productName: PRODUCT_NAME, price: PRICE, andCurrency: CURRENCY)
Choose you wish to implement. Currently Mobiamo SDK supports 2 flows:
Price point selection
On the payment popup the user will be able to choose which price point they prefer to complete the payment with. In other words, you can provide the user with predetermined price options (i.e you can offer 100 credits for 1 USD or 1000 credits for 10 USD). Please note that the range of price points is limited using mobile payments, so in most cases you can’t set custom values.
All you need to do is create an intent and run the process:
Objective-C
[MobiamoSDK setApplicationKey: YOUR_APPLICATION_HERE userID:YOUR_USER_ID productID:PRODUCT_ID productName:PRODUCT_NAME price:@"" andCurrency:@""];
MobiamoViewController *viewController = [MobiamoSDK createNewMobiamoViewController];
viewController.delegate = self;
[viewController showMobiamoWithParentViewController:self completion:^(int code){
}];
Swift
MobiamoSDK.setApplicationKey(YOUR_APPLICATION_HERE, userID: YOUR_USER_ID, productID: PRODUCT_ID, productName: PRODUCT_NAME, price: "", andCurrency: "")
var viewController: MobiamoViewController = MobiamoSDK.createNewMobiamoViewController()
viewController.delegate = self
viewController.showMobiamoWithParentViewController(self, completion:{ (code) -> Void in
})
Price point preselected
When you know which exact price you want to be charged (let’s say you’ve cached all available price points) you can force Mobiamo SDK to charge this exact amount. The user will not see the price points selection drop down.
For this case, you need to add additional parameters of amount and currency to the MobiamoRequest:
Objective-C
[MobiamoSDK setApplicationKey: YOUR_APPLICATION_HERE userID:YOUR_USER_ID productID:PRODUCT_ID productName:PRODUCT_NAME price: PRICE andCurrency:CURRENCY];
MobiamoViewController *viewcontroller = [MobiamoSDK createNewMobiamoViewController];
viewcontroller.delegate = self;
[viewcontroller showMobiamoWithParentViewController:self completion:^(int code){
}];
Swift
MobiamoSDK.setApplicationKey(YOUR_APPLICATION_HERE, userID: YOUR_USER_ID, productID: PRODUCT_ID, productName: PRODUCT_NAME, price: PRICE, andCurrency: CURRENCY)
var viewController: MobiamoViewController = MobiamoSDK.createNewMobiamoViewController()
viewController.delegate = self
viewController.showMobiamoWithParentViewController(self, completion:{ (code) -> Void in
})
Result handling
You have to add MobiamoSDKDelegate to your ViewController:
Objective-C
@interface YourViewController : UIViewController <MobiamoSDKDelegate>
Swift
class YourViewController: UIViewController, MobiamoSDKDelegate
You can handle payment results by defining your callback function. We recommend syncing up with your server at this stage to sync up user's balance, confirm purchased item etc. See the example:
Objective-C
#pragma mark - Mobiamo SDK Delegate
-(void)mobiamoResponse:(MobiamoResponse *)response
{
switch (response.responseCode) {
case MOBIAMO_SUCCESSFUL:
break;
case MOBIAMO_FAILED:
break;
case MOBIAMO_CANCEL:
break;
default:
break;
}
}
Swift
// MARK:- Mobiamo SDK Delegate
func mobiamoResponse(response: MobiamoResponse!) {
switch response.responseCode {
case Int32(MOBIAMO_SUCCESSFUL.value):
break
case Int32(MOBIAMO_FAILED.value):
break
case Int32(MOBIAMO_CANCEL.value):
break
default:
break
}
}
responseCode
code can get one of the following values:
MOBIAMO_SUCCESSFUL
: user has completed the payment
MOBIAMO_FAILED
: user has aborted the payment
MOBIAMO_CANCEL
: can't connect to Mobiamo system due to network/SSL/parameters error.
MobiamoResponse object stores all the information about the payment like payment amount, product name, product ID which was set before.
Server notification handling
After each successful payment we will notify your server about it. We recommend to use this feature as it is the most reliable way to know when the payment went through. Even if your application crashes for some reason, your server will still be notified, so you can sync up later.
Please use pingback processing documentation for more information.
In order to download and install the Mobiamo iOS SDK, please contact us at devsupport@paymentwall.com