Skip to content

Commit defc490

Browse files
add crypto payment method to payment sheet
1 parent 8d31fdb commit defc490

19 files changed

+934
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
### CardScan
33
* [Fixed] Fixed an issue where the UI layout was incorrect after Camera permissions were denied. ([#4487](https://github.com/stripe/stripe-ios/pull/4487)) (Thanks [@matheusbc](https://github.com/matheusbc)!)
44

5+
### PaymentSheet
6+
* [Added] Support for Crypto in PaymentSheet
7+
58
## 24.4.1 2025-01-21
69
### ApplePay
710
* [Added] Added a `dismiss` method to `STPApplePayContext`.

Example/PaymentSheet Example/PaymentSheetUITest/PaymentSheetLPMUITest.swift

+16
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@ class PaymentSheetStandardLPMUIOneTests: PaymentSheetStandardLPMUICase {
207207
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 15.0))
208208
}
209209

210+
func testCryptoPaymentMethod() throws {
211+
var settings = PaymentSheetTestPlaygroundSettings.defaultValues()
212+
settings.currency = .usd
213+
settings.merchantCountryCode = .US
214+
loadPlayground(app, settings)
215+
app.buttons["Present PaymentSheet"].tap()
216+
217+
// Select Crypto
218+
tapPaymentMethod("Crypto")
219+
220+
// Pay
221+
app.buttons["Pay $50.99"].waitForExistenceAndTap()
222+
webviewAuthorizePaymentButton.waitForExistenceAndTap(timeout: 10)
223+
XCTAssertTrue(app.staticTexts["Success!"].waitForExistence(timeout: 15.0))
224+
}
225+
210226
func testZipPaymentMethod() throws {
211227
var settings = PaymentSheetTestPlaygroundSettings.defaultValues()
212228
settings.layout = .horizontal

StripePaymentSheet/StripePaymentSheet/Resources/JSON/form_specs.json

+28-1
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,34 @@
877877
}
878878
}
879879
}
880-
},
880+
},
881+
{
882+
"type": "crypto",
883+
"async": false,
884+
"selector_icon": {
885+
"light_theme_png": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/[email protected]",
886+
"light_theme_svg": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/icon-pm-crypto-15fd4ffeafd1b13e40688c8a06d79ba4.svg",
887+
"dark_theme_png": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/[email protected]",
888+
"dark_theme_svg": "https://js.stripe.com/v3/fingerprinted/img/payment-methods/icon-pm-crypto_dark-f19bb5c5400c6cde94dd53b7f1ce7217.svg"
889+
},
890+
"fields": [
891+
],
892+
"next_action_spec": {
893+
"confirm_response_status_specs": {
894+
"requires_action": {
895+
"type": "redirect_to_url"
896+
}
897+
},
898+
"post_confirm_handling_pi_status_specs": {
899+
"succeeded": {
900+
"type": "finished"
901+
},
902+
"requires_action": {
903+
"type": "canceled"
904+
}
905+
}
906+
}
907+
},
881908
{
882909
"type": "mobilepay",
883910
"async": false,

StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentMethodType.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ extension PaymentSheet {
317317
return []
318318
case .alipay, .EPS, .FPX, .giropay, .grabPay, .netBanking, .payPal, .przelewy24, .klarna,
319319
.bancontact, .iDEAL, .cashApp, .affirm, .zip, .revolutPay, .amazonPay, .alma,
320-
.mobilePay, .swish, .twint, .sunbit, .billie, .satispay:
320+
.mobilePay, .swish, .twint, .sunbit, .billie, .satispay, .crypto:
321321
return [.returnURL]
322322
case .USBankAccount:
323323
return [
@@ -330,7 +330,7 @@ extension PaymentSheet {
330330
return [.returnURL, .userSupportsDelayedPaymentMethods]
331331
case .afterpayClearpay:
332332
return [.returnURL, .shippingAddress]
333-
case .link, .unknown, .crypto:
333+
case .link, .unknown:
334334
return [.unsupported]
335335
@unknown default:
336336
return [.unsupported]

StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet+PaymentMethodAvailability.swift

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extension PaymentSheet {
3535
.sunbit,
3636
.billie,
3737
.satispay,
38+
.crypto,
3839
.boleto,
3940
.swish,
4041
.twint,

StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/PaymentSheetLPMConfirmFlowTests.swift

+10
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ final class PaymentSheet_LPM_ConfirmFlowTests: STPNetworkStubbingTestCase {
227227
}
228228
}
229229

230+
func testCryptoConfirmFlows() async throws {
231+
try await _testConfirm(intentKinds: [.paymentIntent],
232+
currency: "USD",
233+
paymentMethodType: .crypto,
234+
merchantCountry: .US) { form in
235+
// Crypto has no input fields
236+
XCTAssertEqual(form.getAllUnwrappedSubElements().count, 1)
237+
}
238+
}
239+
230240
func testAlipayConfirmFlows() async throws {
231241
try await _testConfirm(intentKinds: [.paymentIntent],
232242
currency: "USD",

StripePayments/StripePaymentsTestUtils/Resources/recorded_network_traffic/PaymentSheetLPMConfirmFlowTests/testCryptoConfirmFlows/0000_post_create_payment_intent.tail

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

StripePayments/StripePaymentsTestUtils/Resources/recorded_network_traffic/PaymentSheetLPMConfirmFlowTests/testCryptoConfirmFlows/0001_get_v1_payment_intents_pi_3QNinPFY0qyl6XeW1C6tfI7s.tail

+65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

StripePayments/StripePaymentsTestUtils/Resources/recorded_network_traffic/PaymentSheetLPMConfirmFlowTests/testCryptoConfirmFlows/0002_post_v1_payment_intents_pi_3QNinPFY0qyl6XeW1C6tfI7s_confirm.tail

+99
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

StripePayments/StripePaymentsTestUtils/Resources/recorded_network_traffic/PaymentSheetLPMConfirmFlowTests/testCryptoConfirmFlows/0003_get_v1_payment_intents_pi_3QNinPFY0qyl6XeW1C6tfI7s.tail

+95
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)