question

lingaraja avatar image
lingaraja asked Mark Mullan Deactivated commented

Can I get a cardholder name when card swipe in clover SDK?

We need to get cardholder name when card swiped. Is that available? Is customer Id is added to Order object when card swiped?

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Mark Mullan avatar image
Mark Mullan Deactivated answered Mark Mullan Deactivated commented

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();
}
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Mark Mullan avatar image Mark Mullan commented ·

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

0 Likes 0 ·

Welcome to the
Clover Developer Community