Quantcast
Jump to content

Integration of Samsung IAP Services in Android Apps


STF News
 Share

Recommended Posts

2021-03-08-01-banner.jpg

Selling digital content is a popular business all over the world. If you are interested in selling your digital items in the Samsung ecosystem, then you need to learn about the Samsung In-App Purchase (IAP) SDK. You can implement Samsung IAP in your Android, Unity, and Unreal Applications.

Since server to server communication is more secure and reliable, payment transaction should be verified from the IAP server. This is the second of two blogs on this topic. In the first part, we discussed how to integrate Samsung’s IAP server API into your app’s server. In this blog, we will learn how to communicate with your server through an Android app.

Please go through the documentation of Samsung IAP SDK to integrate Samsung IAP SDK in your app. Then build your own app server for server verification which is covered in the first part of this blog. To know about server API, read Samsung IAP Server API.

Get Started

Let’s learn through a simple Android game. This game has an item which can only be used for a certain period of time. So, it is a subscription type item. If a user buys this item, then the item will be available after purchase verification.

When the app is launched, the app checks if this item is already subscribed or not. There can be one of two results:

  • The item is not subscribed, then the app offers to subscribe this item.
  • The item is subscribed then the app gets the current status of this subscription through getSubscriptionStatus Server API. The subscription status can be active or cancel. Subscription can be canceled for various reasons. If the IAP server returns the subscription status as ‘cancel’ then the app notifies it to the user.

Implementation of these two cases are discussed in the next sections.


2021-03-08-01-01.jpg

Implement Android IAP

At first, integrate Samsung IAP SDK in your Android app and register it in the seller office to test In-App items. When the app is launched, call getOwnedList() API. It returns a list of in-app items that the app user currently has from previous purchases. If the item is not in this list, then the app offers to purchase the item.

To purchase any item, call startPayment(). This API notifies the end user if the purchase succeeded or failed. If the purchase is successful, then do the server verification. If your app’s server validates the purchase, then make the item available to the user, otherwise request user to purchase it again.

public void onPayment(ErrorVo _errorVo, PurchaseVo _purchaseVo) {
    if (_errorVo != null) {
        if (_errorVo.getErrorCode() == IapHelper.IAP_ERROR_NONE) {
            if (_purchaseVo != null) {
                if (mPassThroughParam != null && _purchaseVo.getPassThroughParam() != null) {
                    if (mPassThroughParam.equals(_purchaseVo.getPassThroughParam())) {
                        if (_purchaseVo.getItemId().equals(ITEM_ID_SUBSCRIPTION)) {
                            mMainActivity.setBackgroundPurchaseId(_purchaseVo.getPurchaseId());
                            new PurchaseVerification(mMainActivity).execute(_purchaseVo.getPurchaseId());
                        }
                    } 
                }
            } 
         }
     }
}

If the item is available in this list, then detailed information of this item such as purchase ID will be available in the OwnedProductVo type ArrayList. To call getSubscriptionStatus Server API, we need the purchase ID of the item. So, send this ID to your app’s server to get the status of the subscribed item.

public void onGetOwnedProducts(ErrorVo _errorVo, ArrayList<OwnedProductVo> _ownedList) {
        if (_errorVo != null) {
            if (_errorVo.getErrorCode() == IapHelper.IAP_ERROR_NONE) {
                if (_ownedList != null) {
                    for (OwnedProductVo item : _ownedList) {
                        if (item.getItemId().compareTo(ItemName.ITEM_ID_SUBSCRIPTION) == 0) {
                            // Check whether subscription is canceled or not.
                            new SubscriptionDetails(mMainActivity).execute(item.getPurchaseId());
                        }
                    }
                }
            } else {
                Log.e(TAG, "onGetOwnedProducts ErrorCode [" + _errorVo.getErrorCode() +"]");
            }
        }
    }

Connect Your App with Your App Server

Create an asynchronous task for communicating with the server. This task has two parts. One is to send purchase ID to your app server and the other is to receive the result from the app server. Use doInBackground() method for these two tasks. Return this result to your main UI through onPostExecute() method.

Create a class which extends AsyncTask<String,Void,String> for server verification. Then write the following code in doInBackground() method to send the purchase ID:

CookieHandler.setDefault( new CookieManager( null, CookiePolicy.ACCEPT_ALL ) );
try{
   URL url = new URL("http:// "); //URL of your app’ server
   URLConnection connection = url.openConnection();
   connection.setDoOutput(true);
   connection.setDoInput(true);
   OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(); 
   String y = "";
   for(int i = 0;i < x.length;i++)
   {
        y = y + x[i];
   }
   out.write(y);
   out.close();
   }catch(Exception e){ 
   }

Receive to the server verification result using the following code:

String output = "";
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String s = "";
while((s = in.readLine())!= null)
{
       output = output + s;
       in.close();
}
return output;    

Now, create an Interface called ServerResponse and implement it in an Activity where you want to show the result from your app’s server.

public interface ServerResponse {
    void processFinish(String output);
}

After receiving the result from the server, return the result to your main UI through onPostExecute() method.

protected void onPostExecute(String result) {
    serverresponse.processFinish(result);
}

Test your app

Let’s test the app. Upload your web app onto a server. Then use that URL in your app to check server verification in doInBackground() method. Keep in mind that Samsung In-App Purchase can’t be tested in an emulator of Android Studio. So use a Samsung device to test your app. Read the Test Guide before starting to test your app. A simple Android game is attached at the end of this article where app to server communication is implemented.

This game has a blue background image which can be subscribed. If this item is not in an active subscription period, then the app offers to subscribe the background. If the user purchases the item, then the game verifies the purchase through the server. If the purchase is verified, then it shows that the subscription status is activated and the app makes the item available. If the user unsubscribes the item from the Galaxy Store, subscription status becomes ‘cancel’. However, as the active subscription period has not ended yet, the item is still available in the app.


2021-03-08-01-02.jpg
2021-03-08-01-03.jpg
2021-03-08-01-04.jpg

Wrapping Up

In these two blogs, we have covered the full communication between your app, server and IAP server. Now you will be able to implement purchase verification through your server. If your app is free but has some premium contents, then you can monetize your app. Samsung In-App Purchase provides many ways to earn money from your app. Go to Galaxy Store Games to find out more details about it.

Follow Up

This site has many resources for developers looking to build for and integrate with Samsung devices and services. Stay in touch with the latest news by creating a free account or by subscribing to our monthly newsletter. Visit the Marketing Resources page for information on promoting and distributing your apps. Finally, our developer forum is an excellent way to stay up-to-date on all things related to the Galaxy ecosystem.

View the full blog at its source

Link to comment
Share on other sites



  • 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...
 Share

  • Similar Topics

    • By STF News
      The Art Store of Samsung Electronics’ The Frame is the epitome of the digital-physical blend taking over today’s art experiences, allowing widely acclaimed galleries, museums and artists to showcase their masterpieces to users around the world by harnessing The Frame’s immaculate digital display to emulate the experience of a physical exhibition.
       
      Melanie Mikecz, a mixed-media artist and illustrator based in San Francisco, U.S., is taking these experiences to new heights with her combinations of naturally-occurring patterns with hyperbolic expressions to masterfully blend the worlds of painting and graphic design for art fans of all ages.
       
      In order to learn more about how technology is helping Mikecz create art that inspires artists and enthusiasts alike, Samsung Newsroom sat down with her to learn more about her creative journey.
       
      ▲ Melanie Mikecz
       
       
      Q: You specialize in a digital mixed media style that charms children and adults alike. What inspires your work?
       
      I have a background in both painting and graphic design. I found that combining painted elements and new technology gives me the most artistic freedom. I am not limited by the constraints of traditional media, but at the same time, my work has more texture and depth than digital media alone.
       
      I have always been inspired by naturally-occurring patterns and vibrant color palettes. However, I do always like to add a twist to my work. Whether that is by exaggerating the color or by creating an imperfect pattern. Now that I have children, I am also influenced by their interests and aesthetics.
       
       
      Q: Was your original intention when creating art to appeal to all ages? Or has that been a natural, organic reaction to your work?
       
      I don’t know that I consciously sought to create art for all ages. Rather I enjoyed making art that was vibrant and a little funky. I’ve always liked drawing animals and creatures, so that tends to appeal to children. My more abstract work is geared more towards adults. However, I think there is a lot of crossover between the two styles.
       
      My Art Store collection for The Frame has bright palettes and imaginative creatures that charm children. At the same time, I think many adults will enjoy adding some color and energy to their living spaces through my work.
       
       
      Q: What do you think of the Art Store as a piece of technology to include within the households of children? 
       
      I would imagine that the Art Store positively affects children’s development as it introduces them to a rotating gallery of art. By periodically swapping out the art on The Frame, children are presented with a variety of artists, styles and subjects. I think this can both inspire children’s own creativity and start bigger conversations.
       
       
      Q: As you said, your illustrations are known for their vibrant color expression. How does The Frame display that aspect of your art?
       
      The Frame displays color better than traditional print media, so my artwork is much more vibrant on its screen than on paper or canvas. The texture of my work also comes through nicely on The Frame. Furthermore, its function as a digital display allows for my work to get in front of a wider audience.
       
       
      Q: What made you decide to work with digital art platforms, such as Etsy and The Frame’s Art Store?
       
      I have been marketing my work on Etsy for years since it is a great way to sell my art directly to the consumer. When I first heard about The Frame, I thought it was such an innovative concept. So, when Etsy and Samsung approached me to share my work this way, I was eager to get involved.
       
       
      Q: What has been your favorite piece of your own to be displayed on The Frame? Why?
       
      My piece Enchanted Sea is one of my favorites because it bridges the gap between abstract art and illustration. The cool color palette of this piece has a modern, beachy vibe.
       
      ▲ “Enchanted Sea”, Melanie Mikecz
       
       
      Q: How does showcasing your work on a digital platform like the Art Store mutually benefit art enthusiasts and consumers alike?
       
      First of all, using The Frame to display art when not watching television is so much nicer than simply having an empty black box on the wall. I also think that it is super fun to be able to swap out the art being displayed depending on your current mood, the season, your vibe or another reason. For example, my piece Sea Turtle Swim might be displayed during warm weather or when you are dreaming of a beach vacation.
       
      ▲ “Sea Turtle Swim”, Melanie Mikecz
       
      However, my piece called Mountain Adventure by the Sea might be more fittingly displayed during winter.
       
      ▲ “Mountain Adventure by the Sea”, Melanie Mikecz
       
      This collaboration with Samsung and the Art Store is also the first time that I have worked with a partner to display my work only digitally. I appreciate the time taken to curate the collections on the Art Store and how diligently credit is given to the artist. The way art is carefully selected and displayed means that the Art Store has the sophistication of a museum collection.
       
       
      Q: Ultimately, where do you see the future of art exhibition headed?
       
      In the future, protecting the artist’s intellectual property will continue to be a focus. I also envision that we will see smaller displays much like The Frame all throughout the home, as well as more prominent digital-based displays in the broader world as digital art exhibitions become more popular.
       
      To see more of Mikecz’s art pieces, including Enchanted Sea, be sure to head to the Art Store on Samsung’s The Frame.
      View the full article
    • By STF News
      With the ever-growing popularity and accessibility of social video platforms, today, anyone can become a creator. To grow their platforms, new creators are choosing professional-grade editing programs and hardware to produce exciting content and increase subscribers. As a result, the demand for high-quality monitors is skyrocketing.
       
      According to Markets & Research, the global Professional Monitors market size was estimated to be worth $104.86 million in 2021 and is forecasted to be $149.21 million by 2028.
       
      If you’re looking to break into content creation, use the following checklist when picking your next monitor.
       
       
      # Want To Be a Content Creator? Here Is How To Pick The Perfect Monitor

       
       
      # Not Familiar With The Terminology Yet? This Guide Will Help You
      Looking to choose a new monitor for content creation? Don’t let unfamiliar jargon put you off. Let’s take a deep dive into the world of monitors.
       
      1. DCI-P3: Reproducing accurate colors from shot to screen
       

       
      DCI-P3, the triangle highlighted on the colorful diagram, constitutes a range of colors that can be presented on a given display, such as a monitor. Simply put, they use figures to indicate the extent of a display’s color handling capabilities. This is why it is called a color gamut, because gamut means a full scope or range of something.
       
      Color standards vary by institutes depending on the purpose and criteria of the color gamut. Classic examples include DCI-P3, sRGB and Adobe RGB. The triangle refers to a percentage of the visible spectrum on a display based on each color standard.
       
      sRGB Adobe RGB DCI-P3 – sRGB is a standard RGB color space that Microsoft and HP created cooperatively in 1996 to use on monitors and printers.  
      – Developed by Adobe in 1998, Adobe RGB was designed to express digital color for photo.  
      – DCI-P3 was created by Digital Cinema Initiatives to efficiently express color for a digital projector.  
      – sRGB covers just 33.3% of visible colors. – It is commonly used for design and photo editing. – It is widely used in HDR content. DCI-P3 presents a more optimized color space for digital videos.
       
      To find the best monitor for video content creation, you need to check a monitor’s color gamut. It is essential to display your video as intended without color distortion, whether on a computer or mobile device. Make sure the monitor supports ‘DCI-P3’ if you often edit videos.
       
      2. HDR: Selecting a monitor that provides incredible contrast and accentuates details
       

       
      Customers are good at intuitively picking up on the quality of a display, so the ability to deliver life-like picture quality is just as crucial as accurate color reproduction.
       
      HDR (High Dynamic Range) refers to a technology that delivers true-to-life pictures by delicately adjusting brightness. You can assess HDR performance based on VESA DisplayHDR ratings created by VESA. VESA Certified DisplayHDR guarantees a display’s quality, allowing you to enjoy the best HDR experience.
       
      VESA assigns a number grade representing peak brightness on certified monitors. In other words, the larger the number, the wider the range of brightness a monitor can express.
       
      As VESA Certified DisplayHDR guarantees a display’s quality, it is highly recommended that serious creators invest in a product that is DisplayHDR 400-verified, or higher. This will enable you to enjoy the best HDR experience possible.
       
      3. Matte Display: Avoiding bright light without installing unnecessary accessories
       
      Content creators can often be disrupted by glare or reflection on their monitors. It is crucial for creators to work on a screen that delivers consistency in all environments regardless of external lighting factors. Bright lights or changes in monitor angle can cause color distortions detrimental to overall content quality, which is why many editors now use monitor hoods while working.
       

       
      However, installing a hood to prevent glare and reflection can undermine work productivity since it is difficult to adjust a monitor’s angle or height. ViewFinity S8 solves such inconveniences by adopting the Matte Display to minimize glare. Low Reflection Film, Samsung’s proprietary technology that reduces glare and reflection, helps you check content even under bright light regardless of angle. As such, ViewFinity S8 received the world’s first UL1 Verification for Glare Free.
       
       
      # Samsung ViewFinity S8, The Best Choice for Content Creators

       
       
      1 UL, LLC is a global safety certification company that determines standards for safety, security and sustainability.
      View the full article
    • By STF News
      With the ambition of ‘the value of infinite viewing experience’, ViewFinity, Samsung’s high resolution monitor lineup will allow creative professionals including designers and content creators to improve their work productivity.
       
      ViewFinity S8 (Model: S80PB), a new monitor specialized for creative professionals delivers accurate colors as intended with a wide color gamut up to 98% of DCI-P3 and UHD resolution. Matte Display is applied on the top of the panel, reducing light reflection. This allows you to create content with vibrant color reproduction and brightness and prevent any distortions. Furthermore, ViewFinity features ergonomic design to offer more comfortable user experience during extended use.
       
      With innovation in technology and performance, Samsung ViewFinity, as a new benchmark of high resolution monitors for creators, will provide a comfortable user experience and productive working environment. You can check out the infographic below to learn more about ViewFinity S8’s exciting features.
       

      View the full article
    • By STF News
      △ Hyesung Ha, Executive Vice President of Visual Display Business at Samsung Electronics
       
      Last month I had the opportunity to travel to Barcelona, Spain to attend Integrated Systems Europe (ISE) for the first time in two years. It reminded me that the world is returning to routines and norms. At the same time, it will be a fundamentally different world moving forward.
       
      I can also apply these observations to Samsung’s digital signage business. In 2022 and beyond, Samsung will deliver a variety of solutions that were and still are important to businesses today, as well as new technologies designed to meet the needs of the modern world.
       
      It’s clear that we will never fully return to what we used to think of as “normal” life. We’ve already reimagined offices, classrooms, entertainment and so much more within our daily routines. It’s my job not only to keep up with these trends, but to fundamentally reimagine the role of digital signage moving forward. That’s why Samsung is focused on redefining our most common spaces, reconnecting the world through new experiences and re-emphasizing the importance of digital signage in our daily lives.
       
       
      Redefining Learning and Collaboration in a New Era
      One of the largest shifts of the past few years is the role technology plays within common environments such as classrooms in schools and meeting rooms in offices. These environments saw an increasing demand for digital transformations and now new considerations are required to ensure every student and professional has the same high-quality collaboration experience regardless of whether they attend in-person, online, or in a hybrid manner. In other words, learning and collaboration spaces have been redefined with an increased emphasis on inclusivity in any scenario.
       

       
      Samsung is addressing this need with the new Samsung Flip Pro. It provides students and professionals with high-quality collaboration experiences whether they are in-person or remote with enhanced usability and specialized features to meet ever-changing business and education needs. With a focus on seamless and intuitive interactions, it’s easy to set up and easy to use. The newly added intuitive control panel enhances the overall classroom or meeting room experience along with the industry’s fastest touch latency, enhanced multi touch features and the ability to simultaneously connect devices to the display wirelessly for enhanced collaboration.
       
       
      Reconnecting Through New Outdoor Experiences
      As consumers return to public shopping malls, sporting events and other forms of entertainment, businesses are competing now more than ever for their attention. With more outdoor activities, signage has become a bridge between consumers and brands while helping people enjoy digital art. In other words, signage reconnects consumers with the world.
       
      LED signage also creates unforgettable experiences inside sports stadiums. Delivering the best viewing angles for fans was one of Samsung’s highest priorities. As part of these efforts, Samsung designed the largest videoboard ever created for sports, the Infinity Screen in SoFi Stadium as a part of the Hollywood Park Technology Alliance. Measuring 70,000 square feet, the incredible curved, 360-degree, dual-sided screen greets fans and provides a state-of-the-art way to experience the game.
       

       
      Another trend where we see a major opportunity for growth is the electric vehicle industry. As demand for electric vehicles surges, carmakers, governments and local businesses are rushing to build more electric vehicle charging stations. This provides a new outlet to serve information and deliver promotions to electric vehicle owners, and Samsung outdoor signage is the perfect solution for this scenario. With ultra-bright picture quality and durability with certified IP56-rated protection, the outdoor signage can excel in a variety of weather conditions and environments, hence businesses can create engaging visual experiences while customers top up their batteries in charging stations.
       
       
      Re-emphasize the Vision of ‘Screens Everywhere’ With Unmatchable Micro LED Technology
      Micro LED technology is set to define the future of display innovation. From the luxury industry to hospitality and travel, the potential of Micro LED is endless. The Wall is Samsung’s state-of-the-art display technology, which features even more options for businesses looking to transform their spaces with next level picture quality and immersion.
       
      Samsung is the leader in Micro LED displays, which contain smaller LEDs, and allow greater LED density, enabling brighter and more detailed color expression inside a slimmer display profile. To create our industry-leading Micro LED technology, we have focused on three key areas: Samsung developed fully integrated ultra-fine Micro LED chips; such densely populated LEDs result in stunning brightness; and we continue to secure processing know-how for ultra-fine semiconductor chips to improve mass production.
       

       
      These unparalleled technologies helped Samsung’s 2022 lineup of The Wall (IWB) open up new possibilities. The micro pitch feature of the IWB delivers the most detailed picture with 0.63 pixel pitch, the slimmest ever, in addition to providing a variety of screen sizes to meet any consumer or business need. Meanwhile, The Wall All-in-One (IAB) has transformed the installation process with a pre-adjusted seam and a ‘Pre-Assembled Frame Kit’ which makes the whole process as simple as a consumer TV. The Wall All-in-One not only saves valuable time but also lowers the total cost of ownership while delivering a better viewing experience.
       
      In a constantly changing world, Samsung will continue to deliver breakthrough innovations to realize the vision of “Screens Everywhere” based on industry-leading Micro LED technology.
       
       
      Reimagining the Role of Digital Signage
      As an industry leader in the global signage market for the past 13 consecutive years,1 we will continue to expand our sustainability efforts by creating products that can reduce carbon emissions and contribute to resource circulation.
       
      Our digital signage solutions, including the 2022 Smart Signage, have received certified energy efficiency grades that rise to new industry standards, such as ENERGY STAR and EPEAT. Samsung also has incorporated eco-conscious packaging featuring recycled materials in all signage products since 2021 and became the first business in the industry to achieve the reducing CO2 label, certified by the Carbon Trust for its display portfolio.
       
      In recognition of our eco-conscious efforts for our sustainability initiative, we won the ‘Sustainability Innovation of the Year’ at the AV News Awards in ISE. As we are grateful for the recognition of our efforts, we plan to make each step count while we collectively change production practices for a sustainable future.
       

       
      The return to routines combined with new customer expectations and habits provides businesses with a rare opportunity to reimagine their offerings and practices. By considering a new role for digital signage moving forward, we’re helping our customers reimagine what’s possible to keep them ahead of the curve.
       
      I’m excited for this next chapter for digital signage. At Samsung, we’re passionate about bringing game-changing innovation and value to our enterprise customers. We will continue to innovate, reimagining the role of digital signage in new and conventional spaces, all while increasing our customers’ possibilities in this new era.
       
       
      1 Samsung has been the No.1 selling digital signage brand for 13 consecutive years by Omdia. (Note: Consumer TVs, along with Commercial Lite and Hospitality TVs used for signage are excluded.)
      View the full article





×
×
  • Create New...