Documentation ¶
Index ¶
Constants ¶
View Source
const ( // https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-api-specification-related-v4#API-ErrorCode IAPResponseResultOK = "0" IAPResponseResultUSER_CANCELED = "1" IAPResponseResultSERVICE_UNAVAILABLE = "2" IAPResponseResultBILLING_UNAVAILABLE = "3" IAPResponseResultITEM_UNAVAILABLE = "4" IAPResponseResultDEVELOPER_ERROR = "5" IAPResponseResultERROR = "6" IAPResponseResultITEM_ALREADY_OWNED = "7" IAPResponseResultITEM_NOT_OWNED = "8" IAPResponseResultITEM_CONSUMED = "9" )
View Source
const ( // OrderSiteChina site Information for China OrderSiteChina = "https://orders-drcn.iap.hicloud.com" // OrderSiteGermany site Information for China OrderSiteGermany = "https://orders-dre.iap.hicloud.com" // OrderSiteSingapore site Information for China OrderSiteSingapore = "https://orders-dra.iap.hicloud.com" // OrderSiteRussia site Information for China OrderSiteRussia = "https://orders-drru.iap.hicloud.com" // OrderSiteAppTouch site Information for China OrderSiteAppTouch = "https://orders-at-dre.iap.dbankcloud.com" )
View Source
const ( // SubscriptionSiteChina site Information for China SubscriptionSiteChina = "https://subscr-drcn.iap.hicloud.com" // SubscriptionSiteGermany site Information for China SubscriptionSiteGermany = "https://subscr-dre.iap.hicloud.com" // SubscriptionSiteSingapore site Information for China SubscriptionSiteSingapore = "https://subscr-dra.iap.hicloud.com" // SubscriptionSiteRussia site Information for China SubscriptionSiteRussia = "https://subscr-drru.iap.hicloud.com" // SubscriptionSiteAppTouchURL site Information for China SubscriptionSiteAppTouchURL = "https://subscr-at-dre.iap.dbankcloud.com" )
View Source
const ( // ProductTokenURL is the endpoint for production environment. ProductTokenURL string = "https://oauth-login.cloud.huawei.com/oauth2/v2/token" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { OrderSiteURL string SubscriptionSiteURL string TokenURL string // contains filtered or unexported fields }
Client implements IAPClient
func NewWithClient ¶
NewWithClient creates a client with a custom http client.
func (*Client) GetHeaderToken ¶
func (c *Client) GetHeaderToken(reqBody IAPRequest) (string, error)
GetHeaderToken get access token
func (*Client) VerifySubscription ¶
func (c *Client) VerifySubscription(ctx context.Context, reqBody IAPRequest) (*InappPurchaseData, error)
VerifySubscription purchase Token Verification for the Subscription Service
func (*Client) VerifyToken ¶
func (c *Client) VerifyToken(ctx context.Context, reqBody IAPRequest) (*InappPurchaseData, error)
VerifyToken purchase Token Verification for the Order Service
type IAPOrderResponse ¶
type IAPOrderResponse struct { ResponseCode string `json:"responseCode,omitempty"` ResponseMessage string `json:"responseMessage,omitempty"` PurchaseTokenData string `json:"purchaseTokenData,omitempty"` DataSignature string `json:"dataSignature,omitempty"` }
IAPSubscriptionResponse store subscription response
type IAPRequest ¶
type IAPRequest struct { PurchaseToken string `json:"purchaseToken,omitempty"` ProductID string `json:"productId,omitempty"` ClientID string ClientSecret string ApplicationPublicKey string SubscriptionID string `json:"subscriptionId,omitempty"` }
IAPRequest input Parameters for order and subscription
type IAPSubscriptionResponse ¶
type IAPSubscriptionResponse struct { ResponseCode string `json:"responseCode,omitempty"` ResponseMessage string `json:"responseMessage,omitempty"` InappPurchaseData string `json:"inappPurchaseData,omitempty"` }
IAPSubscriptionResponse store subscription response
type InappPurchaseData ¶
type InappPurchaseData struct { SurveyReason *int `json:"surveyReason,omitempty"` SurveyDetails string `json:"surveyDetails,omitempty"` ApplicationID int `json:"applicationId,omitempty"` AutoRenewing bool `json:"autoRenewing,omitempty"` OrderID string `json:"orderId,omitempty"` Kind int `json:"kind,omitempty"` PackageName string `json:"packageName,omitempty"` ProductID string `json:"productId,omitempty"` ProductName string `json:"productName,omitempty"` PurchaseTime *int64 `json:"purchaseTime,omitempty"` PurchaseState int `json:"purchaseState,omitempty"` DeveloperPayload string `json:"developerPayload,omitempty"` DeveloperChallenge string `json:"developerChallenge,omitempty"` ConsumptionState *int `json:"consumptionState,omitempty"` PurchaseToken string `json:"purchaseToken,omitempty"` PurchaseType *int `json:"purchaseType,omitempty"` Currency string `json:"currency,omitempty"` Price int `json:"price,omitempty"` Country string `json:"country,omitempty"` PayType string `json:"payType,omitempty"` PayOrderID string `json:"payOrderId,omitempty"` AccountFlag *int `json:"accountFlag,omitempty"` LastOrderID string `json:"lastOrderId,omitempty"` ProductGroup string `json:"productGroup,omitempty"` OriginalPurchaseTime *int64 `json:"oriPurchaseTime,omitempty"` SubscriptionID string `json:"subscriptionId,omitempty"` OriginalSubscriptionID string `json:"oriSubscriptionId,omitempty"` Quantity int `json:"quantity,omitempty"` DaysLasted int `json:"daysLasted,omitempty"` NumOfPeriods *int `json:"numOfPeriods,omitempty"` NumOfDiscount int `json:"numOfDiscount,omitempty"` ExpirationDate *int64 `json:"expirationDate,omitempty"` ExpirationIntent int `json:"expirationIntent,omitempty"` RetryFlag *int `json:"retryFlag,omitempty"` IntroductoryFlag *int `json:"introductoryFlag,omitempty"` TrialFlag *int `json:"trialFlag,omitempty"` CancelTime *int64 `json:"cancelTime,omitempty"` CancelReason *int `json:"cancelReason,omitempty"` AppInfo string `json:"appInfo,omitempty"` NotifyClosed *int `json:"notifyClosed,omitempty"` RenewStatus *int `json:"renewStatus,omitempty"` PriceConsentStatus *int `json:"priceConsentStatus,omitempty"` RenewPrice int `json:"renewPrice,omitempty"` SubscriptionIsvalid bool `json:"subIsvalid,omitempty"` DeferFlag int `json:"deferFlag,omitempty"` CancelWay *int `json:"cancelWay,omitempty"` CancellationTime *int64 `json:"cancellationTime,omitempty"` CancelledSubKeepDays int `json:"cancelledSubKeepDays,omitempty"` Confirmed *int `json:"confirmed,omitempty"` ResumeTime *int64 `json:"resumeTime,omitempty"` SdkChannel string `json:"sdkChannel,omitempty"` }
https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-InAppPurchaseDetails-v4
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
}
TokenResponse is
Click to show internal directories.
Click to hide internal directories.