Malla.CardIO.Forms
1.0.0-beta
dotnet add package Malla.CardIO.Forms --version 1.0.0-beta
NuGet\Install-Package Malla.CardIO.Forms -Version 1.0.0-beta
<PackageReference Include="Malla.CardIO.Forms" Version="1.0.0-beta" />
paket add Malla.CardIO.Forms --version 1.0.0-beta
#r "nuget: Malla.CardIO.Forms, 1.0.0-beta"
// Install Malla.CardIO.Forms as a Cake Addin #addin nuget:?package=Malla.CardIO.Forms&version=1.0.0-beta&prerelease // Install Malla.CardIO.Forms as a Cake Tool #tool nuget:?package=Malla.CardIO.Forms&version=1.0.0-beta&prerelease
CardIO.Forms
CardIO.Forms is a library for Xamarin.Forms Android and iOS that can scan credit card details from the device's camera similar to a barcode scanner. CardIO.Form makes scanning and entering Credit Card information simple.
CardIO.Forms is an implementation of the old Xamarin Components CardIO binding native libraries for Android and iOS. Use with your own risk.
Features
- Live Camera Card Scanning - Quick and simple integration. Get up and running in 5 minutes.
- Optional Manual Entry - Users can choose to type their credit cards in. Card.io provides a slick interface for manual card entry.
- Secure - No credit card information is stored or transmitted.
- Free - SDK's are free for both Android and iOS.
Usage
var config = new CardIOConfig
{
Localization = "es",
ShowPaypalLogo = false,
RequireExpiry = true,
ScanExpiry = true,
RequireCvv = true,
UseCardIOLogo = true,
HideCardIOLogo = true,
SuppressManualEntry = true,
SuppressConfirmation = true,
};
var result = await CardIO.Instance.Scan(config);
Adding CardIO.Forms to your proyect
To get your project working some setup is needed.
- Install the package available on Nuget on each platform-specifi project.
- Initialize the library on each platform in your platform-specific app project.
NuGet
Platform Support
Platform | Version |
---|---|
.NET Standard | 2.0+ |
Xamarin.Forms | 4.4+ |
MonoAndroid | 9.0+ |
Xamarin.iOS | 1.0+ |
Android
You will need to add permissions that card.io requires to your AndroidManifest.xml
file.
<manifest ... >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />
</manifest>
Or you can add the following C# code to your project (can be in the AssemblyInfo.cs
file):
[assembly: UsesPermission(Android.Manifest.Permission.AccessNetworkState)]
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
[assembly: UsesPermission(Android.Manifest.Permission.Camera)]
[assembly: UsesPermission (Android.Manifest.Permission.Flashlight)]
[assembly: UsesPermission(Android.Manifest.Permission.Vibrate)]
You should also declare some of the features your app is using. Again you can do this directly in the manifest, or by adding this C# code to your project:
[assembly: UsesFeature("android.hardware.camera", Required = false)]
[assembly: UsesFeature("android.hardware.camera.autofocus", Required = false)]
[assembly: UsesFeature("android.hardware.camera.flash", Required = false)]
On your MainActivity
add initialization code:
...
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Malla.CardIO.Android.CardIO.Initialize(this);
LoadApplication(new App());
}
protected override void OnActivityResult(int requestCode, Android.App.Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
Malla.CardIO.Android.CardIO.ForwardActivityResult(requestCode, resultCode, data);
}
}
...
Release configuration (Android)
Before you build in release mode, make sure to adjust your proguard configuration by adding the following code to your proguard.cfg
file:
# Don't obfuscate DetectionInfo or public fields, since it is used by native methods
-keep class io.card.** { *; }
-keep class com.keepe.** { *; }
-keepclassmembers class io.card.** { *;}
# required to suppress errors when building on android 22
-dontwarn io.card.payment.CardIOActivity
Also if you are using the linker you need to add the following code to your linker.xml
file:
<linker>
<assembly fullname="Malla.CardIO">
<type fullname="*" />
</assembly>
</linker>
iOS
Just to prevent the linker from removing the assembly on your AppDelegate.cs
file add initialization code.
...
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
Malla.CardIO.iOS.CardIO.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
...
Starting in iOS 10, Apple requires that if your app wants to access the camera, your Info.plist
must specify the reason you wish to access it, which will be displayed to the user when they are prompted to allow or deny your app permission to use the camera.
This means your Info.plist file should contain a string item with a key of NSCameraUsageDescription
and a value containing a description of why you want to use the camera, to show the user.
Open the Info.plist
file as source code and add this:
<key>NSCameraUsageDescription</key>
<string>Camera usage description</string>
Learn More
Learn more about Card.io by visiting http://www.card.io
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. monoandroid90 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. xamarinios10 is compatible. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Xamarin.Forms (>= 4.4.0.991265)
-
MonoAndroid 9.0
- Xamarin.CardIO.Android (>= 5.5.1)
- Xamarin.Forms (>= 4.4.0.991265)
-
Xamarin.iOS 1.0
- Xamarin.CardIO.iOS (>= 5.4.1)
- Xamarin.Forms (>= 4.4.0.991265)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0-beta | 221 | 2/26/2022 |