iPaymentButton

Quickly implement the Apple Pay button in SwiftUI

22
3
Swift

iPaymentButton 💵

Quickly implement & easily customize the Apple Pay button. 🤑

Get Started | Examples | Customize | Install |

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😀