Skip to content

Quickly implement the Apple Pay button in SwiftUI

Notifications You must be signed in to change notification settings

efarrar-forks/iPaymentButton

 
 

Repository files navigation

iPaymentButton 💵

Quickly implement & easily customize the Apple Pay button. 🤑

Get Started | Examples | Customize | Install | Usage

CI


Get Started

  1. Install iPages

  2. Add iPaymentButton to your project

import SwiftUI
import iPaymentButton

struct ContentView: View {
    var body: some View {
        iPaymentButton(action: {
            // Add your custom payment code here 
        })
    }
}
  1. Customize your iPages

Examples

Starter

Use our built-in applePayDemo() to demo a purchase experience.

import SwiftUI
import iPaymentButton
import iGraphics

struct ContentView: View {
    var body: some View {
        iGraphicsBox().stack(3)

        iPaymentButton(action: {
            iPaymentButton.applePayDemo()
            // Add your custom payment code here 
        })
    }
}

Modern

Change the button type and style.
import SwiftUI
import iPaymentButton
import iGraphics

struct ContentView: View {
    var body: some View {
        iGraphicsView(.first)

        iPaymentButton(type: .support, style: .whiteOutline, action: {
            iPaymentButton.applePayDemo()
            // Add your custom payment code here 
        })
    }
}

Customize

iPaymentButton has one required parameter: an action to execute on button tap. iPaymentButton supports several custom initializers and one custom modifier.

Example: Change the text, style and corner radius with the following code block:

iPaymentButton(type: .support, style: .whiteOutline, action: { } )
    .cornerRadius(25)

Use our exhaustive input list to customize your views.

Modifier or Initializer Description
type: PKPaymentButtonType = .buy The text written on the button. 🆒
type: PKPaymentButtonStyle = .black The color that the button should be. 🎨
action: @escaping () -> Void The action to be performed when the user taps the button. 🎬▶️
.cornerRadius(radius: CGFloat) -> iPaymentButton Modifies the corner radius of the payment button ⬛️⚫️. To remove the rounded courners, set this value to 0.0 0️⃣👌. The default value is set to 4.0 🍀.

Install

Use the Swift package manager to install. Find instructions here😀

Usage

iPaymentButton is FREE and open-source for individuals, and will remain that way forever.

iPaymentButton is distributed under a GNU GPL open-source license.

Commercial users, please note, this license is often incompatible for many commercial applications. If your app is distributed for commercial use, it could violate this open-source license even "if the application is free in the App Store".

In order to offer iPaymentButton safely to our commercial friends we made it super easy to purchase a lifetime, full-use license for $0.99. Code on worry free 😁

About

Quickly implement the Apple Pay button in SwiftUI

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Swift 100.0%