Retrieve wallet information

To request wallet information from Samsung Wallet, use the getWalletInfo() method, provided by the SamsungPay (for the Samsung Pay SDK for Android) or SamsungPaySdkFlutter (for the Samsung Pay SDK for Flutter) class. The method allows you to uniquely identify the customer and the Samsung Wallet app on a particular device and provides data needed for provisioning:

  1. Make sure you have checked the Samsung Pay status on the customer's device and the returned status is SPAY_READY.

  2. For the Samsung Pay SDK for Android only, define the information you want to retrieve as keys. If no keys are defined, DEVICE_ID, WALLET_USER_ID, and WALLET_DM_ID are returned.

    For the Samsung Pay SDK for Flutter, all keys are returned by default.

  3. Call the getWalletInfo() method. The result is delivered to the StatusListener interface, which provides the following events:

    • onSuccess(): Called when the operation is successful and returns the wallet details based on the defined keys.
    • onFail(): Called when the operation fails.

The following code snippet is an example of using the getWalletInfo() method:

Samsung Pay SDK for Android:

// Set the serviceId assigned by the Samsung Pay Portal during onboarding
val serviceId = "sampleServiceId"
val bundle = Bundle()
bundle.putString(SamsungPay.EXTRA_ISSUER_NAME, "issuer name")
bundle.putString(SamsungPay.PARTNER_SERVICE_TYPE, ServiceType.APP2APP.toString())

val pInfo = PartnerInfo(serviceId, bundle)
val samsungPay = SamsungPay(context, pInfo)

// Add bundle keys to get wallet information
// This information can be delivered to your server for an eligibility check.
val keys = ArrayList<String>()
keys.add(SamsungPay.WALLET_USER_ID)
keys.add(SamsungPay.DEVICE_ID)

samsungPay.getWalletInfo(keys, object : StatusListener{
    override fun onSuccess(status: Int, walletData: Bundle) {
        // Log.d(TAG, "doWalletInfo onSuccess callback is called");
        // For VISA, deviceID can be set to "clientDeviceID" as defined by VISA
        val deviceId = walletData.getString(SamsungPay.DEVICE_ID)
        // For VISA, walletUserId can be set to "clientWalletAccountID" as defined by VISA
        val walletUserId = walletData.getString(SamsungPay.WALLET_USER_ID)
    }

    override fun onFail(errorCode: Int, errorData: Bundle?) {
        Log.e(TAG, "onFail callback is called, errorCode: " + errorCode);
        // Check the extra error codes in the errorData bundle for all the reasons in
        // SamsungPay.EXTRA_ERROR_REASON, when provided
    }
})

Samsung Pay SDK for Flutter:

    String serviceId; 
    SpaySdk.PARTNER_SERVICE_TYPE: ServiceType.APP2APP.name.toString()

    SamsungPaySdkFlutter(PartnerInfo(serviceId: "", data: {}));
    samsungPay=SamsungPay(context,partnerInfo)

    val keys = ArrayList<String>()
    keys.add(SamsungPay.WALLET_DM_ID)
    keys.add(SamsungPay.DEVICE_ID)
    keys.add(SamsungPay.WALLET_USER_ID)
    samsungPaySdkFlutterPlugin.getWalletInfo(StatusListener(onSuccess: (status, bundle) async {
        val deviceId: String? = walletData.getString(SamsungPay.DEVICE_ID)
        val walletUserId: String? = walletData.getString(SamsungPay.WALLET_USER_ID)
    }, onFail: (errorCode, bundle) {
        Util.showError(context, errorCode, bundle);
    }));