Coder Social home page Coder Social logo

papara-ios's Introduction

Papara iOS SDK

CI Status Version License Platform

You can sign up for a Papara account at http://www.papara.com.

Requirements

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 5+

Example

You need to have Papara Sandbox iOS App to try Example

  1. Install Papara Sandbox iOS App from Testflight
  2. Change Example App Bundle Identifier to your real app bundle identifier
  3. Change Example App PaparaAppId from config to your Papara App Id
  4. Run Example App in a device which have Papara Sandbox iOS App pre installed.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

Swift 5

To integrate Papara into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'Papara', '~> 5.0'
end

Then, run the following command:

$ pod install

App Id

You need to get app id for your application Papara

Usage

Configuration

  • PaparaAppID Will be provided by Papara
  • PaparaSandbox true if you want to test in sandbox environment
  • LSApplicationQueriesSchemes Remove papara-sandbox in production release
  • CFBundleURLTypes For handling returns from Papara App. Should be papara{PaparaAppID}. For example if your AppId is 87826504 so CFBundleURLTypes will be papara87826504

In Xcode, secondary-click your project's .plist file and select Open As -> Source Code.

Insert the following XML snippet into the body of your file just before the final element.

If you already have same keys you need to merge them

<dict>
	...
	<key>PaparaAppID</key>
	<string>87826504</string>
	<key>PaparaSandbox</key>
	<true/>
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>papara</string>
		<string>papara-sandbox</string>
	</array>
	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>papara87826504</string>
			</array>
		</dict>
	</array>
</dict

Initialize

AppDelegate.swift

import Papara

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
	...
    Papara.application(application, didFinishLaunchingWithOptions: launchOptions)
    ...
    return true
}

Handlers

Papara returns true if link is handled by sdk

AppDelegate.swift

import Papara

func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
    let handled = Papara.application(application, handleOpen: url)
    // Add any custom logic here.
    return handled
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
    let handled = Papara.application(app, open: url, options: options)
    // Add any custom logic here.
    return handled
}

Papara Account Number

UIViewController.swift

import Papara

Papara.getPaparaNumber(self) { (result) in
    switch result {
    case .success(let paparaNumber):
        self.showAlertDialog("Success", message: String(paparaNumber))
    case .fail(let error):
        self.showAlertDialog("Error", message: error.localizedDescription)
    case .cancel:
        self.showAlertDialog("Cancel", message: "Cancel")
    }
}

Papara Send Money

Send to Papara Number

UIViewController.swift

import Papara

Papara.sendMoney(self, to: .paparaNumber(Int64(wallet)!), amount: amount!) { (result) in
    switch result {
    case .success:
        self.showAlertDialog("Success", message: "Success")
    case .fail(let error):
        self.showAlertDialog("Fail", message: error.localizedDescription)
    case .cancel:
        self.showAlertDialog("Cancel", message: "Cancel")
    }
}

Send to Mobile Phone

UIViewController.swift

import Papara

Papara.sendMoney(self, to: .mobile(wallet), amount: amount!) { (result) in
    switch result {
    case .success:
        self.showAlertDialog("Success", message: "Success")
    case .fail(let error):
        self.showAlertDialog("Fail", message: error.localizedDescription)
    case .cancel:
        self.showAlertDialog("Cancel", message: "Cancel")
    }
}

Send to Email Address

UIViewController.swift

import Papara

Papara.sendMoney(self, to: .email(wallet), amount: amount!) { (result) in
    switch result {
    case .success:
        self.showAlertDialog("Success", message: "Success")
    case .fail(let error):
        self.showAlertDialog("Fail", message: error.localizedDescription)
    case .cancel:
        self.showAlertDialog("Cancel", message: "Cancel")
    }
}

Papara Pay

  • Firstly, you need to create a payment using backend.
  • SDK needs paymentId, paymentUrl and redirectUrl from backend.
UIViewController.swift

import Papara

Papara.pay(self, paymentId: payment.id, paymentUrl: payment.paymentUrl, redirectUrl: payment.redirectUrl) { (result) in
    switch result {
    case .success(let paymentId, let referenceId, let status, let amount):
        self.showAlertDialog("Success", message: "Success")
    case .fail(let error):
        self.showAlertDialog("Error", message: error.localizedDescription)
    case .cancel:
        self.showAlertDialog("Cancel", message: "Cancel")
    }
}

License

Papara is available under the MIT license. See the LICENSE file for more info.

papara-ios's People

Contributors

aslanmehmetsalih avatar utkuyildirim avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.