G1.Stripe.Maui | |
G1.Stripe.Android.Bindings | |
G1.Stripe.iOS.Bindings |
A .NET MAUI library providing Stripe payment integration for cross-platform mobile applications.
Maintaining this on our own isn’t feasible, so we’re turning it into a community-driven project. Right now it provides a minimal, working iOS API, but we need contributors to flesh it out and improve its reliability. We’ve seen many developers struggle with these same issues, so we’re making everything public in hopes that the community can help build a robust, well-documented solution together.
This library uses the following Stripe SDK versions for each platform:
- Stripe Android SDK:
21.18.0
- Stripe iOS SDK:
24.16.1
You can face issue with long paths, similar to that:
Could not find a part of the path 'c:\packages\g1.stripe.ios.bindings\0.0.3-beta\lib\net9.0-ios18.0\G1.Stripe.iOS.Bindings.resources\Stripe.Swift.Proxy.xcframework\ios-arm64_x86_64-simulator\Stripe_Swift_Proxy.framework\Modules\Stripe_Swift_Proxy.swiftmodule\arm64-apple-ios-simulator.private.swiftinterface'.
to handle that need to enable long paths support and install package via CLI
dotnet add package G1.Stripe.Maui --prerelease
In your MAUI project’s MauiProgram.cs
, wire up the Payment Sheet under the G1.Stripe.Maui
namespace:
using G1.Stripe.Maui;
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseStripePaymentSheet();
return builder.Build();
}
Initialize with your Stripe publishable key:
var paymentSheet = App.Current.Services.GetRequiredService<IPaymentSheet>();
paymentSheet.Initialize("pk_test_XXXXXXXXXXXXXXXXXXXXXXXX");
Build your options and open the sheet:
var options = new PaymentSheetOptions
{
ClientSecret = paymentIntentClientSecret,
MerchantDisplayName = "My Store, Inc.",
// Optional :
Customer = new PaymentSheetCustomerOptions(ephemeralKey, customerId),
AllowsDelayedPaymentMethods = true,
BillingDetails = new Options.PaymentSheetBillingDetailsCollectionOptions
{
Name = Options.BillingDetailsCollectionMode.Always,
Phone = Options.BillingDetailsCollectionMode.Always,
Email = Options.BillingDetailsCollectionMode.Always,
Address = Options.AddressCollectionMode.Full,
AttachDefaultsToPaymentMethod = false
},
#if IOS
ApplePayConfiguration = new TSPSApplePayConfiguration("your.merchant.id", "us", PassKit.PKPaymentButtonType.Checkout, null, null)
#elif ANDROID
GooglePay = new Com.Stripe.Android.Paymentsheet.PaymentSheet.GooglePayConfiguration(Com.Stripe.Android.Paymentsheet.PaymentSheet.GooglePayConfiguration.Environment.Test!, "us")
#endif
};
var result = await paymentSheet.Open(options, cancellationToken);
switch (result)
{
case PaymentSheetResult.Completed:
// Payment successful
break;
case PaymentSheetResult.Canceled:
// User canceled the sheet
break;
case PaymentSheetResult.Failed failure:
// An error occurred
break;
}
If it doesn’t fit your needs:
Register AndroidPaymentSheet
and iOSPaymentSheet
. Make sure you call
AndroidPaymentSheet.CaptureActivity(..)
— Stripe requires an activity that is not yet started.
Reference G1.Stripe.Android.Bindings
and G1.Stripe.iOS.Bindings
and consume the API from there.
Android provides almost all APIs from Stripe.
For iOS, we have a very small set of APIs since Stripe doesn’t expose them via Objective-C (-objc
). We need to wrap the necessary methods and then expose them to enable interop. I need help to expose more APIs. Details here: stripe/stripe-ios#3377