Malla.CardIO.Forms 1.0.0-beta

.NET Standard 2.0
This is a prerelease version of Malla.CardIO.Forms.
Install-Package Malla.CardIO.Forms -Version 1.0.0-beta
dotnet add package Malla.CardIO.Forms --version 1.0.0-beta
<PackageReference Include="Malla.CardIO.Forms" Version="1.0.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Malla.CardIO.Forms --version 1.0.0-beta
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Malla.CardIO.Forms, 1.0.0-beta"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

card.io logo

CardIO.Forms

PRs Welcome Maintenance licence

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.

card.io logo

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.

  1. Install the package available on Nuget on each platform-specifi project.
  2. Initialize the library on each platform in your platform-specific app project.

NuGet

  • NuGet
  • Build status
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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid monoandroid90
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios xamarinios10
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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 96 2/26/2022