UPI Deep Link - Unable to complete the transaction - android

Trying to connect the UPI payment using deeplink for my Android application, but every-time it fails at the last step.
The code fragment for the UPI payment call is below:
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
URI_URL = getUPIString("xxx#upi", "xxx xxx", "test_101", "Test Transaction", "10", "INR");
//Creating an intent for the UPI APP
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(URI_URL));
Intent chooser = Intent.createChooser(intent, "Pay the MSME by");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
startActivityForResult(chooser, 1, null);
}
}
});
To frame the UPI String using this function:
private String getUPIString(String payeeAddress, String payeeName, String trxnRefId,
String trxnNote, String payeeAmount, String currencyCode) {
String UPI = "upi://pay?pa=" + payeeAddress + "&pn=" + payeeName
+ "&tr=" + trxnRefId
+ "&tn=" + trxnNote + "&am=" + payeeAmount + "&cu=" + currencyCode;
return UPI.replace(" ", "+");
}
What could be the possible reasons of failure? Any suggestion or help is welcome.

The error is T04 meaning the refId should be alphanumeric with minlength 1 and maxlength 35. instead of test_101 use test101.

I have worked on UPI and integrate it into my Android project. I have also created a GitHub repository which can be useful for you.
Using deep linking, You will get mostly UPI supporting app but the problem is all app doesn't return value properly. I have tested Paytm, Google pay and freecharge and many more. But These app return value very well.
Due to this problem, I have created custom intent chooser so that exclude those apps who don't return value after payment. Along with this, you will get code of QR code to generate and scan UPI QR code.
Want to know more, here is a document.
Do check it and let me know, it helps you or not. Problem ask me.

Related

UPI deep linking from Ionic3 is not working on Android

I am using this:
options={ action:this.webIntent.ACTION_VIEW,
url:"upi://pay?pa=xxx#upi&pn=Name&tid=TID4587445785&tr=Product
Purchase&am=100&cu=INR&tn=Purchase&mc=< my mc code >" };
this.webIntent.startActivityForResult(options)
However, it's failing with these errors:
Google Pay Error limit exceed
paytm Error payee-mcc length invalid
Bhim Error Payee.code numeric of length 4
Could not figure out a solution. Any help is appreciated.
#rajib ,
Give Merchant code as only of 4 digit .. Thats the one that is causing issue
create your uri as below :
val paymentUri = Uri.Builder().apply {
with(payment) {
scheme("upi").authority("pay")
appendQueryParameter("pa", vpa)
appendQueryParameter("pn", name)
appendQueryParameter("tid", txnId)
appendQueryParameter("mc", merchantId)
appendQueryParameter("tr", txnRefId)
appendQueryParameter("tn", description)
appendQueryParameter("am", amount)
appendQueryParameter("cu", currency)
appendQueryParameter("mcc", payeeMerchantCode)
}
}.build()
// Set Data Intent
val paymentIntent = Intent(Intent.ACTION_VIEW).apply {
data = paymentUri
}
val appChooser = Intent.createChooser(paymentIntent, "Pay using")
if (paymentIntent.resolveActivity(packageManager) != null) {
startActivityForResult(appChooser, PAYMENT_REQUEST)
} else {
Toast.makeText(
this,
"No UPI app found! Please Install to Proceed!",
Toast.LENGTH_SHORT).show()
throwOnAppNotFound()
}
Here mc or merchantId has to be 4 digit and payeeMerchantCode you will get when your account on these psps

search in another application

I want to know can ı search youtube or another application on my application.
String s=" hi ";
Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/results?search_query=" + s));
startActivity(intent);
I can search using this code for youtube web site but I want to search in youtube android application (com.google.android.youtube ) . I will use below code for voice search .
if (resultCode == RESULT_OK && null != data) {
ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
mVoiceInputTv.setText(result.get(0));
String text =mVoiceInputTv.getText().toString();
String filename = text; // full file name
String[] parts = filename.split("\\ "); // String array, each element is text between spaces
String beforeFirstSpace = parts[0]; // Text before the first space
if(beforeFirstSpace.equalsIgnoreCase("Youtube")) {
Intent intent = new Intent(getPackageManager().getLaunchIntentForPackage("com.google.android.youtube"));
intent.setAction(Intent.ACTION_SEARCH);
intent.putExtra(SearchManager.QUERY,text);
startActivity(intent);
finish(); System.exit(0);
}
With this code I open the youtube application but I can't search in application.
You can't do it easily since other apps may (and most likely) offer another API that is different than youtube.
For example:
youtube search API:
https://www.youtube.com/results?search_query=facebook
facebook search API:
http://www.facebook.com/search/web/direct_search.php?q=%gmail
gmail search API:
Gmail: http://mail.google.com/mail/?search=query&view=tl&start=0&init=1&fs=1&q=%youtube
You see there is a different pattern. Thus, you need to implement it manually, 1 by 1, and according to the search API offered by every single app.

Using intent anchor in Ionic app (Android) returns "Cannot display PDF file"

I am trying to integrate the Square Payment on my Ionic 1 application using the Web API based on their docs here. They are using intent anchor to call the Square app and send appropriate payment details. But when I tried to implement, it gives me this error:
Can't display PDF file (intent URL cannot be opened)
Here's my code snippet:
var hrefString = 'intent://#Intent;';
var extrasObject = { /* extras */
"action": "com.squareup.register.action.CHARGE",
"package":"com.squareup",
"S.browser_fallback_url":"<my-fallback-url>",
"S.com.squareup.register.CLIENT_ID":"<my-client-id>",
"S.com.squareup.register.WEB_CALLBACK_URI": "<registered-callback-uri>",
"S.com.squareup.register.API_VERSION":"v1.3",
"i.com.squareup.register.TOTAL_AMOUNT": 100,
"S.com.squareup.register.CURRENCY_CODE":"USD",
"S.com.squareup.register.TENDER_TYPES":"com.squareup.register.TENDER_CARD,com.squareup.register.TENDER_CARD_ON_FILE,com.squareup.register.TENDER_CASH,com.squareup.register.TENDER_OTHER"
};
// Generate intent anchor
for(var key in extrasObject) {
hrefString += key + '=' + extrasObject[key] + ';';
}
// Convert string to URI
var intentURL = encodeURIComponent(hrefString + 'end');
window.open(intentURL, "_system", "location=no");
Prior to this implementation, I already install the InAppBrowser Cordova plugin here.
Can someone help me on this one? Thanks in advance!

AxSU3D Android Facebook Plugin - "The parameter app_id is required"

I'm using AxSU3D's Android plugin in a Unity project. When I try to use the Facebook Login method, I get an error that says "The parameter app_id is required"
I have posted my code below. I have REPLACED the string "fbAppID" with the actual ID. This is just the sample script that came with the plugin that I am trying to use.
Any help will be appreciated
using UnityEngine;
using System.Collections;
using AxSAndroidPlugin.Core;
using AxSAndroidPlugin.Social.Facebook;
public class FacebookSample : MonoBehaviour {
public string fbAppID = "YOUR_FACEBOOK_APP_ID_HERE";
public GameObject picture;
//Texture2D tex;
void OnGUI () {
if(GUI.Button(GUIControls.GetButtonRect(1), "Init" ))
Facebook.Init(fbAppID);
if(GUI.Button(GUIControls.GetButtonRect(2), "Login" ))
Facebook.Login();
if(GUI.Button(GUIControls.GetButtonRect(3), "IsLoggedIn"))
Facebook.IsLoggedIn();
if(GUI.Button(GUIControls.GetButtonRect(4), "User Info")) {
Facebook.GetUserInfo();
}
if(GUI.Button(GUIControls.GetButtonRect(5), "Friends")) {
Facebook.GetFriendsList();
}
if (GUI.Button (GUIControls.GetButtonRect (6), "Load Profile Picture")) {
Facebook.LoadProfilePicture();
}
if (GUI.Button (GUIControls.GetButtonRect (7), "Get Profile Picture")) {
Texture2D tex = Facebook.GetProfilePicture();
picture.renderer.material.mainTexture = tex;
}
if(GUI.Button(GUIControls.GetButtonRect(8), "Send Request")) {
Facebook.SendRequest("This Plugin Rocks!");
}
if(GUI.Button(GUIControls.GetButtonRect(9), "Post To Timeline")) {
string name = "AxS Android Plugin";
string caption = "AxS Android Plugin for Unity";
string description = "A complete solution to all your Android native needs!";
string link = "http://www.axsu3d.com/";
string pictureLink = "http://www.axsu3d.com/DLs/axsu3dLogo.png";
Facebook.PostToTimeline(name, caption, description, link, pictureLink);
}
//Get the user's likes
if(GUI.Button(GUIControls.GetButtonRect(10), "User Likes")) {
Facebook.GetUserLikes();
}
//Logout of Facebook
if(GUI.Button(GUIControls.GetButtonRect(11), "Logout" ))
Facebook.Logout();
if(GUI.Button(GUIControls.GetButtonRect(12), "Back"))
Application.LoadLevel("CoreSample");
}
}
Firstly, wow. I didn't realize something I helped make would show up on SO.
The solution is quite simple, really. You probably did not use the "Merge Manifest" option.
You can find this option under "Tools/AxSU3D/Android/Merge Manifest". This will show a window where you can put in your Facebook app ID.
The option will create or merge a new AndroidManifest.xml file, which will also contain your Facebook App ID.
Try it out.

Get Voice input from Android Wearable

Currently applications like Google Hangouts and Facebook Messenger are able to accept voice input from Android Wearables, translate them to text and send reply messages to users. I have followed the tutorial at https://developer.android.com/training/wearables/notifications/voice-input.html and when I call the method outlined there:
private CharSequence getMessageText(Intent intent) {
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
if (remoteInput != null) {
return remoteInput.getCharSequence(EXTRA_VOICE_REPLY);
}
}
return null;
}
I receive an error with the line RemoteInput.getResultsFromIntent(intent) stating that my API level is too low. Currently using a Samsung Galaxy S3, 4.4.2 API 19. Clearly, this method is not accessible to me, so my question is, how are applications like Hangouts and Facebook Messenger accepting voice input and getting that input onto my device?
developers.Android states that RemoteInput.getResultsFromIntent(intent); is a conveince so that we do not need to parse the ClipData, so I did some research and discorvered what exactly was needed to parse this ClipData and this is how I solved my Problem:
private void getMessageText(Intent intent){
ClipData extra = intent.getClipData();
Log.d("TAG", "" + extra.getItemCount()); //Found that I only have 1 extra
ClipData.Item item = extra.getItemAt(0); //Retreived that extra as a ClipData.Item
//ClipData.Item can be one of the 3 below types, debugging revealed
//The RemoteInput is of type Intent
Log.d("TEXT", "" + item.getText());
Log.d("URI", "" + item.getUri());
Log.d("INTENT", "" + item.getIntent());
//I edited this step multiple times until I discovered that the
//ClipData.Item intent contained extras, or rather 1 extra, which was another bundle
//The key for that bundle was "android.remoteinput.resultsData"
//and the key to get the voice input from wearable notification was EXTRA_VOICE_REPLY which
//was set in my previous activity that generated the Notification.
Bundle extras = item.getIntent().getExtras();
Bundle bundle = extras.getBundle("android.remoteinput.resultsData");
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
Log.d("TAG", String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
tvVoiceMessage.setText(bundle.get(EXTRA_VOICE_REPLY).toString());
}
This answer should be useful for anyone that is interested in developing a wearable application using notifications and voice input replies prior to the release of Android-L.

Categories

Resources