I have implemented payment in my back-end using Stripe.net, Now I have a mobile client writen in Xamarin Which I want to approve credit card payments with. But All of the e
The approach depends a bit depending on your requirements. If you plan to accept only U.S and Canadian cards then the simplest approach would be to confirm the PaymentIntent server-side as described in this guide here:
https://stripe.com/docs/payments/without-card-authentication
The gist is that you collect the credit card information client-side (preferably by tokenizing the details using one of our client-libraries), then call the PaymentIntents API much like you would the Charges API:
var options = new PaymentIntentCreateOptions
{
Amount = 1099,
Currency = "usd",
PaymentMethodId = request.PaymentMethodId,
// A PaymentIntent can be confirmed some time after creation,
// but here we want to confirm (collect payment) immediately.
Confirm = true,
// If the payment requires any follow-up actions from the
// customer, like two-factor authentication, Stripe will error
// and you will need to prompt them for a new payment method.
ErrorOnRequiresAction = true,
};
paymentIntent = service.Create(options);
The key parameters here are:
Confirm
: needs to be set to true
so that the payment is processed right away.ErrorOnRequiresAction
: needs to be set to true
to prevent the payment from entering a state where it expects some form of authentication (e.g. 3D Secure)If SCA and global regulatory requirements are a concern. Then you will need to find a way to confirm the payment client-side so users can authenticate a payment if they need to. Right now, the available integration paths are unfortunately quite limited for hybrid mobile technologies like Cordova, React Native, and Xamarin. Generally speaking there are two paths you can take:
run Stripe.js in a WebView
This would allow you to use all the methods described here: https://stripe.com/docs/js, and follow our default integration path for accepting payments: https://stripe.com/docs/payments/accept-a-payment. For the Xamarin side of things a good place to start would be the official WebView example: https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/workingwithwebview/.
build a bridge to Stripe's native iOS and Android SDKs
This is a bit more complex than running Stripe.js in a WebView, but would likely be more performant and give a slightly more polished user experience. With this approach you would build a bridge into Stripe's Android and iOS SDKs using the approaches outlined here: https://devblogs.microsoft.com/xamarin/binding-ios-swift-libraries/ (iOS), https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/ (Android)