npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

com.taptap.tds.payments.global.v2

v4.0.4

Published

TapTap Develop Service

Downloads

546

Readme

Environment Requirements

  • Supports Unity 2019.4 or higher.

Getting Ready

  • Refer to Before You Start to create an app, enable app configuration, and bind API domains;
  • Refer to TapSDK Quickstart to configure package name and signature certificate;

Getting the SDK

External Dependency Manager for Unity(EDM4U)

Tap payment depends on EDM4U to handle android dependency.

install via OpenUPM

EDM4U is available via OpenUPM, you can add it via Edit -> Project Settings -> Package Manager

alt text

local UPM Package

You can also download UPM version from Google APIs for Unity. And install as a local file

TapPayment SDK

Payment SDK is available via NPMJS, you can add it via Edit -> Project Settings -> Package Manager

alt text Then you will be able to install Taptap Payment Global V2 from Window -> Package Manager

alt text

Android Dependency

EDM4U will automatically monitor Android dependency introduced by TapPayment SDK, but under some circumstances the auto resolve can fail. You can always go to Assets -> External Dependency Manager -> Android Resolver -> Force Resolve to force resolving dependencies. Please make sure com.taptap.android.payment:unity is successfully added as dependency to mainTemplate.gradle, if this is not done by the EDM4U you can also add this manually.

SDK Guide

We provide a new store implementation for the Unity IAP flow, which requires minmal changes if your game already have an IAP flow with Google Play or App Store. If you are implementing IAP for the first time, we will briefly cover the IAP flow and you can always find more details on Unity Documentation

Initialize Unity Gaming Services

Call UnityServices.InitializeAsync() to initialize all Unity Gaming Services at once. It returns a Task that enables you to monitor the initialization's progression.

using System;
using Unity.Services.Core;
using Unity.Services.Core.Environments;
using UnityEngine;

public class InitializeUnityServices : MonoBehaviour
{
    public string environment = "production";

    async void Start()
    {
        try
        {
            var options = new InitializationOptions()
                .SetEnvironmentName(environment);

            await UnityServices.InitializeAsync(options);
        }
        catch (Exception exception)
        {
            // An error occurred during services initialization.
        }
    }
}

Initialize IAP

Make sure you add TapPurchasingModule and set the correct clientId and clientToken in the config.

using UnityEngine;
using UnityEngine.Purchasing;
using TapTap.Payments.Global.V2;

public class MyIAPManager : IStoreListener {

    private IStoreController controller;
    private IExtensionProvider extensions;

    public MyIAPManager () {
        var builder = ConfigurationBuilder.Instance(
            TapPurchasingModule.Instance, 
            StandardPurchasingModule.Instance);
        builder.Configure<ITapConfiguration>().SetClientId("Your Client ID Here");
        builder.Configure<ITapConfiguration>().SetClientToken("Your Client Token Here");
        builder.AddProduct("100_gold_coins", ProductType.Consumable, new IDs
        {
            {"100_gold_coins_google", GooglePlay.Name},
            {"100_gold_coins_mac", MacAppStore.Name}
        });

        UnityPurchasing.Initialize (this, builder);
    }

    /// <summary>
    /// Called when Unity IAP is ready to make purchases.
    /// </summary>
    public void OnInitialized (IStoreController controller, IExtensionProvider extensions)
    {
        this.controller = controller;
        this.extensions = extensions;
    }

    /// <summary>
    /// Called when Unity IAP encounters an unrecoverable initialization error.
    ///
    /// Note that this will not be called if Internet is unavailable; Unity IAP
    /// will attempt initialization until it becomes available.
    /// </summary>
    public void OnInitializeFailed (InitializationFailureReason error)
    {
    }

    /// <summary>
    /// Called when a purchase completes.
    ///
    /// May be called at any time after OnInitialized().
    /// </summary>
    public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
    {
        return PurchaseProcessingResult.Complete;
    }

    /// <summary>
    /// Called when a purchase fails.
    /// </summary>
    public void OnPurchaseFailed (Product i, PurchaseFailureReason p)
    {
    }
}

Launch Purchase Flow

Once IAP is successfully initialized, you can now start purchase flow using IStoreController.InitiatePurchase

// Example method called when the user presses a 'buy' button
// to start the purchase process.
public void OnPurchaseClicked(string productId) {
    controller.InitiatePurchase(productId);
}

Processing Purchases

The ProcessPurchase function of your store listener is called when a purchase completes. Your application should fulfil whatever the user has bought; for example, unlocking local content or sending purchase receipts to a server to update a server-side game model.

A result is returned to indicate whether or not your Application has finished processing the purchase:

Note that ProcessPurchase may be called at any point following a successful initialization. If your application crashes during execution of the ProcessPurchase handler, then it is invoked again the next time Unity IAP initializes, so you may wish to implement your own additional de-duplication.

Reliability

Unity IAP requires explicit acknowledgement of purchases to ensure that purchases are reliably fulfilled in the event of network outages or application crashes. Any purchases that complete while the application is offline will be sent to the application on next initialization.

Completing purchases immediately

When PurchaseProcessingResult.Complete is returned, Unity IAP finishes the transaction immediately (as shown in the diagram below).

You must not return PurchaseProcessingResult.Complete if you are selling consumable products and fulfilling them from a server (for example, providing currency in an online game).

If you do, there is a risk that consumable purchases will be lost if your Application is uninstalled before the cloud save takes place.

alt text

Saving purchases to the cloud

If you are saving consumable purchases to the cloud, you must return PurchaseProcessingResult.Pending and call ConfirmPendingPurchase only when you have successfully persisted the purchase.

When returning Pending, Unity IAP keeps transactions open on the underlying store until confirmed as processed, ensuring consumable purchases are not lost even if a user reinstalls your application while a consumable is in this state.

alt text