Hi, i was making a test on payment intent:
This is the code for launch intent:
Locale locale = new Locale("it", "IT");
String currencyCode = NumberFormat.getCurrencyInstance(locale).getCurrency().getCurrencyCode();
Payment payment = new Payment();
String referenceId = UUID.randomUUID().toString();
payment.setAmount(amount);
payment.setCurrency(currencyCode);
// start Payment activity for result
try {
Intent collectPaymentIntent = new Intent(Intents.ACTION_COLLECT_PAYMENT);
collectPaymentIntent.putExtra(Intents.INTENT_EXTRAS_PAYMENT, payment);
startActivityForResult(collectPaymentIntent, COLLECT_PAYMENT_REQUEST);
} catch (ActivityNotFoundException ex) {
Log.e(TAG, "Poynt Payment Activity not found - did you install PoyntServices?", ex);
}
After complete the payment i need confirmation about success, but also the transaction number.
I need to get the transaction id/number, but i don’t put this data in the Payment object.
I know that this seems to be strange but for the purpose of the app that i am developing, it’s needed to obtain a transaction number from the “outside”.
This is the onActivityResult function code:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == COLLECT_PAYMENT_REQUEST) {
if (resultCode == Activity.RESULT_OK) {
if (data != null) {
Payment payment = data.getParcelableExtra(Intents.INTENT_EXTRAS_PAYMENT);
Log.d(TAG, "Received onPaymentAction from PaymentFragment w/ Status("
+ payment.getStatus() + ")");
if (payment.getStatus().equals(PaymentStatus.COMPLETED)) {
Toast.makeText(this, "Payment Completed", Toast.LENGTH_LONG).show();
if(data.getExtras() != null){
if(data.getExtras().get(Intents.INTENT_EXTRAS_TRANSACTION_ID) != null){
String TransactionCode = data.getExtras().get(Intents.INTENT_EXTRAS_TRANSACTION_ID).toString();
}
}
} else if (payment.getStatus().equals(PaymentStatus.AUTHORIZED)) {
Toast.makeText(this, "Payment Authorized", Toast.LENGTH_LONG).show();
} else if (payment.getStatus().equals(PaymentStatus.CANCELED)) {
Toast.makeText(this, "Payment Canceled", Toast.LENGTH_LONG).show();
} else if (payment.getStatus().equals(PaymentStatus.FAILED)) {
Toast.makeText(this, "Payment Failed", Toast.LENGTH_LONG).show();
} else if (payment.getStatus().equals(PaymentStatus.REFUNDED)) {
Toast.makeText(this, "Payment Refunded", Toast.LENGTH_LONG).show();
} else if (payment.getStatus().equals(PaymentStatus.VOIDED)) {
Toast.makeText(this, "Payment Voided", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Payment No Status", Toast.LENGTH_LONG).show();
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(this, "Payment Canceled", Toast.LENGTH_LONG).show();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
In detail data.getExtras().get(Intents.INTENT_EXTRAS_TRANSACTION_ID)
return null and this is my problem.
There is another way to obtain transaction id/number after payment intent?
For example a transaction number generated by the Smartpos itself and related to the merchant transactions register.
Alternatively, if I insert a transaction number for each payment, then there is a way for the merchant to extract the list of all the transactions made in that SmartPos and from there to identify those made through my app?