SDK Programming Guide
  • Using the Samsung Pay SDK APIs
  • Simply put, an application programming interface (API) allows one piece of software to make use of the functionality of, or data available to, another. It provides a consistent, programmatic method for accessing a resource. Put another way, it is simply a structured way of exposing functionality.

    An API, in the context of Java, is a collection of prewritten packages, classes, and interfaces with their respective methods, fields and constructors. An interface is a collection of abstract methods that a class implements by defining the behavior/state of an object. Similar to a user interface, which facilitates interaction between humans and computers, an API serves as a software program interface facilitating interaction between the partner app and Samsung Pay.

  • 3.1 Online (In-App) Payment API flow and classes
  • The main classes involved here are:
  • SamsungPay – Class for merchant app to get Samsung Pay SDK information and the status of Samsung Pay on the device.
  • PaymentManager – Class to provide payment/transaction functionality.
  • CardInfoListener – Interface for requestCardInfo result from Samsung Pay.
  • TransactionInfoListener – Interface for transaction success/failure callbacks from Samsung Pay; payment information is provided with a success callback and must be used by the merchant app for processing the payment. This is for the normal payment sheet type only.
  • CustomSheetTransactionInfoListener – Interface for transaction success/failure callbacks from Samsung Pay; payment information is provided with a success callback and must be used by the merchant app for processing the payment. This is for the custom payment sheet type only.
  • Figures 2 and 3 capture the Online Payment API process flow between merchant apps integrated with the Samsung Pay SDK and Samsung Pay using the direct and indirect models (see the Samsung Pay white paper Merchant Onboarding for In-App Payments Integration for more on the direct and indirect online payment models).
  • The diagrams below reflect the following essential operations:
    1. Checking the ready status of Samsung Pay.
    2. Starting Payment Manager to establish the service binding and verify the merchant app.
    3. Getting payment card information and the payment amount, including updates.
    4. Getting/updating the user’s billing and shipping addresses, including an updated payment amount if shipping charges will be incurred.
    5. Authenticating the user.
    6. Submitting payment information to PG.
    7. Verifying transaction success or failure.
  • Figure 2: API flow for In-App payments with normal payment sheet

  • Figure 3: API flow for In-App payments with custom payment sheet

  • Feature implementation using the SDK’s API library is discussed in Section 3.3.
  • 3.2 Push Provisioning and open Favorite Cards API flow and classes
  • Figure 4 captures the Push Provisioning and open Favorite Cards API flow for an issuer app integrated with the Samsung Pay SDK.
  • Figure 4: API flow for issuer app

  • The main classes involved here are:
  • SamsungPay – Class for issuer app to fetch Samsung Pay SDK information and the status of Samsung Pay on the device.
  • PaymentManager – Class to provide payment-related functionality.
  • CardManager – Class to provide APIs for card management.