Version: 5.5
Tizen store
스토어 구현

CloudMoolah store

샘플 구현

See the sample IAPDemo scene and script in the default Unity IAP installation.

Initialization

Initialization requires first configuring the appKey and hashKey using the IMoolahConfiguration interface.

설정 API

Unity IAP supports pre-initialization store-specific API through a configuration mechanism. Acquire the IMoolahConfiguration interface instance for CloudMoolah through the ConfigurationBuilder.Configure<IMoolahConfiguration>() in Purchasing.ConfigurationBuilder.Configure Scripting API.

Secret appKey

구문

string IMoolahConfiguration.appKey

설명

  • 초기화하기 위해 필요합니다.

  • 게임을 고유하게 식별합니다.

  • Apply for this on the Cloud Moolah Developer Portal.

  • Set before Initialize is called.

예제

var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

builder.Configure<IMoolahConfiguration>().appKey = "54ad14a8a350e0a71d4764ae9825fc0e";

Secret hashKey

구문

string IMoolahConfiguration.hashKey

설명

  • 초기화하기 위해 필요합니다.

  • Apply for this on the Cloud Moolah Developer Portal.

  • Uniquely identifies the game, and is defined by developer.

  • Set before Initialize is called.

예제

var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

builder.Configure<IMoolahConfiguration>().hashKey = "asdfasdfadsfsadcok-test-a-d";

확장자 API

Unity IAP supports additional store-specific API through an extension mechanism. Acquire the IMoolahExtension interface instance for CloudMoolah through the IExtensionProvider interface return by the IStoreListener.OnInitialized API, for example Unity IAP Initialization and Restoring Transactions.

구매 선행 조건: 등록 및 로그인

CloudMoolah requires establishing per-user identification to create and access a user’s digital wallet. The CloudMoolah wallet collects real currency from pre-paid cards and SMS payments. Currency in the wallet is then used during the payment process. CloudMoolah requires user identification through registration and login in order to access the user’s wallet.

This identification process can be performed invisibly to the user by an application that registers and logs in using computer-generated credentials or by sharing previously created credentials from a third-party identity service.

For example, standalone or offline games may not have access to an identity service from a game developer or publisher. In this case generating credentials may be suitable. One could register using the result of Unity’s SystemInfo.deviceUniqueIdentifier API, supplying this as the user identifying “password” (Note: using this API automatically adds the android.permission.READ_PHONE_STATE to an Android application’s manifest).

Another example is online games, which may have an online identity service available to them through their game server. In this case, copying a user-identifying credential as the registration password is appropriate.

Note: The registration password must remain constant over the lifetime of the user account, serving as a permanent access token for this user’s wallet.

Purchasing requires a successful login, which requires a user to register in turn.

This Registration API is lighter in that a user only needs to provide a single password. This creates the digital wallet. Registration will also generate a “username” which is passed back to the client and must be used for the next step - login.

Login must be performed once per session. Logging in requires the generated username and user-identifying password. After the user is logged in, they may add money to the wallet through the Moo Store’s supported payment providers, and purchases can be attempted.

For users to permanently bind a wallet to an email address, they may supply additional identifying credentials such as a phone number to the Cloud Moolah web service during the purchase process on their Android device.

디지털 지갑 등록

구문

void IMoolahExtension.FastRegister(string CMpassword, Action<string> registerSuccessed, Action<FastRegisterError, string> registerFailed)

파라미터

  • CMpassword: User-defined password for signing up with the Cloud Moolah user system.

  • registerSuccessed: Passes (string cmUserName) on successful fast registration.

  • registerFailed: 빠른 등록에 실패하면 오류 코드와 문자열 설명을 전달합니다.

설명

  • 구매를 위해 필요합니다.

  • Lightweight registration with Cloud Moolah wallet. Returns a Cloud Moolah generated username. User can later perform full registration in the Cloud Moolah purchasing web service to permanently bind the wallet to the user through their phone number.

  • 초기화 후에 호출됩니다.

예제


// Use custom password register a CloudMoolah acount.

m_MoolahExtensions.FastRegister("CMPassword", registerSucceed, registerFailed);

public void registerSucceed(string cmUserName)

{

    m_CloudMoolahUserName = cmUserName;

    Debug.Log ("registerSucceed : cmUserName is " + cmUserName);

}

public void registerFailed(FastRegisterError error, string errorMsg)

{

    Debug.Log ("registerFailed :FastRegisterError is " + error.ToString() + ", errorMsg is " + errorMsg);

}

기존 지갑에 로그인

구문

void IMoolahExtension.Login(string CMUserName, string CMPassword, Action<LoginResultState, string> LoginResult)

파라미터

  • CMUserName: Returned from previous call to FastRegister (below).

  • CMpassword: Used in previous call to FastRegister (below).

  • LoginResult: 필수입니다. (LoginResultState) 시도 결과를 (string message) 진단 메시지와 함께 전달합니다.

설명

  • 필수입니다.

  • User login with Cloud Moolah username.

  • All standalone games can allow users to make purchases without this login (use Unity GUID as username). Example

m_MoolahExtensions.Login(m_CloudMoolahUserName, "CMPassword", loginResult);

public void loginResult(LoginResultState state, string message)

{

    m_IsLoggedIn = state == LoginResultState.LoginSucceed;

}

테스트

CloudMoolah supports local testing for validating an application’s purchase flow error handling, and for simulating payment without making a real-currency payment.

개발자 모드 설정

구문

void IMoolahExtension.SetMode(CloudMoolahMode mode)

파라미터

  • mode: 수행할 구매 흐름 타입입니다.

설명

  • CloudMoolahMode를 지정하여 성공, 실패 또는 정상 작동을 활성화합니다.

예제

m_MoolahExtensions.SetMode(CloudMoolahMode.AlwaysFail); // TESTING: all purchases will fail

추가 API

이전 구매 거래 복원

구문

void IMoolahExtension.RestoreTransactionID(Action<RestoreTransactionIDState> result)

파라미터

  • result: The status of transaction.

설명

  • Return all unfinished transactions which have been paid for successfully but have not been paid out (see the RequestPayOut API) yet.

  • 초기화 후에 호출해야 합니다.

  • 로그인을 먼저 호출해야 합니다.

예제

// Retrieve transaction identifiers, when Client does not already have transaction identifiers.

m_MoolahExtensions.RestoreTransactionID(( RestoreTransactionIDState restoreTransactionIDState)=>{

    // Restore complete, see ProcessPurchase for restored products

};

완전 완료 또는 소비 거래

구문

void IMoolahExtension.RequestPayOut(string transactionId, Action<string, RequestPayOutState, string> result)

파라미터

  • transactionId: 완료할 거래 식별자입니다.

  • result: TransactionId, the result of payout, any error message.

설명

  • This is key for the delivery of a virtual item, and is helpful or necessary for offline games. This API should be used after the virtual item has been delivered.

  • The use-case is that payment has been made but the games crashes before the delivery of the virtual item is complete. The standalone game developer has no record of this, so they must call the TransactionRestore method and the RequestPayOut to finish the transaction.

  • For online games, developers can manage PayOut themselves, so the client does not need to call the PayOut operation and Restore. The client’s game server can also do the PayOut operation by returning the delivery status while the server makes a callback.

  • ProcessPurchase에서 호출합니다.

예제

For an offline game from within ProcessPurchase:


// If platform is CloudMoolah, you should to payout on a standalone game and "return PurchaseProcessingResult.Pending" at the end.

if (m_IsCloudMoolahStoreSelected) {

    m_MoolahExtensions.RequestPayOut (m_CloudMoolahTransactionID, (string transactionID, RequestPayOutState state, string message) => {

        msg = "ProcessPurchase requestPayOut TannsationID:" + transactionID + ",state:"+ state.ToString() + ",msg:" + message;

        if (state == RequestPayOutState.RequestPayOutSucceed) {

            // Finish Transaction

                    m_Controller.ConfirmPendingPurchase(e.purchasedProduct);

            //payout success, issue virtual props. 

        } else {

            //PayOut Failed , Don't issue virtual props.

        }

    });

}

// You should unlock the content here.

// Indicate we have handled this purchase, we will not be informed of it again.x

// If platform is CloudMoolah,you should "return PurchaseProcessingResult.Pending" on a standalone game or "return PurchaseProcessingResult.Complete" on an online game.

return PurchaseProcessingResult.Pending;

온라인 게임의 경우:

// You should unlock the content here.

// Indicate we have handled this purchase, we will not be informed of it again.x

// If platform is CloudMoolah, you should "return PurchaseProcessingResult.Pending" on a standalone game or "return PurchaseProcessingResult.Complete" on an online game.

return PurchaseProcessingResult.Complete;

서버에서 수신 확인

구문

void IMoolahExtension.ValidateReceipt(string transactionId, string receipt, Action<string, ValidateReceiptState, string> result

파라미터

  • transactionId: 결제 거래 ID입니다.

  • receipt: ProcessPurchase를 통해 반환되는 영수증 데이터입니다.

  • result: transactionId, enumeration of status, error message.

설명

  • CloudMoolah 서버에서 거래의 유효성을 검증합니다.

  • 결제 후에 호출합니다.

예제

// Validate a receipt on the server.

m_MoolahExtensions.ValidateReceipt(m_CloudMoolahTransactionID, m_CloudMoolahReceipt, (string transactionID, ValidateReceiptState state, string msg)=>{

    bool succeeded = state == ValidateReceiptState.ValidateSucceed;

});

상수와 열거형

AndroidStore - addition of CloudMoolah

구문

public enum AndroidStore

New Member

  • CloudMoolah: The Cloud Moolah store’s Android identifier.

설명

  • Indicates the Cloud Moolah store is active for Unity IAP.

  • Get from the standardPurchasingModule’s androidStore field.

예제

// Determine whether we are using Cloud Moolah IAP. 

bool m_IsCloudMoolahStoreSelected = Application.platform == RuntimePlatform.Android && module.androidStore == AndroidStore.CloudMoolah;

CloudMoolah store name

구문

string AndroidStore.CloudMoolah

설명

  • The Cloud Moolah store’s shortened, readable name.

  • 상수는 MoolahAppStore입니다.

예제

AndroidStore.CloudMoolah;

로그인 결과 코드

구문

public enum LoginResultState

멤버

  • LoginSucceed: Successful login, session token has been generated.

  • UserNotExists: CMUserName not found on Cloud Moolah server.

  • PasswordError: CMPassword가 올바르지 않습니다.

  • LoginCallBackIsNull: 콜백 파라미터가 null입니다.

  • UserOrPasswordEmpty: 사용자 이름 또는 암호가 비어 있습니다.

  • NetworkError: 네트워크 오류.

  • NotKnown: 알 수 없음.

설명

  • ICloudMoolahExtension.Login에서 이 스테이트를 반환합니다.

FastRegistration

구문

public enum FastRegisterError

멤버

  • PasswordEmpty: CMPassword is empty.

  • FastRegisterCallBackIsNull: FastRegister callback parameter is null.

  • NetworkError: Network error.

  • NotKnown: Unknown error.

설명

  • Cloud Moolah Extension.FastRegister return the errors or exceptions.

  • The callback will return the FastRegisterError if FastRegsiter failed.

영수증 확인

구문

public enum ValidateReceiptState

멤버

  • ValidateSucceed: 영수증 확인에 성공했습니다.

  • ValidateFailed: 영수증 확인에 실패했습니다.

  • NotKnown: 알 수 없는 오류입니다.

설명

  • After purchase is done, client will query Cloud Moolah Server if the receipt is valid.

  • The callback will return the result of validation.

거래 식별자 복원 상태

구문

public enum RestoreTransactionIDState

멤버

  • NoTransactionRestore: No transaction needed to restore.

  • RestoreSucceed: 복원에 성공했습니다.

  • RestoreFailed: 복원에 실패했습니다.

  • NotKnown: 알 수 없는 오류입니다.

설명

  • For an offline game, the previous transactions after the login process will be restored.

  • 오프라인 게임에만 권장됩니다.

  • 반환 상태입니다.

Transaction completion pay out request state

구문

public enum RequestPayOutState

멤버

  • RequestPayOutSucceed: 결제에 성공했습니다.

  • RequestPayOutNetworkError: 결제 중에 네트워크 오류가 발생했습니다.

  • RequestPayOutFailed: 결제에 실패했습니다.

  • NotKnown: 알 수 없는 오류입니다.

설명

  • 결제 API 호출 결과입니다.

  • 연결되지 않은 오프라인 게임에만 유용하다고 간주되고, 연결된 온라인 게임에는 불필요합니다.

Tizen store
스토어 구현