Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,11 @@ interface ApplePayButtonProps {
| "rent"
| "support"
| "contribute"
| "tip";
| "tip"
| "plain" // Apple Pay mark only, for narrow layouts
| "checkout"
| "subscribe"
| "inStore";

buttonStyle: "white" | "whiteOutline" | "black";

Expand Down
4 changes: 3 additions & 1 deletion docs/docs/api/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Renders the system Apple Pay button. Only available on iOS.
| `style` | `ViewStyle` | No | Layout/style (e.g. width, height). |

**ApplePayButtonType:**
`'buy'` | `'setUp'` | `'book'` | `'donate'` | `'continue'` | `'reload'` | `'addMoney'` | `'topUp'` | `'order'` | `'rent'` | `'support'` | `'contribute'` | `'tip'`
`'buy'` | `'setUp'` | `'book'` | `'donate'` | `'continue'` | `'reload'` | `'addMoney'` | `'topUp'` | `'order'` | `'rent'` | `'support'` | `'contribute'` | `'tip'` | `'plain'` | `'checkout'` | `'subscribe'` | `'inStore'`

`'plain'` shows only the Apple Pay mark, for narrow layouts. `'inStore'` reads "Pay with Apple Pay".

**ApplePayButtonStyle:**
`'white'` | `'whiteOutline'` | `'black'`
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The payment fails with `code: 'CONFIGURATION'` and `Unknown merchant capability

Use only supported Apple button values:

- `buttonType`: `'buy' | 'setUp' | 'book' | 'donate' | 'continue' | 'reload' | 'addMoney' | 'topUp' | 'order' | 'rent' | 'support' | 'contribute' | 'tip'`
- `buttonType`: `'buy' | 'setUp' | 'book' | 'donate' | 'continue' | 'reload' | 'addMoney' | 'topUp' | 'order' | 'rent' | 'support' | 'contribute' | 'tip' | 'plain' | 'checkout' | 'subscribe' | 'inStore'`
- `buttonStyle`: `'white' | 'whiteOutline' | 'black'`

## Android (Google Pay)
Expand Down
4 changes: 4 additions & 0 deletions package/ios/ApplePayButtonFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ enum ApplePayButtonFactory {
case .support: return .support
case .contribute: return .contribute
case .tip: return .tip
case .plain: return .plain
case .checkout: return .checkout
case .subscribe: return .subscribe
case .instore: return .inStore
}
}

Expand Down
39 changes: 39 additions & 0 deletions package/ios/Tests/ApplePayButtonFactoryTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import PassKit
import XCTest
@testable import NitroPay

final class ApplePayButtonFactoryTests: XCTestCase {

func testMapsEveryButtonTypeToPassKit() {
let expected: [(ApplePayButtonType, PKPaymentButtonType)] = [
(.plain, .plain),
(.buy, .buy),
(.setup, .setUp),
(.instore, .inStore),
(.donate, .donate),
(.checkout, .checkout),
(.book, .book),
(.subscribe, .subscribe),
(.reload, .reload),
(.addmoney, .addMoney),
(.topup, .topUp),
(.order, .order),
(.rent, .rent),
(.support, .support),
(.contribute, .contribute),
(.tip, .tip),
(.continue, .continue),
]

for (type, pkType) in expected {
XCTAssertEqual(ApplePayButtonFactory.mapButtonType(type), pkType, "\(type.stringValue)")
}
}

func testReadsTheNewTypesFromJavaScriptNames() {
XCTAssertEqual(ApplePayButtonType(fromString: "plain"), .plain)
XCTAssertEqual(ApplePayButtonType(fromString: "checkout"), .checkout)
XCTAssertEqual(ApplePayButtonType(fromString: "subscribe"), .subscribe)
XCTAssertEqual(ApplePayButtonType(fromString: "inStore"), .instore)
}
}
12 changes: 6 additions & 6 deletions package/nitrogen/generated/android/c++/JGooglePayButtonType.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package/nitrogen/generated/ios/swift/ApplePayButtonType.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package/nitrogen/generated/shared/c++/ApplePayButtonType.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package/src/specs/ApplePayButton.nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export type ApplePayButtonType =
| 'support'
| 'contribute'
| 'tip'
| 'plain'
| 'checkout'
| 'subscribe'
| 'inStore'
export type ApplePayButtonStyle = 'white' | 'whiteOutline' | 'black'

export interface ApplePayButtonProps extends HybridViewProps {
Expand Down
Loading