Check Mobile App
Read now

PayU Money Payment Gateway Integration In Swift

Save

Hi guys, today we will learn about how to implement PayU Money Payment Gateway for an iOS application in Swift.

Before starting to code first we need to know what a payment gateway is

A payment gateway is an e-commerce system that helps support modern retail or other types of sales of products and services, over the Internet or at brick-and-mortar stores. Payment gateways authorize credit card payments in order to support point-of-sale systems.

Thus, it’s enough for us now. Let’s start by following the instructions below.

STEPS TO INTEGRATE

1.) Add Payu Money SDK to your Project

We can add it by following ways:

a.)  By Integrate Payu Money SDK using Cocoa Pods:

To integrate Payu Money into your Xcode project using CocoaPods, specify it as a target in your Podfile:

(i) Add the following lines to Podfile of your project:

(ii) Then, run the following command to install it:

 

b.) Manually include Payu Money framework in your project :

For manually include the Payu Money framework, you have to follow the given below steps:

(i) Add Payu Money SDK to your project from Github

(ii) Clone or download the framework from the Github.

(iii) Unzip the “PayUMoney-IOS-SDK-master.zip” file and open it.

(iv) Navigate to the “PlugNPlay” folder & drag the PlugNPlay.framework into your project

(v) In Xcode, add the PlugNPlay.framework in Link Binary With Libraries & Embedded Frameworks section.

 

2.) Import the SDK

After installation, you must import the SDK in your project by adding the following line to the files in which you want to use this framework.

3.) Set Payment Params

To start using the PayUmoney PnP SDK, you need you to initialize the SDK by providing details about the customer and the transaction. To initiate the payment, create an object of type ‘PUMTxnParam’ and set all the mandatory parameters as shown below:

You can handle success or error events when a payment is completed by  “PlugNPlay.presentPaymentViewController“.

4.) Calculate Server-Side Hash

The only server-side change required while integrating the PayU Money SDK is to generate a hash parameter for both the payment request & response.

A hash is an encrypted value (checksum) that is to be sent by the merchant in a payment request and sent by PayU Money in the payment response. A hash is used to protect transactions against “man in the middle attack”.

The SHA512 hash implements the HashFunction protocol for the specific case of SHA-2 hashing with a 512-bit digest (SHA512Digest). Larger digests take more space but are more secure.

Note: The entire hash logic is built on the assumption ‘Salt’ is always safe with the merchant. Hence is very important for the merchant to keep the ‘Salt’ safe by adhering to the best security practices. For eg: Merchant should always compute from the server-side and never from the client-side, should never share the ‘Salt & Key’ over emails or directly commit to public repositories like Github.

5.)  Insert the following XML Source Code Snippet Into the Body of Your Info.Plist File Just Before the Final

 

Conclusion

 

So please follow the above step and if you have any issue or suggestion you can leave your query/suggestion in the comment section I will try to solve that.

. . .

Leave a Comment

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


2 comments

  • Dilip Tiwari
    Hii can u help me bro
    • Vishal Verma (Moderator)
      Please let us know how can I help you?
  • css.php

    Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

    Deniel Kerr

    Owner and Founder. Opencart

    Talk to Sales
    Start a Project

      Message Sent!

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

      Back to Home