We need to get cardholder name when card swiped. Is that available? Is customer Id is added to Order object when card swiped?
We need to get cardholder name when card swiped. Is that available? Is customer Id is added to Order object when card swiped?
Hi @lingaraja,
First you'll want to register your app's Manifest to listen for the PAYMENT_PROCESSED broadcast
<receiver
android:name=".YourReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.clover.intent.action.PAYMENT_PROCESSED" />
</intent-filter>
</receiver>
This will give you access to an OrderID and PaymentID when you receive the broadcast.
public void onReceive(Context context, Intent intent) {
String paymentId = intent.getStringExtra(Intents.EXTRA_CLOVER_PAYMENT_ID);
String orderId = intent.getStringExtra(Intents.EXTRA_CLOVER_ORDER_ID);
}
Using those IDs, you can use the orderConnector to find that payment and get the cardholder name. Pseudo-code below that would need better logic for anything production.
public void getCardholderNameFromLastPayment() {
new AsyncTask<Void, Void, Void>() {
protected final Void doInBackground(Void... params) {
try {
List<Payment> payments;
payments = orderConnector.getOrder("ORDER_ID").getPayments();
payments.get(payments.size() - 1).getCardTransaction().getCardholderName();
} catch (RemoteException | ClientException | ServiceException | BindingException e) {
e.printStackTrace();
}
return null;
}
}.execute();
}
N.B., the PAYMENT_PROCESSED broadcast is also fired on cash payments, so among other things, you'll want to ensure that the payment.getCardTransaction() != null
No one has followed this question yet.