Quantcast
Jump to content


Recommended Posts

Posted

2026-03-16-01-banner.jpg

Integrating payments into a mobile app is a security-critical and UX-sensitive task. While Flutter simplifies cross-platform development, platform-specific payment systems like Samsung Pay still require careful handling.

Samsung provides an official Samsung Pay SDK Flutter Plugin, which allows Flutter applications to integrate Samsung Pay without writing custom platform channels. However, for production-grade integration, using the plugin correctly is essential, especially when it comes to checking Samsung Pay readiness.

In this blog, you learn how to build a sample Flutter application by using the official Samsung Pay SDK Flutter Plugin and following Samsung-recommended best practices. You can download the complete sample project at the end of this blog.

Why Use the Official Samsung Pay SDK Flutter Plugin?

Integrating payment systems requires careful handling of platform constraints, security, and long-term maintainability. The Samsung Pay SDK Flutter Plugin addresses these concerns by providing an official abstraction over the native Samsung Pay SDK, enabling Flutter applications to leverage Samsung Wallet features without direct interaction with platform-specific APIs.

By exposing supported Dart APIs and managing native SDK communication internally, the Flutter plugin removes the need for custom MethodChannel implementations and reduces integration risk. For Flutter applications targeting Samsung Galaxy devices, this approach offers the most stable and maintainable path to Samsung Pay integration.

The following diagram illustrates the high-level architecture of the Samsung Pay integration.

Text
Figure 1: Samsung Pay integration architecture

Prerequisites

Before starting, ensure the following requirements are met:

Set Up the Integration Code

To start the integration process, add the Samsung Pay SDK Flutter Plugin to your project dependencies:

dependencies:
  samsung_pay_sdk_flutter:
    path: ./samsungpaysdkflutter_v1.03.00/samsungpaysdkflutter

Next, configure the Samsung Pay SDK API level by setting a valid Samsung Pay SDK API version (latest version: 2.22) by opening android > app > src > main > AndroidManifest.xml and adding the API level in the metadata inside the <application> tag.

<meta-data
    android:name="spay_sdk_api_level"
    android:value="2.22" /> 
<!-- Use the most recent SDK version to leverage the latest APIs -->

Initialize Samsung Pay in Flutter

Create an instance of SamsungPaySdkFlutter with valid PartnerInfo (which contains the service ID and service type). If you are a merchant, then the service type must be set to INAPP_PAYMENT.

The following code snippet initializes the Samsung Pay SDK using your service ID and in-app payment configuration.

import 'package:samsung_pay_sdk_flutter/samsung_pay_sdk_flutter.dart';

static final SamsungPaySdkFlutter sdk = SamsungPaySdkFlutter(
  PartnerInfo(
    serviceId: SERVICE_ID,
    data: {
      SpaySdk.PARTNER_SERVICE_TYPE: ServiceType.INAPP_PAYMENT.name
    }
  )
);

Check Samsung Pay Availability

Samsung Pay readiness must be checked before calling any API of the Samsung Pay SDK Flutter Plugin. There are several reasons why Samsung Pay might not be in the ready state, such as an unsupported device, unsupported region, or incomplete Samsung Wallet setup, so this check is mandatory.

SamsungPayConfig.sdk.getSamsungPayStatus(
  StatusListener(
    onSuccess: (status, bundle) {
      // Status "2" means Samsung Pay is READY
      onResult(status == "2");
    },
    onFail: (errorCode, bundle) {
      // If status check fails, Samsung Pay is not ready
      onResult(false);
    }
  )
);

Create Payment Information with a Custom Payment Sheet

To initiate a transaction, you must create a payment request using a custom payment sheet.

The AmountBoxControl object is mandatory for building a CustomSheet. It provides the monetary details of the transaction.

AmountBoxControl amountControl = AmountBoxControl(
    Strings.AMOUNT_CONTROL_ID, Strings.currency
);

// Add product item to the payment sheet
amountControl.addItem(
  product.productId,
  product.name,
  product.price,
  ""
);

// Set total amount (product price + additional fees)
// You can add tax, shipping, or other fees here
amountControl.setAmountTotal(
  product.price + 5.00, // Add $5 for shipping/fees as example
  SpaySdk.FORMAT_TOTAL_PRICE_ONLY
);

Next, add the amountBoxControl to the CustomSheet instance.

CustomSheet customSheet = CustomSheet();
customSheet.addControl(amountControl);

Finally, create the payment information by populating the CustomSheetPaymentInfo instance

// Configure merchant information for the payment
CustomSheetPaymentInfo paymentInfo = CustomSheetPaymentInfo(
  merchantName: "Samsung Pay Flutter App",
  customSheet: customSheet
);

// Set merchant details
paymentInfo.merchantId = "123456";
paymentInfo.setMerchantName("Sample Merchant");
paymentInfo.setMerchantCountryCode("US");

Request Payment

To start the payment process, call the startInAppPayWithCustomSheet() API. This API requires CustomSheetPaymentInfo and CustomSheetTransactionInfoListener instances set up in the last step.

When this API is called, a custom payment sheet is displayed on the merchant application screen. The user can select a registered card for the payment and change the billing and shipping addresses if needed. Payment results are delivered to the CustomSheetTransactionInfoListener.

The onCardInfoUpdated() callback is triggered when the user changes the payment card. In this callback, the updateSheet() method must be called to update current payment sheet.

CustomSheetTransactionInfoListener listener = CustomSheetTransactionInfoListener(
  onCardInfoUpdated: (PaymentCardInfo cardInfo, CustomSheet sheet) {
    // Called when user changes the selected card on payment sheet
    // You can update the sheet here if needed (e.g., change fees based on card)
    SamsungPayConfig.sdk.updateSheet(sheet);
  },
  onSuccess: (paymentInfo, paymentCredential, extraData) {
    // Payment completed successfully
    // paymentCredential contains the encrypted card details to send to your backend
    print("Payment Successful!");
    print("Payment Credential: $paymentCredential");
    onSuccess();
  },
  onFail: (errorCode, bundle) {
    // Payment failed or user cancelled
    print("Payment Failed: $errorCode");
    onFail(errorCode);
  }
);

Lastly, call startInAppPayWithCustomSheet() API to start the payment:

SamsungPayConfig.sdk.startInAppPayWithCustomSheet(paymentInfo, listener);

Testing Samsung Pay Integration

Follow the steps below to test Samsung Pay integration

  1. Configure the STG environment: Add tester accounts to your service and generate a debug expiration date for the test accounts.
  2. Install Samsung Wallet test application: To test your application in the staging environment, the latest version of the Samsung Wallet test application is required. You can install it from the Samsung Pay Partner portal. However, to test your app in production mode, you need to use a market released application.
  3. Test cards: To thoroughly test your application, you must add at least one payment card to the Samsung Wallet application. Samsung provides test cards for this purpose. Keep in mind that the test cards only work in staging environments, not in production.
  4. Run the application: After setting up the environment, build the application and test it on any supported Galaxy device.

undefined

Figure 2: Samsung Pay Flutter sample application

Release Your Application

After successful testing, submit your application for release approval through the Samsung Pay Developers Portal. Once approved, your app can be published for your users.

Conclusion

Using the official Samsung Pay SDK Flutter Plugin makes it simpler to create a secure and reliable payment integration for Flutter applications on Galaxy devices. By following Samsung-recommended practices, such as checking Samsung Pay readiness and handling custom payment sheets correctly, you can build a production-ready and maintainable payment experience.

Additional Resources

View the full blog at its source



  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Similar Topics

    • By Samsung Newsroom
      The Galaxy Watch ecosystem is designed for seamless connection from capturing screenshots that sync automatically to your phone, to sharing what's on your wrist in seconds. This works great for most users.
      However, if you’re a developer, tester, or creator who prefers working directly on a computer, there’s a more efficient, hands-on way to capture your Galaxy Watch’s display.
      Using Command Prompt (or Windows Terminal) and Android Debug Bridge (ADB), you can directly screen record or capture screenshots from your Galaxy Watch without needing a companion mobile device or any third-party apps. It’s fast, simple, and perfect for creating app demos, tutorials, or development documentation.
      Record your Galaxy Watch screen via ADB
      Follow these steps to record your Galaxy Watch screen directly from your computer:
      Open the Command Prompt and use the cd command to navigate to the platform-tools folder: cd %LocalAppData%/Android/Sdk/platform-tools
      Pair and connect your Galaxy Watch to your computer over Wi-Fi. NoteThe link directs you to steps on how to connect the Galaxy Watch to Android Studio, but you can follow the same steps and commands when using the Command Prompt. Enter the command below to start screen recording your watch: adb shell screenrecord /sdcard/record_demo.mp4
      This command tells your computer (via ADB) to start recording the screen of your connected Galaxy Watch. Let's break it down piece-by-piece:
      adb – connects your computer to the watch or Android device. shell – opens a command-line interface inside the device. screenrecord – starts recording the device's screen. When you run screenrecord, the device starts capturing the display and saves it as a video file (the default format is .mp4). /sdcard/record_demo.mp4 – sets the file path where the recording will be saved on the device and the file name. Stop the recording by pressing CTRL + C.
      Transfer the recorded video to your computer: adb pull /sdcard/record_demo.mp4 C:\Destination\Folder\In\Your_Computer
      The pull command copies the recording from your watch to your computer.
      (Optional) Delete the recording from your watch using the rm command. adb shell rm /sdcard/record_demo.mp4 You now have a recorded video of your Galaxy Watch screen saved directly on your PC, ready for editing or presentation.


      Capture screenshots directly from Galaxy Watch to PC
      If you only need static images, you can easily transfer screenshots from your Galaxy Watch without using a phone:
      Take a screenshot on your Galaxy Watch by pressing the Home and Back buttons simultaneously until you see the screenshot animation.
      Locate the screenshot file using ADB shell and copy its filename.
      adb shell cd sdcard/DCIM/screenshots ls
      NoteYou can also run the simplified version of this command:
      adb shell ls /sdcard/DCIM/screenshots/ The ls command lists the screenshots stored on your watch.
      Transfer the screenshot to your computer: adb pull /sdcard/DCIM/screenshots/[File_Name].png C:\Destination\Folder\In\Your_Computer
      The image is now available on your computer for quick viewing or editing.

      Things to keep in mind
      This method works best with Galaxy Watches running Wear OS powered by Samsung (Galaxy Watch4 and newer models), as these devices support ADB connections for development and debugging. While this approach is highly effective for capturing screen activity, it has some limitations:
      Audio Capture: The screenrecord command records video but does not capture system audio. If you need audio, additional steps or tools may be required. Recording Duration: The recording duration may be limited (typically up to 3 minutes). This restriction can vary depending on the device and ADB implementation. Compatibility: Older Tizen-based Galaxy Watches may not support ADB connections, making this method unsuitable for those devices. Using ADB through Command Prompt provides a direct and efficient way to interact with your Galaxy Watch. Whether you're developing apps, recording demos, or capturing visuals for documentation, these simple commands make it easy to manage your device directly from your computer.
      View the full blog at its source
    • By Samsung Newsroom
      Introduction
      The Samsung IAP Subscription server APIs empower developers to efficiently manage Samsung In-App Purchase (IAP) subscriptions, including cancellation, refund, revocation, and status check. These APIs serve as the foundation for implementing subscription management features within your application management server.
      Integrating the Samsung IAP server APIs with your backend server simplifies subscription management. This integration allows you to cancel subscriptions and prevent further billing for users, revoke access to subscription-based content, process refunds based on user requests, and check subscription status to determine validity and current state.
      A well-structured backend implementation streamlines subscription management, ensuring customers receive reliable service and minimizing potential issues related to billing, access, and refunds.
      Prerequisites
      To establish server-to-server communication between the Samsung IAP service and your server, follow these essential steps.
      Develop a Subscription Application – Ensure your application supports subscription operations. Upload Binary for Beta Testing – Submit your application for testing in Seller Portal. Create Subscriptions – Set up subscription products in Seller Portal for user subscriptions. Completing these steps ensures a seamless integration of Samsung IAP into your application. For detailed guidance, visit Register an app and in-app items in Seller Portal.
      Implementation of the Samsung Subscription APIs
      The Samsung IAP Subscription server APIs are used to manage subscription-related operations, including cancellations, revocations, refunds, and status checks.
      To leverage these APIs effectively, setting up a backend server is essential. This secure server-to-server communication facilitates efficient handling of all subscription-related operations between the Samsung IAP service and your server.
      API Overview
      The Samsung IAP Subscription server API provides endpoints for efficiently managing subscription-based operations. It allows developers to cancel, revoke, refund, and check the status of subscriptions. This API also facilitates robust operations and efficient management of user subscriptions, all while ensuring security and authentication through the use of appropriate headers.
      Base Endpoint
      The Samsung IAP Subscription server APIs need a secure endpoint for managing subscriptions.
      https://devapi.samsungapps.com/iap/seller/v6/applications/<packageName>/purchases/subscriptions/<purchaseId> More detailed information is available through the Support Documentation.
      Headers
      To ensure secure communication with the Samsung IAP service, the following headers must be included in every request.
      Content-Type – Defines the format of the request body. For JSON content, use application/json. Authorization – Uses an access token for authentication. The format should be (Bearer <access_token>). Refer to the Create an Access Token page for details on generating an access token. Service Account ID – Obtained from Seller Portal under Assistance > API Service. This ID is required to generate a JSON Web Token (JWT). For more detailed information, visit the Create a Service Account section in Seller Portal. These headers collectively ensure secure and authenticated API requests, enabling seamless integration with the Samsung IAP service.
      Supported Methods
      The Samsung IAP Subscription server API enables efficient subscription management. Developers can cancel, revoke, or refund subscriptions using PATCH requests, and check subscription status using GET requests.
      Configuring the Server
      You can develop a Spring Boot server for this purpose. Here are the guidelines for setting it up.
      Create a Spring Boot Project - For detailed steps, refer to Developing Your First Spring Boot Application. Set Up the Server Endpoint: Create a controller for Samsung IAP Subscription APIs within your IDE after importing the Spring Boot project. This controller manages all in-app subscription activities. The controller performs PATCH and GET requests with the Samsung IAP service, ensuring communication with your server. Performing a PATCH Request
      The PATCH request is used to cancel, refund, or revoke a subscription. Follow these steps to proceed.
      Creating a Request Body To cancel, refund, or revoke a subscription, a specific request body must be created for each operation. When interacting with Samsung IAP service, you send a well-structured API request tailored to the specific action you wish to execute. Below are the request formats for various subscription operations.
      // Cancel a subscription RequestBody body = RequestBody.create( MediaType.parse("application/json"), "{\"action\" : \"cancel\"}" ); // Revoke a subscription RequestBody body = RequestBody.create( MediaType.parse("application/json"), "{\"action\" : \"revoke\"}" ); // Refund a subscription RequestBody body = RequestBody.create( MediaType.parse("application/json"), "{\"action\" : \"refund\"}" ); Building the PATCH Request (Cancel, Revoke or Refund Subscription) The PATCH method in REST APIs is used for partial updates of resources, enabling you to send only the specific fields that need modification rather than the entire resource. The PATCH request needs a request body to specify the intended action. To execute a subscription management request, you must construct a secure HTTP request that includes all necessary headers and authentication details.
      Request request = new Request.Builder() .url(API_URL) .patch(body) .addHeader("Content-Type", "application/json") .addHeader("Authorization", "Bearer " + ACCESS_TOKEN) .addHeader("service-account-id", SERVICE_ACCOUNT_ID) .build(); Executing the PATCH Request Once the PATCH request is prepared, execute it using the OkHttpClient, ensuring proper request handling and response processing.
      @CrossOrigin(origins = "*") @RequestMapping(value = "/cancel", method = RequestMethod.PATCH ) public void patchRequest(){ // Set request body as JSON with required action. // Initialize PATCH request, set body, add headers, and finalize setup. client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // handle exception } @Override public void onResponse(Call call, Response response) throws IOException { // handle response response.close(); } }); } Example Response
      This response indicates that the request was processed successfully and without errors.
      { "code" : "0000", "message" : "Success" } Performing a GET Request
      The GET request is used to retrieve the status of a subscription. Follow these steps to proceed.
      Building the GET Request The GET method is primarily used to retrieve or read data from a server. To check the status of a subscription, the GET method is required to retrieve detailed item information. This type of request does not require a request body; only the necessary headers for authentication are needed.
      Request request = new Request.Builder() .url(API_URL) .addHeader("Content-Type", "application/json") .addHeader("Authorization", "Bearer " + ACCESS_TOKEN) .addHeader("service-account-id", SERVICE_ACCOUNT_ID) .build(); Executing the GET Request Once the GET request is prepared, execute it using the OkHttpClient to retrieve and efficiently process the response data.
      @GetMapping("/get") public void getRequest(){ // Initialize GET request, add headers, and finalize setup. client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { // handle exception } @Override public void onResponse(Call call, Response response) throws IOException { // handle response } }); } Example Response
      If the GET request executes successfully, it returns the status of the subscription as a response.
      { "subscriptionPurchaseDate": "2025-04-28 04:54:06 UTC", "subscriptionEndDate": "2025-04-28 05:54:06 UTC", "subscriptionStatus": "CANCEL", "subscriptionFirstPurchaseID": "55541a3d363c9dee6194614024ee2177c72a9dec51fe8dba5b44503f57dc9aec", "countryCode": "USA", "price": { "localCurrencyCode": "USD", "localPrice": 15, "supplyPrice": 15 }, ... } Deploying and Testing the Server
      For the server to perform API calls, it can use a publicly accessible URL. You can deploy the project to obtain the URL. For testing purposes, you might deploy it on a platform like CodeSandbox, which provides a publicly accessible URL similar to https://abcde-8080.csb.app/iap/xxxx.
      Conclusion
      By properly integrating the Samsung IAP Subscription server APIs, developers can ensure seamless handling of subscription-related actions within their applications. The implementation of secure server-to-server communication guarantees efficient subscription management and significantly enhances the overall user experience.
      References
      Download Sample Server Source Code Samsung IAP Subscription Documentation Integrate the Samsung In-App Purchase Orders API with Your Application View the full blog at its source
    • By Samsung Newsroom
      January 2025 Unveiling Invites to "Galaxy Unpacked 2025" Ushering in a New Era of Mobile AI
      New Galaxy products are unveiled at Galaxy Unpacked 2025! Galaxy Unpacked 2025 commences on January 23, 3 AM KST (January 22, 10 AM local time) in San Jose, USA. It is streamed live online via the Samsung Electronics Newsroom, Samsung.com, and Samsung Electronics YouTube channel. Samsung Electronics' innovations are going to usher in a new era of the mobile AI experience with the natural and intuitive Galaxy UI. See for yourself.
        Learn More Highlights from the CES 2025 Samsung Press Conference
      On January 6, Samsung Electronics held the CES 2025 Samsung Press Conference under the theme "AI for All: Everyday, Everywhere," unveiling its technological visions. The full inter-device connectivity and hyper-personalized user experience through AI, both introduced at the conference, have attracted media attention from all over the world. Check out the innovative technologies that will change the future in our video.
        Learn More Updates for Samsung In-App Purchase: Resubscription and Grace Period Features
      Managing subscriptions is now more convenient with the new Samsung in-app purchase (IAP) updates. The newly updated features are resubscription and grace period.
      Users can now reactivate their canceled subscription in Galaxy Store using the resubscribe feature. Even if there is a problem with the payment when renewing a subscription, the subscription is not canceled if the problem is resolved during the set grace period. If the developer activates the grace period feature in the item settings of Galaxy Store's Seller Portal, the system automatically retries the payment and sends the information about the failed automatic payment to the user so that they can change their payment method.
      Developers can also see new information in the subscription API and ISN services, such as the subscription API's response parameters and ISN service events. Manage your subscriptions more effectively using these new features. Tutorial: Manage the Purchase/Subscription of Digital Items with Samsung In-App Purchases
      The hassle of managing digital item purchases and subscriptions is no more! Samsung in-app purchase (IAP) is a powerful tool that provides a more secure and convenient payment environment for users and expands commercialization opportunities for developers. This tutorial covers how to smoothly and efficiently implement item purchase/consumption processing and subscription management. A step-by-step guide and practical code examples are used to walk developers through the complex API integration process even if they're just starting out. Check out the tutorial on the Samsung Developer Portal.
        Learn More Tutorial: Step into Galaxy Watch Application Development Using Flutter
      Did you know that you can develop an application for Galaxy Watches with a single codebase? The tutorial shows software developers how they can develop applications for Galaxy Watch using the Flutter framework. Flutter is an open-source framework for building multi-platform applications from a single codebase. An easy step-by-step guide that can be followed without much preparation is provided for beginners, as well as practical tips and a code example for Flutter developers who are new to developing Galaxy Watch applications. Check out the tutorial and start developing Galaxy Watch applications!

      Learn More Tutorial: Monitoring Your Cards in Samsung Wallet in Real Time
      Do you want to monitor the status of cards added to Samsung Wallet on user devices in real time? Samsung Wallet provides the Send Card State API to make it easy to track the cards, as the API notifies the server of any changes whenever a card is added, deleted, or updated.
      The tutorial covers how to set up server notifications, how to receive notifications to a Spring server, and how to securely verify the received notifications. Learn how to monitor the status of cards in Samsung Wallet in real time.

      Learn More Samsung Electronics Demonstrates AI-RAN Technologies, Paving the Way for the Convergence of Telecommunications and AI
      Telecommunications technology is evolving beyond just improvements in data transmission speed, moving towards emphasizing user experience, energy efficiency, and sustainability. Samsung Electronics is accelerating the emergence of the era of future communications by showcasing the AI-RAN technology which integrates AI technology with the Radio Access Network (RAN), which is the core technology for communications networking.
      In particular, at the Silicon Valley Future Wireless Summit held in November 2024, Samsung Electronics demonstrated the results of the AI-RAN PoC to global communications providers, the first in the industry to do so. The technology indicated a possibility to greatly improve data throughput, communication coverage, and energy efficiency compared to the existing 5G RAN. It also proved the convergence of communications and AI could significantly enhance network performance. Learn more about Samsung Electronics' AI-RAN technology that goes beyond the boundary of communications and creates smarter networks with AI.

      Learn More Building a Trusted Execution Environment on RISC-V Microcontrollers
      In embedded systems such as IoT devices, it is crucial to protect sensitive data. For this, a Trusted Execution Environment (TEE) is required. It creates an isolated environment within the processor, so that security-sensitive tasks can be executed without risk of external threats.
      Samsung Research is conducting a study on how to implement the TEE technology on RISC-V-based microcontrollers (MCU), an open-source hardware architecture, and has introduced mTower, a core project related to this study. Learn more about stronger security for IoT devices on the Samsung Research blog.

      Learn More   
      https://developer.samsung.com

      Copyright© %%xtyear%% SAMSUNG All Rights Reserved.
      This email was sent to %%emailaddr%% by Samsung Electronics Co.,Ltd.
      You are receiving this email because you have subscribed to the Samsung Developer Newsletter through the website.
      Samsung Electronics · 129 Samsung-ro · Yeongtong-gu · Suwon-si, Gyeonggi-do 16677 · South Korea

      Privacy Policy       Unsubscribe

      View the full blog at its source
    • Government UFO Files
    • By maljaros
      There is no native Strava mobile app for Tizen OS smartphones, so what app could be used for tracking trail run and cycling activities on a Samsung Z4? Or is there a "non-native" route to Strava itself?
      Thank you, Maljaros





×
×
  • Create New...