Midtrans Payment Integration in iOS

Updated 30 April 2019


This blog will be about the integration Midtrans payment gateway in the iOS application using swift language. Before the start to integration the Midtrans payment, let you know payment type in the Midtrans payment gateway.

1. GO-PAY: Midtrans accepting transaction directly from the website or chat application.
2. AKULAKU: Midtrans Payment service without credit card from the customer account. Customers can make payments using the credit limit on my Akulaku account.
3. Indomaret: Midtrans Payment services through Indomaret outlets throughout Indonesia. Payment can be made by cash or debit.
4. Credit card: Midtrans Payment using a credit/debit card bearing the VISA / MasterCard / JCB / Amex logo, from all local and international banks.
5.Virtual Account: Transfer payment services from any local account via ATM Bersama / Prima / Alto. Facilitated by Bank Permata.
6.Mandiri clickpay: Internet banking payment service from Bank Mandiri. Payment can be made by entering a 16 digit Mandiri debit and token card.

Let start the integrate Midtrans payment gateway, for this, we have to follow some steps which I mentioned in the below

  1. Download the Midtrans SDK using pod.
    1.1 Please install Cocoapods version 1.0.0. You can find the installation guide here.
    1.2 Navigate to your project’s root directory and run pod init to create a Podfile.
    1.3 Open up the Podfile and add MidtransKit to your project’s target.

    1.4 Save the file and run pod install to install MidtransKit.
    1.5 Open .xcworkspace project.
  2. After installation of MidtransKit, we have to configure it with the clientKey, merchant server URL and server environment in the AppDelegate.swift.

    In the setClientKey method we need to pass three parameter( client key,environment,merchantServerURL). We will get the client-key after creating the merchant account. Please click here to create the merchant account.
    The second parameter is an environment which decides that the payment mode is live or testing. There are 4 environments in the Midtrans payment gateway.
    1. production: This server type should be used only when the product ready to be released.
    2.Sandbox: This server type should be used for testing.
    3. Staging: This server type should be used for testing.
    4. Unknown: Internal usage only.
    Third and the last parameter is merchantServerURL, which is used for the server URL that you have mentioned in the signup time on the merchant account.

    Important: We need to add -ObjC to the Xcode project. Navigate to your .xcodeproj file in Xcode, choose your app main target in Targets, and in the Build Settings tab, search for Other Linker Flags, double click and add -ObjC.

  3. Now we configure the payment method and generate a transaction.
    3.1 Merchant Server Implementation.
    Midtrans payment gateway needs a token which is help create the payment transaction and the Merchant Server is used to create the payment token.
    click here to download charge file and upload it in your server.
  4. 3.2 Get Token from charge API.

3.3 Now finally we handle the event from SDK.

Hope the above blog will help you in integrate Midtrans payment gateway in iOS using swift.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home