Quantcast
Jump to content


Recommended Posts



  • 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
      Samsung Wallet provides powerful tools for partners to engage with their users and improve the user experience. Push notification is one of these features, allowing partners to send customized notifications to their users. But before they can do that, partners need to create a notification template and receive approval for it from Samsung.
      Partners can create individual notification templates from the Wallet Partners Portal. As a partner, if you need to create a large number of card notifications, the Adding Notification Templates server API comes in handy.
      In the example scenario in this blog, we create a notification template from a partner's server using the Adding Notification Template API.
      System requirements
      The Adding Notification Template API has the following prerequisites:
      Complete the onboarding procedure to obtain the required security certificates if you are new to Samsung Wallet, and create your wallet card.
      Get permission from Samsung to use the Adding Notification Template API as explicit permission is needed. Reach out to Samsung Developer Support for further assistance.
      API fundamentals
      To create a notification template, you need to handle an HTTP POST request which contains the endpoint, headers, and a body. For a successful execution of the API, you need to follow the following specification.
      Endpoint: Use the following URL as endpoint.
      URL https://tsapi-card.walletsvc.samsung.com/partner/v1/card/template/{Card Id}/notification Headers: To ensure secure communication between the Samsung server and the partner server, implement the following headers.
      Authorization: Bearer token for authentication. For details, follow REST API Authorization Token. x-smcs-partner-id: Use the Samsung Wallet partner ID. x-request-id: A unique UUID string that identifies each request. Body: Contains detailed template data in the JWT token format. See the Adding Notification Templates for a detailed API specification.
      API implementation
      The steps below show how to implement the Adding Notification Template API. For a better understanding of the implementation process, download the sample source code.
      Certificate management
      The KeyManager class is a static utility class that provides methods for loading cryptographic keys from files. This separation of concerns ensures that certificate handling logic is isolated and reusable.
      Loading public keys from certificate files
      First, you need to load RSA public certificates from X.509 certificate files. The GetPublicKeyRSA() method loads RSA public keys from the partner.crt and samsung.crt files you received during the onboarding process. If the certificate doesn't contain an RSA key, this method raises an exception.
      public static RSA GetPublicKeyRSA(string certPath) { try { var cert = new X509Certificate2(certPath); return cert.GetRSAPublicKey() ?? throw new InvalidOperationException("Certificate does not contain RSA public key"); } catch (Exception ex) { throw new InvalidOperationException($"Failed to load certificate: {ex.Message}", ex); } } Loading private keys from a PEM file
      The GetPrivateKeyRSA() method loads an RSA private key from a PEM file. This is used to generate JWT tokens.
      public static RSA GetPrivateKeyRSA(string pemPath) { try { string keyData = File.ReadAllText(pemPath); // Remove PEM headers and whitespace keyData = keyData.Replace("-----BEGIN PRIVATE KEY-----", "") .Replace("-----END PRIVATE KEY-----", "") .Replace("-----BEGIN RSA PRIVATE KEY-----", "") .Replace("-----END RSA PRIVATE KEY-----", "") .Replace("\n", "") .Replace("\r", "") .Trim(); byte[] keyBytes = Convert.FromBase64String(keyData); var rsa = RSA.Create(); rsa.ImportPkcs8PrivateKey(keyBytes, out _); return rsa; } catch (Exception ex) { Console.WriteLine($"Failed to load private key from {pemPath}: {ex.Message}"); return null; } } Token generation
      The TokenGenerator class is the heart of the implementation, responsible for creating secure tokens using cryptographic techniques.
      Constructor and properties
      The class stores all necessary cryptographic keys and identifiers.
      private string _partnerId = ""; private string _certificateId = ""; private readonly RSA _samsungPublicKey; private readonly RSA _partnerPublicKey; private readonly RSA _partnerPrivateKey; public TokenGenerator(string partnerId, string certificateId, RSA samsungPublicKey, RSA partnerPublicKey, RSA partnerPrivateKey) { _partnerId = partnerId; _certificateId = certificateId; _samsungPublicKey = samsungPublicKey; _partnerPublicKey = partnerPublicKey; _partnerPrivateKey = partnerPrivateKey; } Generating an authentication token
      An authentication token proves that your request to Samsung's server is legitimate. It contains the following:
      The API method and path being accessed. var authPayload = new Dictionary<string, object> { ["API"] = new Dictionary<string, string> { ["method"] = "POST", ["path"] = $"/partner/v1/card/template/{cardId}/notification" } }; Timestamp and other metadata like certificate id. Retrieve this metadata from My account > Encryption Management in the Wallet Partners Portal.
      A digital signature that verifies the sender's identity. The token is used in the Authorization header of the HTTP request.
      public string GenerateAuthToken(Dictionary<string, object> authPayload, string contentType_auth) { string dataStr = JsonSerializer.Serialize(authPayload); string authToken = SignJws(dataStr, contentType_auth); return authToken; } Generating a notification template token
      Next, generate the JWT token for notification template data (ntemplate). It is recommended to generate this token after a user action. For details about the JWT format, follow Card Data Token (cdata).
      Preparing a notification template
      Define the notification template according to the following code snippet. Define your message details and message type here. Get details about the template fields from the “[Request]” section of the Adding Notification Templates documentation.
      var notificationTemplate = new { type = "M", messageType = "M", messageDetails = new[] { new { languageCode = "en", message = "Sample merchant push notification message." } }, forceSaveYn = "N" }; NoteUse forceSaveYn = “Y”, if you want to save the template even if the message is detected as harmful. If your message is detected as harmful, your template can be rejected by Samsung. The default value of the forceSaveYn property is “N”. Implementing encryption (JWE)
      The notification template data or payload is encrypted using the Samsung public key and this encrypted payload is used for signing.
      public string GenerateCdata(string payloadData, string notification) { string jweTokenString = JWT.Encode(payloadData, _samsungPublicKey, JweAlgorithm.RSA1_5, JweEncryption.A128GCM); string jwtTokenString = SignJws(jweTokenString, notification); return jwtTokenString; } Implementing JWS signing
      The encrypted JWE token is then signed with the partner's private key. This signature proves the token originated from a legitimate partner. Samsung can verify this signature using the partner's public key.
      NoteUse AUTH as the content type when signing an auth token and use NOTIFICATION as the content type when signing the notification template data. private string SignJws(string payload, string contentType) { try { // Create header var header = new Dictionary<string, object> { ["alg"] = "RS256", ["cty"] = contentType, ["partnerId"] = _partnerId, ["ver"] = 3, ["certificateId"] = _certificateId, ["utc"] = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }; return JWT.Encode(payload, _partnerPrivateKey, JwsAlgorithm.RS256, header); } catch (Exception ex) { throw new InvalidOperationException($"JWS signing failed: {ex.Message}", ex); } } Building and executing the POST request
      The next stage of the process is to construct the HTTP POST request to generate a new notification.
      client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Add("Authorization", $"Bearer {authToken}"); client.DefaultRequestHeaders.Add("x-smcs-partner-id", partnerId); client.DefaultRequestHeaders.Add("x-request-id", requestId); try { HttpResponseMessage response = await client.PostAsync(endpoint, content); response.EnsureSuccessStatusCode(); string responseContent = await response.Content.ReadAsStringAsync(); Console.WriteLine("Successfully generated notification template: " + responseContent); } catch (HttpRequestException e) { Console.WriteLine("Failed to generate notification template: " + e.Message); } catch (Exception e) { Console.WriteLine("Unexpected error during HTTP request: " + e.Message); } Running the sample application
      Once you are done with the above steps, open the sample project and do the following:
      Update the partnerId, cardId, and certificateId values in the src/Program.cs file with your actual values. Place your partner.crt, samsung.crt and private_key.pem files in the /cert directory. Navigate to the src directory, then build and run the project. Find the details for responses and errors from the [Response] section of the documentation. # Build the project dotnet build # Run the application dotnet run Conclusion
      Now that you know how to create a new notification template using the Adding Notification Template API, you can implement it with your server if you need to generate a larger number of notification templates at once.
      Additional resources
      For more information on this topic, consult the following resources:
      Download the complete source code Official Samsung Wallet API documentation Send Push Notifications to Samsung Wallet Users Using the Send Notification API blog View the full blog at its source
    • By Samsung Newsroom
      Samsung Wallet Partners can create and update card templates to meet their business needs through the Wallet Partners Portal. However, if the partner has a large number of cards, it can become difficult to manage them using the Wallet Partners Portal website. To provide partners with more flexibility, Samsung provides server APIs so that partners can easily create and modify Samsung Wallet card templates without using the Wallet Partners Portal. With these APIs, partners can also create their own user interface (UI) or dashboard to manage their cards.
      In this article, we implement the Add Wallet Card Templates API to create a card template for a Coupon in the Wallet Partners Portal. We focus on the API implementation only and do not create a UI for card management.
      Prerequisites
      If you are new to Samsung Wallet, complete the onboarding process and get the necessary certificates. As a Samsung Wallet Partner, you need permission to use this API. Only authorized partners are allowed to create wallet card templates using this API. You can reach out to Samsung Developer Support for further assistance. API overview
      The REST API discussed in this article provides an interface to add wallet card templates directly from the partner's server. This API utilizes a base URL, specific headers, and a well-structured body to ensure seamless integration.
      URL: This is the endpoint where the request is sent to create a new wallet card template.
      https://tsapi-card.walletsvc.samsung.com/partner/v1/card/template Headers: The information provided in the headers ensures secure communication between the partner's server and Samsung's server.
      Authorization: The Bearer token. See the JSON Web Token documentation for details. X-smcs-partner-id: This is your partner ID. The partner ID gives you permission to use the API. X-request-id: Use a randomly generated UUID string in this field. Body: The body must be in the JWT token format. Convert the payload data (card template in JSON format) into a JWT token.
      For more details about the API, refer to the documentation.
      Implementation of the API to create a card template
      The Add Wallet Card Templates API allows you to add a new card template to the Wallet Partners Portal. You can also create the card in the portal directly, but this API generates a new card template from your server, without requiring you to launch the Wallet Partners Portal. Follow these steps to add a new card template.
      Step 1: Extracting the keys
      Extract the following keys from the certificates. These keys are used while generating the JWT token.
      RSAPublicKey partnerPublicKey = (RSAPublicKey) readPublicKey("partner.crt"); RSAPublicKey samsungPublicKey = (RSAPublicKey) readPublicKey("samsung.crt"); PrivateKey partnerPrivateKey = readPrivateKey("private_key.pem"); Extracting the public keys
      Use the following code to extract the partner public key and the Samsung public key from the partner.crt and samsung.crt certificate files, respectively. You received these certificate files during the onboarding process.
      private static PublicKey readPublicKey(String fileName) throws Exception { // Load the certificate file from resources ClassPathResource resource = new ClassPathResource(fileName); try (InputStream in = resource.getInputStream()) { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); X509Certificate certificate = (X509Certificate) certFactory.generateCertificate(in); return certificate.getPublicKey(); } } Extracting the private key
      The following code extracts the private key from the .pem file you generated during the onboarding process. This key is needed to build the auth token.
      private static PrivateKey readPrivateKey(String fileName) throws Exception { String key = new String(Files.readAllBytes(new ClassPathResource(fileName).getFile().toPath())); key = key.replace("-----BEGIN PRIVATE KEY-----", "").replace("-----END PRIVATE KEY-----", "").replaceAll("\\s", ""); byte[] keyBytes = Base64.getDecoder().decode(key); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(keyBytes)); } Step 2: Generating the authorization token
      Samsung's server checks the authorization token of the API request to ensure the request is from an authorized partner. The authorization token is in the JWT format. Follow these steps to create an authorization token:
      Building the auth header
      Create an authHeader. Set “AUTH” as its payload content type to mark it as an authorization token. As you can create multiple certificates, use the corresponding certificate ID of the certificate that you use in the project. You can get the certificate ID from “My account > Encryption Management” of the Wallet Partners Portal.
      // create auth header JSONObject authHeader = new JSONObject(); authHeader.put("cty", "AUTH"); authHeader.put("ver", 3); authHeader.put("certificateId", certificateId); authHeader.put("partnerId", partnerId); authHeader.put("utc", utcTimestamp); authHeader.put("alg", "RS256"); Creating the payload
      Create the payload using the authHeader. Follow this code snippet to create the payload.
      // create auth payload JSONObject authPayload = new JSONObject(); authPayload.put("API", new JSONObject().put("method", "POST").put("path", "/partner/v1/card/template")); authPayload.put("refId", UUID.randomUUID().toString()); Building the auth token
      Finally, generate the authorization token. For more details, refer to the “Authorization Token” section of the Security page
      private static String generateAuthToken(String partnerId, String certificateId, long utcTimestamp, PrivateKey privateKey) throws Exception { // create auth header // create auth payload // return auth token return Jwts.builder() .setHeader(authHeader.toMap()) .setPayload(authPayload.toString()) .signWith(privateKey, SignatureAlgorithm.RS256) .compact(); } Step 3: Generating a payload object token
      The request body contains a parameter named “ctemplate” which is a JWT token. Follow these steps to create the “ctemplate.”
      Creating the card template object
      Select the proper card template you want to create from the Card Specs documentation. Get the payload object as JSON format. Now create the JSONObject from the JSON file using the following code snippet.
      // creating card template object JSONObject cDataPayload = new JSONObject(); cDataPayload.put("cardTemplate", new JSONObject() .put("prtnrId", partnerId) .put("title", "Sample Card") .put("countryCode", "KR") .put("cardType", "coupon") .put("subType", "others") .put("saveInServerYn", "Y")); Generating the JWE token
      Create the JWE token using the following code snippet. For more details about the JWE format, refer to the “Card Data Token” section of the Security page.
      // JWE payload generation EncryptionMethod jweEnc = EncryptionMethod.A128GCM; JWEAlgorithm jweAlg = JWEAlgorithm.RSA1_5; JWEHeader jweHeader = new JWEHeader.Builder(jweAlg, jweEnc).build(); RSAEncrypter encryptor = new RSAEncrypter((RSAPublicKey) samsungPublicKey); JWEObject jwe = new JWEObject(jweHeader, new Payload(String.valueOf(cDataPayload))); try { jwe.encrypt(encryptor); } catch (JOSEException e) { e.printStackTrace(); } String payload = jwe.serialize(); Building the JWS header
      Next, follow this code snippet to build the JWS header. Set “CARD” as the payload content type in this header.
      // JWS Header JWSHeader jwsHeader = new JWSHeader.Builder(JWSAlgorithm.RS256) .contentType("CARD") .customParam("partnerId", partnerId) .customParam("ver", 3) .customParam("certificateId", certificateId) .customParam("utc", utcTimestamp) .build(); Building the JWS token
      Generate the JWS token from the previously generated JWE token and, finally, get the “ctemplate” JWT. Follow the “JWS Format” section of the Security page.
      private static String generateCDataToken(String partnerId, PublicKey partnerPublicKey, PublicKey samsungPublicKey, PrivateKey partnerPrivateKey, String certificateId, long utcTimestamp) throws Exception { // creating card template object // JWE payload generation // JWS Header // JWS Token generation JWSObject jwsObj = new JWSObject(jwsHeader, new Payload(payload)); RSAKey rsaJWK = new RSAKey.Builder((RSAPublicKey) partnerPublicKey) .privateKey(partnerPrivateKey) .build(); JWSSigner signer = new RSASSASigner( ); jwsObj.sign(signer); return jwsObj.serialize(); } Step 4: Building the request
      As all of the required fields to create the request have been generated, you can now create the request to add a new template. Follow the code snippet to generate the request.
      private static Request buildRequest(String endpoint, String partnerId, String requestId, String authToken, String cDataToken) { // Prepare JSON body JSONObject cDataJsonBody = new JSONObject(); cDataJsonBody.put("ctemplate", cDataToken); RequestBody requestBody = RequestBody.create( MediaType.parse("application/json; charset=utf-8"), cDataJsonBody.toString() ); // Build HTTP Request Request request = new Request.Builder() .url(endpoint) .post(requestBody) .addHeader("Authorization", "Bearer " + authToken) .addHeader("x-smcs-partner-id", partnerId) .addHeader("x-request-id", requestId) .addHeader("x-smcs-cc2", "KR") .addHeader("Content-Type", "application/json") .build(); return request; } Step 5: Executing the request
      If the request is successful, a new card is added to the Wallet Partners Portal and its “cardId” value is returned as a response.
      private static void executeRequest(Request request) { // Execute HTTP Request try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { System.out.println("Wallet Card Template added successfully: " + response.body().string()); } else { System.out.println("Failed to add Wallet Card Template: " + response.body().string()); } } } Implement as a server
      At this point, you can add a webpage UI for creating card templates and deploy it as a web service. In this sample project, there is no UI added. But, you can deploy this sample as a web service and test it.
      Conclusion
      This tutorial shows you how you can create a new Samsung Wallet card template directly from your server by using a REST API. Now that you can implement the API, you can add a UI and make it more user-friendly. Also implement the Updating Wallet Cards Templates API for better card management.
      References
      For additional information on this topic, refer to the resources below:
      Sample project code. Business Support for Special Purposes documentation. View the full blog at its source
    • By Samsung Newsroom
      Advancements in medical research and technology are transforming the pharmaceutical industry by accelerating drug development, enabling personalized medicine, and enhancing patient care through AI, big data, and advanced diagnostics.
      Samsung Health collects and analyzes valuable health data from users’ daily activities. Using sensors in Galaxy smartphones and wearables, it tracks fitness activities, sleep cycles, nutrition, and more. When combined, this data offers a comprehensive, data-driven view of an individual’s overall health. When studied in depth, these insights can serve as a crucial resource for researchers, helping them better understand health conditions and explore how pharmaceutical interventions can improve wellness.
      One key area of study is sleep disturbances, a common and disruptive symptom among menopausal women. However, the causes of these disturbances remain insufficiently understood, and existing sleep aids often prove ineffective. To bridge this knowledge gap, Samsung Health has partnered with Bayer to conduct an observational study on sleep disturbances in menopausal women.
      With access to one of the world’s largest collections of biometric data from wearable devices, Samsung is uniquely positioned to enhance research in women's health with real-world evidence. By analyzing sleep patterns, heart rate variability, and overall well-being, Samsung Health can help Bayer gain deeper insights into women's health, enabling the development of targeted and meaningful treatment options at various life stages. This research aims to expand treatment options and improve sleep solutions for those experiencing menopause-related sleep issues.
      Technology plays a vital role in advancing clinical studies and medical research by providing real-time data and analytics from everyday activities, ultimately shaping better health outcomes.
      View the full blog at its source
    • By Shashank Suryavanshi
      Hi, I've developed the Tizen app using the web and now after building it, the build is created in wgt format.
      I want to install the build directly on Samsung Tv so that I can test the app there once.
      I've already created the certificates and it's also verified by the Tizen team.
      Now, when I tried to connect the SamsungTv with Tizen using the Device Manager I'm getting these following errors
      The remote device is already connected by another one. This remote device is running on a non-standard port or There is no IP address, please check the physical connection What I've done?
      I opened the developer mode of Samsung tv and updated the IP address with my system IP address and in the device manager I added all the details what was required and after clicking on add button then I faced the above errors.
      Can anyone help me like how can we either create the build in .tmg format because Usb demo packaging tool is not supported now.  Or how can I connect the SamsungTv with Tizen Studio using the Device Manager. 
      I've read and went through the documentation from official site still I face this issue.
    • Government UFO Files





×
×
  • Create New...