Introduction
Welcome to Duitku Ios SDK Documentation, use this SDK Integration Documentation to start your payment with Duitku Payment Gateway.
Transaction Flow
- Checkout, When customer doing checkout in merchant's ios apps, the apps will send Request Transaction to merchant's server.
- Request Transaction, After receiving request from apps, merchant server will send Request Transaction to Duitku API.
- Get Request Transaction, Merchant server receive response from Duitku that cointains transaction detail.
- Response, Merchant server send the response back to customer's ios apps.
- Callback Notification, Duitku will send callback notification to merchant's server.
Environment
The standard IDE for application development for iOS apps is Xcode, version 9 above. For the project details, these are the minimum specifications:
- Xcode version 9 and above
- IOS version 11 and above
- Swift version: Swift 4
This documentation also contains:
- Sample Project
- Sample code for request transaction
- Sample code for check transaction
- Sample code for payment method list
Integration
Import Duitku SDK Library To Merchant Apps
Import Duitku SDK Library to your pod file
IOS SDK Cocoapods Version
pod 'duitku', '~> 1.0'
Installation IOS SDK Cocoapods
- Open terminal and navigate to your project’s root directory
- Run '$ pod init' on terminal to create a Podfile.
- Open podfile and add Duitku IOS SDK Cocoapods.
- Save the file and run '$ pod install' on terminal to install Duitku.
- Cocoapods will download and install Duitku.
- Open 'yourproject.xcworkspace' on your project file.
import Duitku SDK Class
import duitku
Initializing class
class yourclass : DuitkuClient
Include Function To Respond Callback Transaction
override func onSuccess_(status: String, reference: String, amount: String, code: String, merchantOrderId: String) {
//logic here
clearSdkTask()
}
override func onPending_(status: String, reference: String, amount: String, code: String, merchantOrderId: String) {
//logic here
clearSdkTask()
}
override func onCanceled_(status: String, reference: String, amount: String, code: String, merchantOrderId: String) {
//logic here
clearSdkTask()
}
There are 3 different function in catch callback situation.
Merchant will need to create 3 pages to show the customers about ther transaction status.
On viewWillAppear
override func viewWillAppear(_ animated: Bool) {
runPayment(self)
self.navigationController?.isNavigationBarHidden = false
self.navigationItem.title = "Order" //optional
}
Request Transaction To Merchant Server
Add Method For RequestTransaction To Merchant Server
func settingMerchant(){
Util.merchantNotification = true
DuitkuKit.data(
paymentAmount: "100000" //example //your payment amount
,productDetails: "Test Pay with duitku" //
,email: "[email protected]" //your email
,phoneNumber: "08123456789" //your customer phone number
,additionalParam: "" //optional
,merchantUserInfo: "" //optional
,customerVaName: "John Doe" // display name on bank confirmation display
,callbackUrl: 'http://example.com/callback'; // url for callback
,returnUrl: 'http://example.com/return'; // url for return
,expiryPeriod: "10" // set the expired time in minutes
,firstName: "john"
,lastName: "doe"
,alamat: "Jl. Kembangan Raya"
,city: "jakarta"
,postalCode: "11530"
,countryCode: "ID"
,merchantOrderId: "" //can empty if merchant order id on web server
)
//can loop here
ItemDetails.data(name: "sepatu" , price: 100000 , quantity: 1) //optional
// base url
BaseRequestDuitku.data(
baseUrlPayment: "http://server-merchant/api/" //base url merchant server
,requestTransaction: "requestTransaksi.php" //endpoint
,checkTransaction: "checktransaksi.php" //endpoint
,listPayment: "listPayment.php" //endpoint
)
}
Function | Description |
---|---|
Util.merchantNotification | Set notification from Duitku or from Merchant. Set value to true to use merchant notification page, or false to use duitku notification page. |
runPayment(self) | Run Duitku SDK. |
paymentAmount | Amount of transaction. |
productDetails | Product detail of transaction. |
Customer's email address, this field is mandatory. | |
phoneNumber | Customer's phone number, this field is mandatory. |
additionalParam | Additional parameter for merchant purpose. |
merchantUserInfo | Merchant user info or Customer info. |
customerVaName | Name that will be shown in VA so customer can see their name in mobile banking or ATM machine, this field is used only by VA payment channel. |
expiryPeriod | Expiry time of the transaction in minutes.(max: 1440) |
callbackUrl | Merchant callback url, this must be linked to merchant server to update the status of transaction. |
returnUrl | Merchant return url, this must be linked to merchant server to redirect customer to merchant page after finished or cancelled their payment. |
baseUrlPayment | Merchant site url to access request transaction module, check transaction module and List Payment module. |
requestTransaction | Request transaction module on merchant server. |
checkTransaction | Check transaction module on merchant server. |
listPayment | List of payment method module on merchant server. |
Start Payment Function
Call StartPayment Function
startPayment(self);
Merchant need to call startPayment() Function to continue the payment process.
Merchant's Server Side
Below are sample of merchant server module to do transaction with Duitku IOS SDK
Description | Value |
---|---|
Merchant Server Base URL | Example, https://www.merchantsite.com |
Request Transaction | download |
Check Transaction | download |
Payment List | download |
Error Handling
Getting Webkitview Exception
If you encounter this error exception, you need to import webkit framework to your target app
Getting Navigation Controller Exception
If you encounter this error exception, you need to add navigation controller to your view controller
Getting Blank When checkout payment
add these script on your info.plist file to prevent getting a blank page
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Merchant Server Side
These are sample of merchant server module to do transaction with Duitku Ios SDK
Description | Value |
---|---|
Merchant Server Base URL | Example, https://www.merchantsite.com |
Request Transaction | download |
Check Transaction | download |
Payment List | download |
Sample Ios Project
Sample project Sample-project