Skip to content

Latest commit

 

History

History
91 lines (64 loc) · 3.8 KB

README.md

File metadata and controls

91 lines (64 loc) · 3.8 KB

PirateChainPaymentURISwift

Build Status Carthage Compatible

PirateChainPaymentURISwift is an open source library to handle the pirate chain payment URI based on the BIT 21. The purpose of this library is to provide a simpler way to the developers to integrate in their applications support for this URI Scheme to easily make payments.

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate PirateChainPaymentURI into your Xcode project using Carthage, specify it in your Cartfile:

github "Meshbits/PirateChainPaymentURISwift" "piratechain"

Run carthage update to build the framework and drag the built PirateChainPaymentURI.framework into your Xcode project.

Or In your project -> Targets -> Build Phases -> Link Binary with Libraries -> Import -> PirateChainPaymentURI.framework

In your project -> Targets -> Frameworks, Libraries and Embedded Content -> PirateChainPaymentURI.framework -> Update it to Embed & Sign

Usage

Code

Parse the URI arrr:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=50&label=Luke-Jr&message=Donation%20for%20project%20xyz.

   guard let pirateChainPaymentURI = PirateChainPaymentURI.parse("arrr:175kjasjtWpb8K1S7NmH4Zx6rewF9WQrcZv245Wsknjadnsadnk?message=Bought%20pizza&amount=0.67&label=Mr.ET") else {
            return
        }

        print(pirateChainPaymentURI.address)
        print(pirateChainPaymentURI.amount)
        print(pirateChainPaymentURI.label)
        print(pirateChainPaymentURI.message)

In case you want to open the deep link to our Pirate Chain Wallet:

https://github.com/Meshbits/pirate-chain-ios-wallet

Parse the URI arrr://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=50&label=Luke-Jr&message=Donation%20for%20project%20xyz.

   guard let pirateChainPaymentURI = PirateChainPaymentURI.parse("arrr://175kjasjtWpb8K1S7NmH4Zx6rewF9WQrcZv245Wsknjadnsadnk?message=Bought%20pizza&amount=0.67&label=Mr.ET") else {
            return
        }

        print(pirateChainPaymentURI.address)
        print(pirateChainPaymentURI.amount)
        print(pirateChainPaymentURI.label)
        print(pirateChainPaymentURI.message)

Generatig the following DeepLink URI which will directly open a pirate chain wallet arrr://175kjasjtWpb8K1S7NmH4Zx6rewF9WQrcZv245Wsknjadnsadnk?message=Bought%20pizza&amount=0.67&label=Mr.ET

     let pirateChainPaymentURI: PirateChainPaymentURI = PirateChainPaymentURI.init(build: {
                    $0.address = "175kjasjtWpb8K1S7NmH4Zx6rewF9WQrcZv245Wsknjadnsadnk"
                    $0.amount = 0.67
                    $0.label = "Mr.ET"
                    $0.message = "Bought pizza"
                    $0.isDeepLink = true
                })

        print(pirateChainPaymentURI.uri)

Generatig the following URI arrr:175kjasjtWpb8K1S7NmH4Zx6rewF9WQrcZv245Wsknjadnsadnk?message=Bought%20pizza&amount=0.67&label=Mr.ET

     let pirateChainPaymentURI: PirateChainPaymentURI = PirateChainPaymentURI.init(build: {
                    $0.address = "175kjasjtWpb8K1S7NmH4Zx6rewF9WQrcZv245Wsknjadnsadnk"
                    $0.amount = 0.67
                    $0.label = "Mr.ET"
                    $0.message = "Bought pizza"
                    $0.isDeepLink = false 
                })

        print(pirateChainPaymentURI.uri)