Query a payment
If you want to inquire about a payment instance already made in the RDCPass application, follow the steps below.
- Add the intent-filter (Activity) in your project's AndroidManifest.xml file:
<action android:name="android.intent.action.ANSWER" />
In addition to the intent-filter for creating the payment intention, your project should look like this:
android
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.ANSWER" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
- Implement again the "shareRDCPass" function used to create a payment intention, but change the
String intent
to the valueIntent.ACTION_ANSWER
, which corresponds to the intention of querying for a payment.
The String total
value, on the other hand, can be empty (String total = ""
).
android
public void shareRDCPass(String total, String intent) {
try {
Intent sharingIntent = new Intent(intent);
sharingIntent.setClassName("redelcom.cl.rdcpass", "redelcom.cl.rdcpass.MainActivity");
sharingIntent.putExtra("packageName", getPackageName());
sharingIntent.putExtra("className", getClass().toString().split(" ")[1]);
sharingIntent.putExtra("userTransactionId", "DEMO1234");
startActivity(sharingIntent);
} catch (Exception e) {
e.printStackTrace();
}
}
- To receive the response from RDCPass, you should also include the following code block:
android
try{
Intent intent = getIntent();
String action = intent.getAction();
String payload = new JSONObject(intent.getStringExtra("payload"));
String userTransactionId= new JSONObject(intent.getStringExtra("userTransactionId"));
if (Intent.ACTION_ANSWER.equals(action)) {
// Define what to do with the received data “payload”
}
} catch (Exception e) {
e.printStackTrace();
}
The structure of the response for the payment query intention will be the same as that provided during the creation of a payment intention. You can check it out in the annex: response examples.