Use the Reader SDK card-on-file workflow to create a customer card for an existing Customer
object. The card-on-file workflow is a sequence of screens used by customers to specify that they want to save their card information for future purchases.
Important
Always ask customers for permission before saving their card information. For example, include a checkbox in your purchase flow that customers can select to specify that they want to save their card information for future purchases.
Linking cards on file without obtaining customer permission can result in your application being disabled without notice.
Use the CustomerCardManager
class to create a new customer card manager to securely collect card information. Customer card information is stored on Square servers, not on the device running the Reader SDK, so you need to implement a callback to handle the response from Square.
import com.squareup.sdk.reader.ReaderSdk;
import com.squareup.sdk.reader.crm.CustomerCardManager;
import com.squareup.sdk.reader.core.CallbackReference;
CustomerCardManager customerCardManager =
ReaderSdk.customerCardManager();
...
CallbackReference storeCardCallbackRef = customerCardManager.addStoreCardActivityCallback(result -> {
hideLoadingIndicatorOnYourActivity();
if (result.isSuccess()) {
showStoreCardSuccessDialog(result.getSuccessValue());
} else {
showErrorDialog(result.getError());
}
});
Use the customer card manager to start the StoreCard
activity and link the card to an existing customer ID.
showLoadingIndicatorOnYourActivity();
customerCardManager.startStoreCardActivity(activity, customerId));