blsage / iPaymentButton

Quickly implement the Apple Pay button in SwiftUI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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πŸ˜€

About

Quickly implement the Apple Pay button in SwiftUI


Languages

Language:Swift 100.0%