Xamarin.Forms: Add Credit/Debit Card Reader to you App with PayPal.Forms

Xamarin.Forms: Add Credit/Debit Card Reader to you App with PayPal.Forms

Hello today I'll show how easily is to add a card scanner into your Xamarin.Forms(Android, iOS) app with only a few lines of code using the PayPal.Forms Library.

First at all we need to add PayPal.Forms to all of your projects(Android, iOS and PCL-Forms) by searching for "PayPal.Forms" in nuget packages manager or running next command on a nuget packages console "Install-Package PayPal.Forms"

Second on our Android app we need to add a few lines of code for permissions and features inside our "AndroidManifest.xml"

VERY IMPORTANT FOR IOS 10 IF YOU WANT TO USE THE CAMERA FEATURES

Add "NSCameraUsageDescription" into you Info.plist file.

<key>NSCameraUsageDescription</key>
<string>We will use your camera to scan the credit card</string>

After this now we're able to configure PayPal.Forms init calls inside our MainActivity.cs(Android) and AppDelegate.cs(iOS)

Call just CrossPayPalManager.Init(); just after call Forms.Init ();

***NOTE: if you plan to use only card scanner you can use init PayPal Config as follow***

If the configuration is getting fine now we can use the scan method CrossPayPalManager.Current.ScanCard();

-ScanCardResult-- Status (Successful, Cancelled, Error)-- Card:--- Scaned: Returns true if card was scanned or false if the card was input by hand by user--- RedactedCardNumber: Give you the card number with next format **** **** **** 1234.--- PostalCode: Give you the card postal code(if is requerid).--- ExpiryYear: Give you the card expiry year.--- ExpiryMonth: Give you the card expiry month.--- Cvv: Give you the card cvv.--- CardType (Unrecognized, Ambiguous, Amex, Jcb, Visa, Mastercard, Discover)--- CardNumber: Give you the card number.--- CardImage: Forms ImageSource with Scanned Card Image.
Hope that this can help you to create and awesome Forms app now i invite you to play with it and also remember that this lib also can help you to implement PayPal Mobile SDK Frameworks for more information and examples take a look to my PayPal.Forms repository on Github:

Xamarin.Forms: Custom Context Actions on iOS
Hello folks now is time to talk about customize context action views on Xamarin.Forms cell for iOS (yes the red/light-gray options that appear when you swipe a cell) the default colors are not a good-looking, so right now is a little bit tricky to achieve that but we will use a reflection technique to achieve the next two escenarios: Change background color for default and destructive context actionSet custom view for default and destructive context action
first at all, lets take a look to native impl. on Xamarin.Forms Github project on the next url https://github.com/xamarin/Xamarin.Forms/blob/ae92582d5acad2b8aeab9a2ed5b490561e71bd6c/Xamarin.Forms.Platform.iOS/ContextActionCell.cs#L14

Here we have two key items "DestructiveBackground" and "NormalBackground" both are the Images that Xamarin.Forms use to put as background on the default ContextActions view(Gray/Red)