Simple cross platform plugin that uses Pay.Cards library to scan credit card information.
- Available on NuGet: http://www.nuget.org/packages/Plugin.PayCards
- Install into your .NETStandard project and Client projects.
Platform Support
Platform | Version |
---|---|
Xamarin.iOS | iOS 12+ |
Xamarin.Android | API 9+ |
Call CrossPayCards.Current from any project to gain access to APIs.
After installing the package in your shared, iOS and Android projects you should do the following setup on each platform:
Call PayCardsRecognizerService.Initialize in MainActivity OnCreate method
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
PayCardsRecognizerService.Initialize(this);
LoadApplication(new App());
}
Override MainActivity OnActivityResult and call PayCardsRecognizerService.OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
PayCardsRecognizerService.OnActivityResult(requestCode, resultCode, data);
}
Add Camera Permission in Info.plist
<key>NSCameraUsageDescription</key>
<string>This application needs camera access</string>
Now you are ready to to scan credit cards!
var cardInfo = await CrossPayCards.Current.ScanAsync();
System.Debug.WriteLine("Result", $"{card.HolderName}\n{card.CardNumber}\n{card.ExpirationDate}","Ok");