Common Flow

Once setup is complete, you’re ready to add the Samsung Pay SDK Flutter Plugin code within your partner app for calling the Samsung Pay SDK’s APIs and receiving callbacks. The following functionalities are ready to call through APIs:

  • Checking Samsung Wallet Status
  • Activating the Samsung Wallet App
  • Updating the Samsung Wallet App

Checking Samsung Wallet Status

The first step in implementing the Samsung Pay SDK Flutter Plugin within your partner app is to create the SamsungPaySdkFlutter instance, this will check the Samsung Wallet status on the device. It's determine the support for Samsung Wallet (or lack thereof), and whether or not to display the Samsung Pay button to the user for selection as a payment option. The Samsung Pay button also lets issuer apps add a card to Samsung Wallet. In both instances, the partner app must have valid PartnerInfo to pass to SamsungPay for caller verification.

To set its PartnerInfo, the partner app passes its serviceId (SID) and ServiceType, both of which are assigned by the Samsung Pay Developers portal when you create the service. This will be used for checking blocked list and version control between the Samsung Pay SDK Flutter Plugin and the Samsung Wallet app on the device. You must set the ServiceType in PartnerInfo to call other Samsung Wallet APIs.

String serviceId;
Map<String,dynamic> data;
static final samsungPaySdkFlutterPlugin = SamsungPaySdkFlutter(PartnerInfo(serviceId: 'partner_app_service_id', data: {SpaySdk.PARTNER_SERVICE_TYPE:ServiceType.APP2APP.name.toString()}));

After setting PartnerInfo, your partner app can now call getSamsungPayStatus(). This method of the SamsungPay class must be called before using any other feature in the Samsung Pay SDK Flutter Plugin.

  Future<void> getSamsungPayStatus(StatusListener? statusListener)

The result is delivered to StatusListener and provides onSucccess and onFail events. Check the Android SDK Common Flow for more details.

The following sample code shows how to use the getSamsungPayStatus() API method:

 MyHomePage.samsungPaySdkFlutterPlugin.getSamsungPayStatus(StatusListener(onSuccess:(status, bundle) async {

  showStatus(status, bundle);
  
    }, onFail:(errorCode, bundle){
  
      showError(errorCode, bundle);
  
    }
    ));

Activating the Samsung Walllet App

The SamsungPaySdkFlutter class provides the following API method to activate the Samsung Wallet app on a device:

 Future<void> activateSamsungPay()

activateSamsungPay() is called to activate the Samsung Wallet app on the same device on which the partner app is running. First, the partner app must check the Samsung Wallet status with a getSamsungPayStatus() call. If the status is SPAY_NOT_READY and EXTRA_ERROR_REASON is ERROR_SPAY_SETUP_NOT_COMPLETE, the partner app needs to display an appropriate message to user, then call activateSamsungPay() to launch the Samsung Wallet app so the user can sign in.

Here’s an example of how to code this

 samsungPaySdkFlutterPlugin.activateSamsungPay();

Updating the Samsung Wallet App

The SamsungPaySdkFlutter class provides the following API method to update the Samsung Wallet app on the device:

Future<void> goToUpdatePage()

goToUpdatePage() is called to update Samsung Wallet app on the same device on which the partner app is running.

As with all API calls, the partner app must first check the Samsung Wallet status with getSamsungPayStatus(). If this returns SPAY_NOT_READY and EXTRA_ERROR_REASON is ERROR_SPAY_APP_NEED_TO_UPDATE, then the partner app needs to display an appropriate message to the user and call goToUpdatePage(), which launches the Samsung Wallet update page.

The following code sample reflects how to update Samsung Wallet:

samsungPaySdkFlutterPlugin.goToUpdatePage();