CocoaPods trunk is moving to be read-only. Read more on the blog, there are 8 months to go.

PPGAppKit 0.0.34

PPGAppKit 0.0.34

Maintained by Srinivas Prabhu.



PPGAppKit 0.0.34

  • By
  • PayPro Global, Inc

Introduction

PayPro Global Inc offers the best shopping experience through a complex payment processing system which delivers secure transactions, versatility (multiple options to satisfy all customer preferences), user friendly experience (localized content, payment methods and currencies) and the highest degree of transaction fulfillment.

PPGAppKit is PayPro Global's SDK which enables quick integration of our shopping experience in a Mac App.

This SDK is a thin layer over Webview which enables integration of PayProGlobal e-commerce solution in Mac App.

To get an idea of how it works, the SDK provides a Swift and Objective-C examples. All source code is released under the MIT license. It is open to contributions and its use is unrestricted.

PPGAppKit

PPGAppKit consists of two primary components PayProWebView and Configuration.

The PayProWebView provides functionality to load the e-commerce solution of PayPro Global. PayProWebView is initialized with Configuration object and embedded within the Mac App. This document provides details about how to construct a URL which is provided to Configuration object. Once order has been submitted and thank you page is loaded you get PayProGlobal Order Id, status and the invoice link through WebView's HTTP Response headers.

Requirements

  • Xcode 11.x

  • Swift 5.x

  • Objective-C 2.0

Installation

CocoaPods

# Podfile 

use_frameworks! 

  

target 'YOUR_TARGET_NAME' do 

    pod 'PPGAppKit' 

end 

  

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

$ pod install 

If you don't have CocoaPods installed, it can be install using following command:

$ sudo gem install cocoapods 

Swift Package Manager

To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL https://github.com/paypro-global/MacOsWebViewSDK.git

How-to use PPGAppKit in Swift

  1. Read our URL Parameters guide to learn how about URL parameters.

  2. Create Configuration object using the URL parameters explained in Step 1.

  3. Create PayProGlobal initialized with Configuration object.

  4. Observe didFail/didStartPaymentViewLoad/didFinishPaymentViewLoad to track progress of URL Load.

  5. Observe didCompletedOrder, it is called along with order info on order completion.

  6. Observe urlCredential method to handle Authentication Challenge.

  7. Access paymentView object in PayProGlobal and add it as a sub view on any NSWindow.

Example located in Example/Swift folder show how to create PayProGlobal and use it in detail.

Use Swift Package or CocoaPods as explained in Installation Section.

If you have used SwiftPackage, Open PayProGlobalStore.xcodeproj, build and run.

If you have used CocoaPods, Open PayProGlobalStore.xcworkspace, build and run.

Example

    private lazy var payproGlobal: PayProGlobal = { 

       let configuration = Configuration(url: "https://store.payproglobal.com/checkout?products[1][id]=59421&use-test-mode=true&secret-key=gEcP!-xp9M") 

       return PPGAppKit.create(configuration: configuration) 

    }() 

            

    private func load(){ 

       let paymentView = payproGlobal.paymentView 



       payproGlobal.didFail = { (error) in 

           print("Did Fail \(error)") 

       } 

        

       payproGlobal.didStartPaymentViewLoad = { 

           print("didStartPaymentViewLoad ") 

       } 

        

       payproGlobal.didFinishPaymentViewLoad = { 

           print("didFinishPaymentViewLoad ") 

       } 
       
       
       
       payproGlobal.didCompletedOrder = { (orderInfo) in
           print("did complete Order \(orderInfo)")
       }



       payproGlobal.urlCredential = { [weak self] (crediential) in 

           self?.showAuthenticationUI(with: crediential) 

       } 

        

       paymentView.translatesAutoresizingMaskIntoConstraints = false 

       container.addConstraints(paymentViewConstraints) 

       container.addSubview(paymentView) 

    } 

How-to use PPGAppKit in Objective-C

  1. Read our URL Parameters guide to learn how about URL parameters.

  2. Create Configuration object using

  3. Create PayProGlobal initialized with Configuration object. Examples located in Example/Swift and Example/Objective-C are showing how to create PayProGlobal and use it in detail.

  4. Observe didFail/didStartPaymentViewLoad/didFinishPaymentViewLoad to track progress of URL Load.

  5. Observe didCompletedOrder, it is called along with order info on order completion.

  6. Observe urlCredential method to handle Authentication Challenge.

  7. Access paymentView object in PayProGlobal and add it as a sub view on any NSWindow.

Example located in Example/Objectice-C folder show how to create PayProGlobal and use it in detail.

Run following command to create a XcodeWorkspace using CocoaPods:

$ cd [../Example/Objective-C] 

$ pod install 

If you don't have CocoaPods installed, it can be install using following command:

$ sudo gem install cocoapods 

Open PayProGlobalStore.xcworkspace , build and run it.

Example

Configuration *configuration = [[Configuration alloc] initWithUrl:@"https://store.payproglobal.com/checkout?products[1][id]=59421&use-test-mode=true&secret-key=gEcP!-xp9M"]; 

self.payproGlobal = [PPGAppKit createWithConfiguration:configuration]; 



self.payproGlobal.didStartPaymentViewLoad = ^(){ 

   NSLog(@"Did start"); 

}; 



self.payproGlobal.didFinishPaymentViewLoad = ^(){ 

   NSLog(@"Did Finish"); 

}; 

self.payproGlobal.didCompletedOrder = ^(NSDictionary<NSString *,id> * orderInfo){ 

   NSLog(@"did Complete Order %@",orderInfo);

}; 


self.payproGlobal.didFail  = ^(NSError * error) { 

   NSLog(@"Did Fail"); 

}; 


__weak ViewController *weakSelf = self; 



self.payproGlobal.urlCredential = ^(void (^ callback)(NSURLCredential * _Nullable)) { 

   [weakSelf showAlert:callback]; 

}; 



NSView *paymentView = [self.payproGlobal paymentView]; 

[paymentView setTranslatesAutoresizingMaskIntoConstraints:false]; 

[self.container addSubview:paymentView]; 

Sandbox Settings

If your app is sandboxed you should do following in Signing & Capabilities tab:

  1. Enable Outgoing Connections (Client) to allow the framework to send data to PayPro Global.

  2. Enable Printing to allow the framework to print invoice.

  3. Framework supports Saving of invoice feature by providing Read/Write access to User Selected File.

Sandbox Settings