TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Sep 2017 |
Maintained by Kyle Vu.
Do you want to accept payments from mobile users in different countries, different payment system by writing just few of code lines? Paymentwall SDK is a global mobile payment gateway that accepts payments from more than 200 countries with 100+ alternative payment options. We now provide SDK for iOS which will become a native part of your application, it eliminates the necessity to open a web browser for payments. Less steps, faster process, there’s no doubt your conversion rate will get boost! All you have to do is import the library into your project and config it to start accepting in-app payment. It is quick and easy! We'll guide you through the process here.
XCode 8.0+, iOS 8.0+
SDK integration requires a project key. Obtain these Paymentwall API credentials in the application settings of your Merchant Account at Paymentwall.com
Our SDK is delivered as static library or public repository.
-ObjC
to Other Linker Flags
in your project's Build settingsbridging-header.h
files, then import the following files into the header file like:#import <PWCoreSDK/PWCoreSDK.h>
Update: If your CoreSDK got update during install any plugin, you should also check to update the rest of plugins.
PWCoreSDK.sharedInstance().setupPaymentwall(withProjectKey: "YOUR PUBLIC KEY", secretKey: "YOUR SECRET KEY", requestTimeout: 30)
Optional: Extra settings can be found in the Extra settings section below
Project key: All payment option will use this Project key if their Project key set to nil, you also can specify their own Project key
Secret key: PWLocal and local payment options plugins will use this Secret key as default if you specify it here
PWCoreSDKDelegate
protocol to handle payment response:func paymentResponse(_ response: PWCoreSDKResponse?) {
guard let response = response else { return }
switch response.responseCode {
case .SUCCESSFUL:
case .FAILED:
case .CANCEL:
case .MERCHANT_PROCESSING:
//Example when you use Brick and `useNativeFinishDialog == true` can be found below
}
switch response.paymentType {
case .NONE:
case .MINT:
case .PWLOCAL:
case .BRICK:
case .MOBIAMO:
case .OTHERS:
}
}
PWCoreSDK.sharedInstance().addBrickPayment(withPublicKey: nil, useNativeFinishDialog: true, cardScannerPlugin: PWCardScannerPlugin.sharedInstance())
noPrice
specify if you want to use the default Mobiamo price for each country:PWCoreSDK.sharedInstance().addMobiamoPayment(withAppID: nil, noPrice: true)
PWCoreSDK.sharedInstance().addMintPayment(withAppID: nil)
type
can be VIRTUAL_CURRENCY / DIGITAL_GOODS_FLEXIBLE / DIGITAL_GOODS_DEFAULT / CART:PWCoreSDK.sharedInstance().addPWLocalPayment(with: .DIGITAL_GOODS_FLEXIBLE, secretKey: nil)
PWCoreSDK.sharedInstance().addCustomPaymentOptions([alipay, unionpay, ...])
Note: These payment options will be place in
Local payments
together with PWLocal.
PaymentObject
class and assign to the CoreSDK:let payment = PaymentObject()
payment.name = choosenItem.name
payment.price = Double(choosenItem.price)!
payment.currency = "USD"
payment.image = choosenItem.image
payment.userID = "test_user"
payment.itemID = choosenItem.name+"id"
payment.signVersion = 3
let customSetting = ["widget":"pw",
"ag_type":"fixed"]
payment.pwLocalParams = customSetting
PWCoreSDK.sharedInstance().setPaymentObject(payment)
Note: pwLocalParams can be Dictionary or any of the defined class:
CartDefaultWidget
,DigitalGoodsDefaultWidget
,DigitalGoodsFlexibleWidget
,VirtualCurrency
, refer their headers for required property or PWLocal docs. Key and value like prices, amount, currencyCode, currencies, ag_name, ag_external_id, uid will be ignored and use the one you described inPaymentObject
PWCoreSDK.showPaymentOptionsViewController(withParentViewcontroller: self, delegate: self, showCompletion: nil)
PWCoreSDK.sharedInstance().setUseGameUI(true)
PWCoreSDK.sharedInstance().setUseNativeFinishDialogForAllMethods(false)
response: PWCoreSDKResponse
will contain the token: BrickToken
along with itIf useNativeFinishDialog
is set to false
, the SDK will dismiss after token is successfully fetched, the response.responseCode
will also be .MERCHANT_PROCESSING
, you will have to handle success/failed/3D secure yourself and store card feature wont be available
If useNativeFinishDialog
is set to true
, the loading popup will keep showing, after you process the token in your sever, post a Notification
to use the SDK success or failed dialog, also the SDK will call delegate again to return .SUCCESS
or .FAILED
:
if response.paymentType == .BRICK {
if let returnedToken = response.token {
//Process the token with your server here asynchronous
//When done:
NotificationCenter.default.post(name: Notification.Name(BRICK_TOKEN_PROCESSED_FINISH), object: nil, userInfo: nil)
}
}
Pass the error in Dictionary as ["error": errorMessage]
via userInfo
, the SDK will automatically show failed dialog instead of successful dialog
If 3D secure happen, we also support 3D secure, pass the URL in Dictionary as ["secure": urlString]
via userInfo
, the SDK will handle showing the 3D secure and pass SUCCESS/FAILED
back to app after user finish enter secure info
If you want to enable store card feature for user, pass the Charge object to our SDK via userInfo
, Charge object format can be found in our Brick docs
If you wish to provide your PWLocal signature manually:
//Define all params in step 8., and extra custom settings, then get `stringToSign`:
let payment = PaymentObject()
payment.name = choosenItem.name
payment.price = Double(choosenItem.price)!
payment.currency = "USD"
payment.image = choosenItem.image
payment.userID = "test_user"
payment.itemID = choosenItem.name+"id"
payment.signVersion = 3
let customSetting = ["widget":"pw",
"ag_type":"fixed"]
let strToSign = PWCoreSDK.sharedInstance().getStringToSign(customSetting, paymentObject: payment)
//Calculate your sign and set it
customSetting["sign"] = sha256(text: "\(strToSign!)YOUR SECRET KEY")
payment.pwLocalParams = customSetting
Paymentwall SDK supports external payment system injection (which are in our defined payment system (PS) list). Each time you want to add a new payment system, you have to include it's native SDK into your project along with our plugin framework, our framework will handle creating all the necessary parameters then you can use them to show the native local payment SDK:
pod 'PW[Local payment method]Plugin'
or manually dragging the PW[Local payment method]Plugin.a
and it's headers file to your projectbridging-headers.h
if you use SwiftNote: All plugins support your own signature string if you don't specify Secret key in both CoreSDK and PluginSDK, use
plugin.getStringToSign()
to get the string to sign, then add your signed string toplugin.signString