Intermediate: Creating QR code for payment using Huawei Scan Kit in Xamarin(Android)
Huawei Scan Kit has an ability to scan and parse all barcodes and QR Codes. It can also generate barcodes and QR codes. Its success rate is very high as it can detect barcodes and QR codes in dim light or even it is looking blurry.
This application generates QR code for Debit/Credit card information and the same QR code can be used while making a payment in any other application. Users need to scan the QR code on payment screen from Gallery and it will set the card details in proper fields. This application will reduce the effort of filling the card details while making a payment.
Let us start with the project configuration part:
Step 1: Create an app on App Gallery Connect.
Step 2: Create Android Binding Library for Xamarin Project.
Step 3: Collect all .dll files and save it in your system.
Step 4: Create new Xamarin(Android) project.
Step 5: Change your app package name same as AppGallery app’s package name.
a) Right click on your app in Solution Explorer and select properties.
b) Select Android Manifest on left side menu.
c) Change your Package name as shown in below image.
Step 6: Generate SHA 256 key.
a) Select Build Type as Release.
b) Right-click on your app in Solution Explorer and select Archive.
c) If Archive is successful, click on Distribute button as shown in below image.
d) Select Ad Hoc.
e) Click Add Icon.
f) Enter the details in Create Android Keystore and click on Create button.
g) Double click on your created keystore and you will get your SHA 256 key and save it.
f) Add the SHA 256 key to App Gallery.
Step 7: Add all .dll files to References > Add Reference > Browse.
Step 8: Add Read/Write external storage permission to manifest.
Step 9: Now click Build Solution in Build menu.
Let us start with the implementation part:
Step 1: Add runtime permission (Read/Write external storage) to the project. Add the below code in MainActivity.java.
Step 2: Get the form data and generate QR Code.
Step 3: Save the QR code to Gallery.
Step 4: Scan the QR Code from gallery while making the payment from Credit/Debit card.
Now implementation part done.
Tips and Tricks
Please add runtime external store Read/Write permissions.
This application help users to make payment easily. So no need to type the card details while making a payment. During payment, Scan the QR Code from gallery and it will fill all the details automatically.