hms

package
v1.28.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InAppPurchaseDataKindConsumable    int64 = 0
	InAppPurchaseDataKindNonConsumable int64 = 1
	InAppPurchaseDataKindSubscription  int64 = 2
)

Constants for InAppPurchaseData.Kind product type https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataPurchaseStateInitialized int64 = -1
	InAppPurchaseDataPurchaseStatePurchased   int64 = 0
	InAppPurchaseDataPurchaseStateCanceled    int64 = 1
	InAppPurchaseDataPurchaseStateRefunded    int64 = 2
)

Constants for InAppPurchaseData.PurchaseState https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataPurchaseTypeSandbox   int64 = 0
	InAppPurchaseDataPurchaseTypePromotion int64 = 1
)

Constants for InAppPurchaseData.PurchaseType indicates if the product is purchased through sandbox environment or promotion. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

Note: You should always check InAppPurchaseData.PurchaseType != nil first.

View Source
const (
	InAppPurchaseDataPayTypeHuaweiPoint     string = "0"
	InAppPurchaseDataPayTypeCreditCard      string = "3"
	InAppPurchaseDataPayTypeAlipay          string = "4"
	InAppPurchaseDataPayTypeCarrier         string = "6"
	InAppPurchaseDataPayTypePayPal          string = "13"
	InAppPurchaseDataPayTypeDebitCard       string = "16"
	InAppPurchaseDataPayTypeWeChatPay       string = "17"
	InAppPurchaseDataPayTypeGiftCard        string = "19"
	InAppPurchaseDataPayTypeBalance         string = "20"
	InAppPurchaseDataPayTypeHuaweiPointCard string = "21"
	InAppPurchaseDataPayTypeWorldPay        string = "24"
	InAppPurchaseDataPayTypeHuaweiPay       string = "31"
	InAppPurchaseDataPayTypeAntCreditPay    string = "32"
	InAppPurchaseDataPayTypeMPesa           string = "200" // M-Pesa
)

Constants for InAppPurchaseData.PayType payment methods when buying the product. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133#section135412662210

View Source
const (
	InAppPurchaseDataAccountFlagHuaweiID int64 = 0
	InAppPurchaseDataAccountFlagAppTouch int64 = 1
)

Constants for InAppPurchaseData.AccountFlag Account type. See https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-common-statement-0000001050986127#section1741234185817 for details.

View Source
const (
	InAppPurchaseDataExpirationIntentCanceledByUser         int64 = 1
	InAppPurchaseDataExpirationIntentProductUnavaliable     int64 = 2
	InAppPurchaseDataExpirationIntentAbnormalUserSigning    int64 = 3
	InAppPurchaseDataExpirationIntentBillingError           int64 = 4
	InAppPurchaseDataExpirationIntentPriceIncreaseDisagreed int64 = 5
	InAppPurchaseDataExpirationIntentUnknownError           int64 = 6
)

Constants for InAppPurchaseData.ExpirationIntent Reasons why a subscription expires. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataRetryFlagNo  int64 = 0
	InAppPurchaseDataRetryFlagYes int64 = 1
)

Constants for InAppPurchaseData.RetryFlag Indicates whether the system still tries to renew an expired subscription. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataIntroductoryFlagNo  int64 = 0
	InAppPurchaseDataIntroductoryFlagYes int64 = 1
)

Constants for InAppPurchaseData.IntroductoryFlag Indicates whether a subscription is in the renewal period with promotion or not. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataTrialFlagNo  int64 = 0
	InAppPurchaseDataTrialFlagYes int64 = 1
)

Constants for InAppPurchaseData.TrialFlag Indicates whether a subscription is in the free trial period or not. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataCancelReasonOther               int64 = 0 // Other causes. For example, a user mistakenly purchases a subscription and has to cancel it.
	InAppPurchaseDataCancelReasonUserIssue           int64 = 1 // A user encounters a problem within the app and cancels the subscription.
	InAppPurchaseDataCancelReasonUpgradeOrCrossgrade int64 = 2 // A user performs subscription upgrade or crossgrade.
)

Constants for InAppPurchaseData.CancelReason Causes of subscription cancellation. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

Note: You should check SubIsValid first.

View Source
const (
	InAppPurchaseDataNotifyClosedNo  int64 = 0
	InAppPurchaseDataNotifyClosedYes int64 = 1
)

Constants for InAppPurchaseData.NotifyClosed Indicates whether a user has disabled the subscription notification function. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataRenewStatusCanceledByUser int64 = 0 // A user proactively canceled the subscription auto-renewal.
	InAppPurchaseDataRenewStatusNormal         int64 = 1 // The subscription will be auto-renewed.
)

Constants for InAppPurchaseData.RenewStatus Indecates whether the auto-renewal is canceled or not. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataPriceConsentStatusNoResponse int64 = 0 // The user did not give any comfirmation. Subscription will be terminated without renewal after expires.
	InAppPurchaseDataPriceConsentStatusAgreed     int64 = 1 // The user has agreed with the price increase.
)

Constants for InAppPurchaseData.PriceConsentStatus User opinions collected when the product price increased. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

View Source
const (
	InAppPurchaseDataCancelWayByUser      int64 = 0
	InAppPurchaseDataCancelWayByDeveloper int64 = 1
	InAppPurchaseDataCancelWayByHuawei    int64 = 2
)

Constants for InAppPurchaseData.CancelWay how does the subscription be canceled https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

Note: You should check SubIsValid first.

View Source
const (
	CanceledPurchaseCancelledSourceByUser      int64 = 0
	CanceledPurchaseCancelledSourceByDeveloper int64 = 1
	CanceledPurchaseCancelledSourceByHuawei    int64 = 2
)

Constants for CanceledPurchase.CancelledSource https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-cancel-or-refund-record-0000001050746117

View Source
const (
	CanceledPurchaseCancelledReasonOther              int64 = 0
	CanceledPurchaseCancelledReasonUserRepentance     int64 = 1
	CanceledPurchaseCancelledReasonProductNotProvided int64 = 2
	CanceledPurchaseCancelledReasonAbnormal           int64 = 3
	CanceledPurchaseCancelledReasonAccidental         int64 = 4
	CanceledPurchaseCancelledReasonFraud              int64 = 5
	CanceledPurchaseCancelledReasonChargeback         int64 = 6
	CanceledPurchaseCancelledReasonUpgradeOrDowngrade int64 = 7
	CanceledPurchaseCancelledReasonServiceAreaChanged int64 = 8
)

Constants for CanceledPurchase.CancelledReason https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-cancel-or-refund-record-0000001050746117

View Source
const (
	NotificationTypeInitialBuy           int64 = 0
	NotificationTypeCancel               int64 = 1
	NotificationTypeRenewal              int64 = 2
	NotificationTypeInteractiveRenewal   int64 = 3
	NotificationTypeNewRenewalPref       int64 = 4
	NotificationTypeRenewalStopped       int64 = 5
	NotificationTypeRenewalRestored      int64 = 6
	NotificationTypeRenewalRecurring     int64 = 7
	NotificationTypeInGracePeriod        int64 = 8
	NotificationTypeOnHold               int64 = 9
	NotificationTypePaused               int64 = 10
	NotificationTypePausePlanChanged     int64 = 11
	NotificationTypePriceChangeConfirmed int64 = 12
	NotificationTypeDeferred             int64 = 13
)

Constants for StatusUpdateNotification.NotificationType https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-notifications-about-subscription-events-0000001050706084#EN-US_TOPIC_0000001050706084__section18290165220716

View Source
const (
	InAppPurchaseDataDeferFlagYes int64 = 1
)

Constants for InAppPurchaseData.DeferFlag Indicates whether to postpone the settlement date. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

Variables

View Source
var ErrorResponseAbnormalUserAccount error = errors.New("The user account is abnormal, for example, the user has been deregistered")

ErrorResponseAbnormalUserAccount The user account is abnormal, for example, the user has been deregistered.

https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248

View Source
var ErrorResponseConsumedProduct error = errors.New("The product cannot be consumed or confirmed because it has been consumed or confirmed")

ErrorResponseConsumedProduct The product cannot be consumed or confirmed because it has been consumed or confirmed.

https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248

View Source
var ErrorResponseCritical error = errors.New("A critical error occurs during API operations")

ErrorResponseCritical A critical error occurs during API operations.

Rectify the fault based on the error information in the response. If the fault persists, contact Huawei technical support. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248

View Source
var ErrorResponseInvalidParameter error = errors.New("The parameter passed to the API is invalid")

ErrorResponseInvalidParameter The parameter passed to the API is invalid. This error may also indicate that an agreement is not signed or parameters are not set correctly for the in-app purchase settlement in HUAWEI IAP, or the required permission is not in the list.

Check whether the parameter passed to the API is correctly set. If so, check whether required settings in HUAWEI IAP are correctly configured. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248

View Source
var ErrorResponseProductNotBelongToUser error = errors.New("A user failed to consume or confirm a product because the user does not own the product")

ErrorResponseProductNotBelongToUser A user failed to consume or confirm a product because the user does not own the product.

https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248

View Source
var ErrorResponseUnknown error = errors.New("Unknown error from API response")

ErrorResponseUnknown error placeholder for undocumented errors

Functions

func VerifySignature

func VerifySignature(base64EncodedPublicKey string, data string, signature string) (err error)

VerifySignature validate inapp order or subscription data signature. Returns nil if pass.

Document: https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/verifying-signature-returned-result-0000001050033088 Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/demo.go#L60

Types

type ApplicationAccessToken

type ApplicationAccessToken struct {
	// App-level access token.
	AccessToken string `json:"access_token"`

	// Remaining validity period of an access token, in seconds.
	ExpiresIn int64 `json:"expires_in"`

	// Save the timestamp when AccessToken is obtained
	ExpiredAt int64 `json:"-"`

	// Request header string
	HeaderString string `json:"-"`
}

ApplicationAccessToken model, received from HMS OAuth API https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/open-platform-oauth-0000001050123437#EN-US_TOPIC_0000001050123437__section12493191334711

type CanceledPurchase

type CanceledPurchase struct {
	// Unique order ID of a subscription or subscription renewal.
	OrderID string `json:"orderId"`

	// Product ID.
	ProductID string `json:"productId"`

	// Purchase token.
	PurchaseToken string `json:"purchaseToken"`

	// Purchase timestamp in UTC.
	PurchaseTime int64 `json:"purchaseTime"`

	// Cancellation or refund timestamp in UTC.
	CancelledTime int64 `json:"cancelledTime"`

	// Cancellation or refund initiator. Possible values are:
	//    0: user
	//    1: developer
	//    2: Huawei
	CancelledSource int64 `json:"cancelledSource"`

	// Cancellation or refund reason. Possible values are:
	//    0: others
	//    1: user repentance
	//    2: product not provided
	//    3: abnormal app service
	//    4: accidental purchase
	//    5: fraud
	//    6: chargeback
	//    7: upgrade or downgrade
	//    8: user service area change
	CancelledReason int64 `json:"cancelledReason"`
}

CanceledPurchase individual canceled purchase information, for CanceledPurchaseList.

Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-cancel-or-refund-record-0000001050746117

type CanceledPurchaseList

type CanceledPurchaseList struct {
	// Result code. Possible values are:
	//    0: success
	//    Other values: failure. For details about the result codes, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248
	ResponseCode string `json:"responseCode"`

	// Response description.
	ResponseMessage string `json:"responseMessage,omitempty"`

	// List of canceled or refunded purchase information, in JSON strings. Each string indicates a purchase record.
	//
	// For details about the purchase information format, please refer to CanceledPurchase{}
	CancelledPurchaseList string `json:"cancelledPurchaseList,omitempty"`

	// Token to query data on the next page. If a value is returned, pass it in the next query request to query data on the next page.
	ContinuationToken string `json:"continuationToken,omitempty"`
}

CanceledPurchaseList response from query canceled or refunded purchase list

Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-cancel-or-refund-record-0000001050746117

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements VerifySignature, VerifyOrder and VerifySubscription methods

func New

func New(clientID, clientSecret, orderSiteURL, subscriptionSiteURL string) *Client

New returns client with credentials. Required client_id and client_secret which could be acquired from the HMS API Console. When user accountFlag is not equals to 1, orderSiteURL/subscriptionSiteURL are the site URLs that will be used to connect to HMS IAP API services. If orderSiteURL or subscriptionSiteURL are not set, default to AppTouch Germany site.

Please refer https://developer.huawei.com/consumer/en/doc/start/api-console-guide and https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-common-statement-0000001050986127 for details.

func (*Client) CancelSubscriptionRenewal

func (c *Client) CancelSubscriptionRenewal(ctx context.Context, purchaseToken, subscriptionID string, accountFlag int64) (success bool, responseMessage string, err error)

CancelSubscriptionRenewal Cancel a aubscription from auto-renew when expired. Note that this does not cancel the current subscription. If you want to revoke a subscription, use Client.RevokeSubscription() instead. Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/subscription.go#L54 Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-cancel-subscription-0000001050746115

func (*Client) ConfirmPurchases added in v1.26.3

func (c *Client) ConfirmPurchases(ctx context.Context, purchaseToken, productID string, accountFlag int64) (success bool, responseMessage string, err error)

ConfirmPurchases gets subscriptions info with subscriptionId and purchaseToken. This API is used to notify the Huawei IAP server to update the delivery status of a consumable after it is successfully delivered. If no notification is sent, the consumable cannot be purchased again. Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-purchase-confirm-for-order-service-0000001051066054

func (*Client) DelaySubscription added in v1.26.3

func (c *Client) DelaySubscription(ctx context.Context, purchaseToken, subscriptionID string, currentExpirationTime, desiredExpirationTime int64, accountFlag int64) (success bool, responseMessage string, newExpirationTime int64, err error)

DelaySubscription extend the current subscription expiration date without chanrging the customer. Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/subscription.go#L68 Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-delayed-settlement-0000001050706082

func (*Client) GetApplicationAccessTokenHeader

func (c *Client) GetApplicationAccessTokenHeader() (string, error)

GetApplicationAccessTokenHeader obtain OAuth AccessToken from HMS

Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/atdemo.go#L37

func (*Client) GetCanceledOrRefundedPurchases

func (c *Client) GetCanceledOrRefundedPurchases(

	ctx context.Context,

	startAt int64,

	endAt int64,

	maxRows int,

	continuationToken string,

	productType int64,

	accountFlag int64,
) (canceledPurchases []CanceledPurchase, newContinuationToken string, responseCode string, responseMessage string, err error)

GetCanceledOrRefundedPurchases gets all revoked purchases in CanceledPurchaseList{}. This method allow fetch over 1000 results regardles the cap implied by HMS API. Though you should still limit maxRows to a certain number to increate preformance.

In case of an error, this method might return some fetch results if maxRows greater than 1000 or equals 0.

Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/order.go#L52 Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-cancel-or-refund-record-0000001050746117

func (*Client) GetMerchantQueryPurchases added in v1.26.3

func (c *Client) GetMerchantQueryPurchases(

	ctx context.Context,

	startAt int64,

	endAt int64,

	continuationToken string,

	accountFlag int64,
) (canceledPurchases []OrderInfoList, newContinuationToken string, responseCode string, responseMessage string, err error)

GetMerchantQueryPurchases gets all revoked purchases in OrderInfoList{}. This method allow fetch over 1000 results regardles the cap implied by HMS API. Though you should still limit maxRows to a certain number to increate preformance.

In case of an error, this method might return some fetch results if maxRows greater than 1000 or equals 0.

Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-cancel-or-refund-record-0000001050746117

func (*Client) GetOrderDataString

func (c *Client) GetOrderDataString(ctx context.Context, purchaseToken, productID string, accountFlag int64) (purchaseTokenData, dataSignature string, err error)

GetOrderDataString gets order (single item purchase) response data as json string and dataSignature

Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-order-verify-purchase-token-0000001050746113 Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/order.go#L41

func (*Client) GetSubscriptionDataString

func (c *Client) GetSubscriptionDataString(ctx context.Context, purchaseToken, subscriptionID string, accountFlag int64) (string, error)

GetSubscriptionDataString gets subscriptions response data string.

Document: https://developer.huawei.com/consumer/en/doc/development/HMSCore-References/api-subscription-verify-purchase-token-0000001050706080 Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/subscription.go#L40

func (*Client) RefundSubscription

func (c *Client) RefundSubscription(ctx context.Context, purchaseToken, subscriptionID string, accountFlag int64) (success bool, responseMessage string, err error)

RefundSubscription refund a subscription payment. Note that this does not cancel the current subscription. If you want to revoke a subscription, use Client.RevokeSubscription() instead. Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/subscription.go#L84 Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-refund-subscription-fee-0000001050986131

func (*Client) RevokeSubscription

func (c *Client) RevokeSubscription(ctx context.Context, purchaseToken, subscriptionID string, accountFlag int64) (success bool, responseMessage string, err error)

RevokeSubscription will revoke and issue a refund on a subscription immediately. Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/subscription.go#L99 Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-unsubscribe-0000001051066056

func (*Client) VerifyOrder

func (c *Client) VerifyOrder(ctx context.Context, purchaseToken, productID string, accountFlag int64) (InAppPurchaseData, error)

VerifyOrder gets order (single item purchase) info with productId and purchaseToken.

Note that this method does not verify the DataSignature, thus security is relied on HTTPS solely.

Document: https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-order-verify-purchase-token-0000001050746113 Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/order.go#L41

func (*Client) VerifySubscription

func (c *Client) VerifySubscription(ctx context.Context, purchaseToken, subscriptionID string, accountFlag int64) (InAppPurchaseData, error)

VerifySubscription gets subscriptions info with subscriptionId and purchaseToken.

Document: https://developer.huawei.com/consumer/en/doc/development/HMSCore-References/api-subscription-verify-purchase-token-0000001050706080 Source code originated from https://github.com/HMS-Core/hms-iap-serverdemo/blob/92241f97fed1b68ddeb7cb37ea4ca6e6d33d2a87/demo/subscription.go#L40

type ConsumptionState added in v1.25.1

type ConsumptionState int

Constants for InAppPurchaseData.ConsumptionState https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

const (
	InAppPurchaseDataConsumptionStateNotConsumed ConsumptionState = 0
	InAppPurchaseDataConsumptionStateConsumed    ConsumptionState = 1
)

type InAppPurchaseData

type InAppPurchaseData struct {
	// App ID.
	ApplicationID int64 `json:"applicationId"`

	// For consumables or non-consumables, the value is always false.
	// For subscriptions, possible values are:
	// true: A subscription is in active state and will be automatically renewed on the next renewal date.
	// false: A user has canceled the subscription. The user can access the subscribed content
	//        before the next renewal date but will be unable to access the content after the date
	//        unless the user enables automatic renewal. If a grace period is provided,
	//        this value remains true for the subscription as long as it is still in the grace period.
	//        The next settlement date is automatically extended every day until the grace period ends
	//        or the user changes the payment method.
	AutoRenewing bool `json:"autoRenewing"`

	// Order ID, which uniquely identifies a transaction and is generated by the Huawei IAP server during payment.
	OrderID string `json:"orderId"`

	// Product type. Possible values are:
	//    0: consumable
	//    1: non-consumable
	//    2: subscription
	Kind int64 `json:"kind"`

	// App package name.
	PackageName string `json:"packageName,omitempty"`

	// Product ID. Each product must have a unique ID, which is maintained in the PMS or passed when the app initiates a purchase.
	ProductID string `json:"productId"`

	// Product name.
	ProductName string `json:"productName,omitempty"`

	// Timestamp of the purchase time, which is the number of milliseconds from 00:00:00 on January 1, 1970 to the purchase time.
	PurchaseTime int64 `json:"purchaseTime,omitempty"`

	// A parameter that has the same meaning as purchaseTime and used by APIs of earlier versions. If your app has the latest version integrated, just ignore this parameter.
	PurchaseTimeMillis int64 `json:"purchaseTimeMillis"`

	// Transaction status. Possible values are:
	//    -1: initialized
	//    0: purchased
	//    1: canceled
	//    2: refunded
	PurchaseState int64 `json:"purchaseState"`

	// Information stored on the merchant side, which is passed by the app when the payment API is called.
	DeveloperPayload string `json:"developerPayload,omitempty"`

	// Challenge defined when an app initiates a consumption request.
	// The challenge uniquely identifies the consumption request and exists only for one-off products.
	DeveloperChallenge string `json:"developerChallenge,omitempty"`

	// Consumption status, which exists only for one-off products. Possible values are:
	//    0: not consumed
	//    1: consumed
	ConsumptionState ConsumptionState `json:"consumptionState,omitempty"`

	// Confirmation status. Possible values are:
	//    0: not confirmed
	//    1: confirmed
	// If this parameter is left empty, no confirmation is required.
	Confirmed int64 `json:"confirmed,omitempty"`

	// Purchase token, which uniquely identifies the mapping between a product and a user.
	// It is generated by the Huawei IAP server when the payment is complete.
	// NOTE:
	// * This parameter uniquely identifies the mapping between a product and a user.
	//   It does not change when the subscription is renewed.
	// * Currently, the value contains 92 characters and its length may be expanded.
	//   If the value needs to be stored, you are advised to reserve 128 characters.
	PurchaseToken string `json:"purchaseToken"`

	// Purchase type. Possible values are:
	//    0: in the sandbox
	//    1: in the promotion period (currently unsupported)
	// This parameter is not returned during formal purchase.
	// To avoid default value issues. check if PurchaseType != nil first, then read *PurchaseType.
	PurchaseType *int64 `json:"purchaseType,omitempty"`

	// Currency. The value must comply with the ISO 4217 standard.
	Currency string `json:"currency,omitempty"`

	// Value after the actual price of a product is multiplied by 100. The actual price is accurate to two decimal places.
	// For example, if the value of this parameter is 501, the actual product price is 5.01.
	Price int64 `json:"price,omitempty"`

	// Country or region code, which is used to identify a country or region. The value must comply with the ISO 3166 standard.
	Country string `json:"country,omitempty"`

	// Payment method. Possible values are:
	//    0: HUAWEI Point
	//    3: credit card
	//    4: Alipay
	//    6: carrier billing
	//    13: PayPal
	//    16: debit card
	//    17: WeChat Pay
	//    19: gift card
	//    20: balance
	//    21: HUAWEI Point card
	//    24: WorldPay
	//    31: Huawei Pay
	//    32: Ant Credit Pay
	//    33: SHARINGPAY
	//    34: Bank card (Adyen)
	//    35:	iDEAL (Adyen)
	//    36:	OpenBK (Adyen)
	//    37:	Sofort (Adyen)
	//    38:	Giropay (Adyen)
	//    39:	FPX (iPay88)
	//    40:	eNETS (iPay88)
	//    41:	BOOST (iPay88)
	//    42:	Sberbank (Yandex)
	//    43:	eMoney (Yandex)
	//    44:	Huabei
	//    45:	Coupon (HMS coupon)
	//    46:	eMoney4MP(Mercado Pago Account Money)
	//    47:	2C2PBank(2C2P)
	//    48:	TrueMoney (2C2P)
	//    49:	Combined payment using gift cards and HMS coupons
	//    61:	GCash (Paynamics)
	//    62:	BPI Online (Paynamics) - Philippines
	//    63:	UnionBankOnline (Paynamics)
	//    64:	AlipayHK (Adyen)
	//    66:	TNG (AliGlobal)
	//    67:	PaymentWall (PayU)
	//    68:	PayMaya Wallet (Adyen)
	//    69:	Paysafecard
	//    70:	MPESA
	//    71:	BankCard (PetalPay)
	//    72:	WXPay (PetalPay)
	//    73:	AliPay (PetalPay)
	//    74:	Boost (iPay88)
	//    75:	OXXO PAY (EBANX)
	//    76:	AlipayHK (AliGlobal)
	//    77:	GCash (AliGlobal)
	//    78:	Efecty (EBANX)
	//    79:	Multicaja (EBANX)
	//    80:	Fawry Pay
	//    81:	Point (paid only with membership points)
	//    82:	HWPay4Petal (PetalPay)
	//    83:	TrueMoney (AliGlobal)
	//    84:	MIR (Yandex)
	//    85:	Boost (AliGlobal)
	//    86:	VTC Pay
	//    90:	OZOW
	//    93:	ShopeePay
	//    94:	PetalPay
	//    95:	UnionPay
	//    97:	QIWI
	//    98:	Trustly
	//    99:	KNET (Adyen)
	//    100:	PagoEfectivo (EBANX)
	//    102:	Tinkoff
	//    200: M-Pesa
	PayType string `json:"payType,omitempty"`

	// Transaction order ID.
	PayOrderID string `json:"payOrderId,omitempty"`

	// Order ID generated by the Huawei IAP server during fee deduction for the previous renewal.
	// The parameter value is the same as that of orderId when a subscription is purchased for the first time.
	LastOrderID string `json:"lastOrderId"`

	// ID of the subscription group to which a subscription belongs.
	ProductGroup string `json:"productGroup,omitempty"`

	// Timestamp of the first fee deduction time, which is the number of
	// milliseconds from 00:00:00 on January 1, 1970 to the first successful fee deduction time.
	OriPurchaseTime int64 `json:"oriPurchaseTime,omitempty"`

	// Subscription ID.
	//
	// NOTE: This parameter uniquely identifies the mapping between a product and a user. It does not change when the subscription is renewed.
	SubscriptionID string `json:"subscriptionId,omitempty"`

	// Original subscription ID. If this value is not empty, the current subscription is switched from another one.
	// It can be linked to the original subscription information.
	OriSubscriptionID string `json:"oriSubscriptionId,omitempty"`

	// Purchase quantity.
	Quantity int64 `json:"quantity,omitempty"`

	// Days of a paid subscription, excluding the free trial period and promotion period.
	DaysLasted int64 `json:"daysLasted,omitempty"`

	// Number of successful renewal periods. How many time the subscription has been renewed, excludes promotion.
	// If the value is 0 or does not exist, no renewal has been performed successfully.
	NumOfPeriods int64 `json:"numOfPeriods,omitempty"`

	// Number of successful renewal periods with promotion.
	NumOfDiscount int64 `json:"numOfDiscount,omitempty"`

	// Timestamp of the subscription expiration time. In milliseconds.
	//
	// For an automatic renewal receipt where the fee has been deducted successfully, this time indicates the renewal date or expiration date.
	// If the value is a past time, the subscription has expired.
	ExpirationDate int64 `json:"expirationDate,omitempty"`

	// Reason why a subscription expires. Possible values are:
	//    1: canceled by a user
	//    2: product being unavailable
	//    3: abnormal user signing information
	//    4: billing error
	//    5: price increase disagreed with by a user
	//    6: unknown error
	// If there are multiple exceptions, a smaller number indicates a higher priority (1 > 2 > 3...).
	ExpirationIntent int64 `json:"expirationIntent,omitempty"`

	// Indicates whether the system is still trying to renew an expired subscription. Possible values are:
	//    0: no
	//    1: yes
	RetryFlag int64 `json:"retryFlag,omitempty"`

	// Indicates whether a subscription is in a renewal period with promotion. Possible values are:
	//    0: no
	//    1: yes
	IntroductoryFlag int64 `json:"introductoryFlag,omitempty"`

	// Indicates whether a subscription is in a free trial period. Possible values are:
	//    0: no
	//    1: yes
	TrialFlag int64 `json:"trialFlag,omitempty"`

	// Time when a subscription is revoked. A refund is made and the service is unavailable immediately.
	// This value is returned when a user:
	//    a. makes a complaint and revokes a subscription through the customer service personnel; or
	//    b. performs subscription upgrade or crossgrade that immediately takes effect and revokes the previous subscription.
	// Note: If a receipt is revoked, it is deemed that the purchase is not complete.
	CancelTime int64 `json:"cancelTime,omitempty"`

	// Cause of subscription cancellation. Possible values are:
	//    0: other causes. For example, a user mistakenly purchases a subscription and has to cancel it.
	//    1: A user encounters a problem within the app and cancels the subscription.
	//    2: A user performs subscription upgrade or crossgrade.
	// Note: If this parameter is left empty but the cancelTime parameter has a value,
	// the cancellation is caused by an operation such as upgrade.
	CancelReason int64 `json:"cancelReason,omitempty"`

	// App information. This parameter is reserved.
	AppInfo string `json:"appInfo,omitempty"`

	// Indicates whether a user has disabled the subscription notification function. Possible values are:
	//    0: no
	//    1: yes
	// If the user disables the subscription notification function, no subscription notification will be sent to this user.
	NotifyClosed int64 `json:"notifyClosed,omitempty"`

	// Renewal status. Possible values are:
	//    1: The subscription renewal is normal.
	//    0: The user cancels subscription renewal.
	// For auto-renewable subscriptions, this parameter is valid for both valid and expired subscriptions. However, it does not represent users' subscription status. Generally, when the value is 0, the app can provide other subscription options for the user, for example, recommending another subscription with a lower level in the same group. The value 0 indicates that a user proactively cancels the subscription.
	RenewStatus int64 `json:"renewStatus,omitempty"`

	// User opinion on the price increase of a product. Possible values are:
	//    1: The user has agreed with the price increase.
	//    0: The user does not take any action. After the subscription expires, it becomes invalid.
	PriceConsentStatus int64 `json:"priceConsentStatus,omitempty"`

	// Price used upon the next renewal. It is provided as a reference for users when the priceConsentStatus parameter is returned.
	RenewPrice int64 `json:"renewPrice,omitempty"`

	// true: A user has been charged for a product, the product has not expired, and no refund has been made. In this case, you can provide services for the user.
	// false: The purchase of a product is not finished, the product has expired, or a refund has been made for the product after its purchase.
	//
	// NOTE
	// If a user has canceled a subscription, the subIsvalid parameter value is still true until the subscription expires.
	SubIsValid bool `json:"subIsvalid,omitempty"`

	// Indicates whether to postpone the settlement date.
	//    1: yes
	DeferFlag int64 `json:"deferFlag,omitempty"`

	// Subscription cancellation initiator. Possible values are:
	//    0: user
	//    1: developer
	//    2: Huawei
	CancelWay int64 `json:"cancelWay,omitempty"`

	// Timestamp (milliseconds in UTC) when you set a subscription renewal to be stopped in the future.
	// The subscription is still valid within the validity period, but the renewal will be stopped in the future. No refund is required.
	// NOTE:
	// cancelWay and cancellationTime are displayed when a subscription renewal stops (no refund is involved).
	CancellationTime int64 `json:"cancellationTime,omitempty"`

	// Number of days for retaining a subscription relationship after the subscription is canceled.
	CancelledSubKeepDays int64 `json:"cancelledSubKeepDays,omitempty"`

	// Timestamp (milliseconds in UTC) when a paused subscription is resumed.
	ResumeTime int64 `json:"resumeTime,omitempty"`

	// Cancellation reason. Possible values are:
	//    0: others
	//    1: too high fee
	//    2: technical problem, for example, product not provided
	//    5: in the blocklist because of fraud
	//    7: subscription switchover
	//    9: service being rarely used and not required
	//    10: other better apps
	SurveyReason int64 `json:"surveyReason,omitempty"`

	// When the value of surveyReason is 0, this parameter is used to collect the cancellation reason entered by users.
	SurveyDetails string `json:"surveyDetails,omitempty"`

	// UTC timestamp (in milliseconds) when the grace period of a subscription ends.
	GraceExpirationTime int64 `json:"graceExpirationTime,omitempty"`
}

InAppPurchaseData json model. Used when requesting In-App order and / or subscription verification. https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133

type MerchantPurchaseList added in v1.26.3

type MerchantPurchaseList struct {
	// Result code. Possible values are:
	//    0: success
	//    Other values: failure. For details about the result codes, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248
	ResponseCode string `json:"responseCode"`

	// Response description.
	ResponseMessage string `json:"responseMessage,omitempty"`

	// List of canceled or refunded purchase information, in JSON strings. Each string indicates a purchase record.
	//
	// For details about the purchase information format, please refer to CanceledPurchase{}
	OrderInfoList []OrderInfoList `json:"orderInfoList,omitempty"`

	// Token to query data on the next page. If a value is returned, pass it in the next query request to query data on the next page.
	ContinuationToken string `json:"continuationToken,omitempty"`
}

MerchantPurchaseList response from query canceled or refunded purchase list

Document:https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-application-query-orderinfo-0000001431190629#section86486220462

type ModifySubscriptionResponse

type ModifySubscriptionResponse struct {
	ResponseCode      string `json:"responseCode"`
	ResponseMessage   string `json:"responseMessage,omitempty"`
	NewExpirationTime int64  `json:"newExpirationTime,omitempty"`
}

ModifySubscriptionResponse JSON response from {rootUrl}/sub/applications/v2/purchases/stop|delay|returnFee|withdrawal

type OrderInfoList added in v1.26.3

type OrderInfoList struct {
	//Huawei order ID.
	OrderNo string `json:"orderNo"`

	//Merchant request ID.
	RequestID string `json:"requestId"`

	//Country or region code, which is used to identify a country or region. The value must comply with the ISO 3166 standard.
	Country string `json:"country"`

	//Merchant ID.
	MerchantID string `json:"merchantId"`

	//App ID.
	ApplicationID string `json:"applicationId"`

	//Time when an order is placed. The value is a UTC timestamp, in milliseconds.
	OrderTime int64 `json:"orderTime"`

	//Payment time. The value is a UTC timestamp, in milliseconds.
	TradeTime int64 `json:"tradeTime"`

	//Product ID.
	ProductID string `json:"productId"`

	//Product name.
	ProductName string `json:"productName"`

	//Payment amount. The unit is dependent on the currency.
	PayMoney string `json:"payMoney"`

	//Coupon amount. The unit is dependent on the currency.
	CouponAmt string `json:"couponAmt"`

	//Deduction amount converted from bonus points. The unit is dependent on the currency.
	MpAmt string `json:"mpAmt"`

	//Refund amount converted from bonus points. The unit is dependent on the currency.
	MpRfdAmt string `json:"mpRfdAmt"`

	//Currency.
	Currency string `json:"currency"`

	//Payment method. For details about its values, please refer to the PayType table at the bottom of the Data Models section.
	PayType int `json:"payType"`

	//Order status. The options are as follows:
	//
	//0: paid
	//1: refunded
	//2: payment failed
	//3: refund failed
	//4: unpaid
	//5: refunding
	TradeState int `json:"tradeState"`

	//Transaction type. The options are as follows:
	//
	//PURCHASE: payment
	//REFUND: refund
	TradeType string `json:"tradeType"`

	//Refund time. The value is a UTC timestamp, in milliseconds.
	RefundTime int64 `json:"refundTime"`

	//Refund amount. The unit is dependent on the currency.
	RefundMoney string `json:"refundMoney"`
}

type OrderNotification added in v1.26.3

type OrderNotification struct {
	//Notification service version, which is set to v2.
	Version string `json:"version,omitempty"`

	// Notification type. The value can be:
	//1: successful payment
	//2: successful refund
	NotificationType int64 `json:"notificationType"`

	// Subscription token, which matches a unique subscription ID.
	PurchaseToken string `json:"purchaseToken"`

	// Product ID.
	ProductID string `json:"productId"`
}

OrderNotification JSON content when unmarshal NotificationRequest.OrderNotification https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-notifications-about-subscription-events-v2-0000001385268541

type OrderVerifyResponse

type OrderVerifyResponse struct {
	ResponseCode      string `json:"responseCode"`                // Response code, if = "0" means succeed, for others see https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248
	ResponseMessage   string `json:"responseMessage,omitempty"`   // Response descriptions, especially when error
	PurchaseTokenData string `json:"purchaseTokenData,omitempty"` // InappPurchaseData JSON string
	DataSignature     string `json:"dataSignature,omitempty"`     // Signature to verify PurchaseTokenData string
}

OrderVerifyResponse JSON response from {rootUrl}/applications/purchases/tokens/verify

type StatusUpdateNotification

type StatusUpdateNotification struct {
	// Environment for sending a notification. Value could be one of either:
	//    "PROD": general production environment
	//    "SandBox": sandbox testing environment
	Environment string `json:"environment"`

	// Notification event type. For details, please refer to const NotificationTypeInitialBuy etc.
	NotificationType int64 `json:"notificationType"`

	// Subscription ID
	SubscriptionID string `json:"subscriptionId"`

	// Subscription token, which matches a unique subscription ID.
	PurchaseToken string `json:"purchaseToken"`

	// Timestamp, which is passed only when notificationType is CANCEL(1).
	CancellationDate int64 `json:"cancellationDate,omitempty"`

	// Order ID used for payment during subscription renewal.
	OrderID string `json:"orderId"`

	// PurchaseToken of the latest receipt, which is passed only when notificationType is INITIAL_BUY(0), RENEWAL(2), or INTERACTIVE_RENEWAL(3) and the renewal is successful.
	LatestReceipt string `json:"latestReceipt,omitempty"`

	// Latest receipt, which is a JSON string. This parameter is left empty when notificationType is CANCEL(1).
	// For details about the parameters contained, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-data-model-0000001050986133#EN-US_TOPIC_0000001050986133__section264617465219
	LatestReceiptInfo string `json:"latestReceiptInfo,omitempty"`

	// Signature string for the LatestReceiptInfo parameter. The signature algorithm is SHA256withRSA.
	//
	// After your server receives the signature string, you need to use the public payment key to verify the signature of LatestReceiptInfo in JSON format.
	// For details, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/verifying-signature-returned-result-00000010500330885
	//
	// For details about how to obtain the public key, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/query-payment-info-0000001050166299
	LatestReceiptInfoSignature string `json:"latestReceiptInfoSignature,omitempty"`

	// Token of the latest expired receipt. This parameter has a value only when NotificationType is RENEWAL(2) or INTERACTIVE_RENEWAL(3).
	LatestExpiredReceipt string `json:"latestExpiredReceipt,omitempty"`

	// Latest expired receipt, which is a JSON string. This parameter has a value only when NotificationType is RENEWAL(2) or INTERACTIVE_RENEWAL(3).
	LatestExpiredReceiptInfo string `json:"latestExpiredReceiptInfo,omitempty"`

	// Signature string for the LatestExpiredReceiptInfo parameter. The signature algorithm is SHA256withRSA.
	//
	// After your server receives the signature string, you need to use the public payment key to verify the signature of LatestExpiredReceiptInfo in JSON format.
	// For details, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/verifying-signature-returned-result-0000001050033088
	//
	// For details about how to obtain the public key, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/query-payment-info-0000001050166299
	LatestExpiredReceiptInfoSignature string `json:"latestExpiredReceiptInfoSignature,omitempty"`

	// Signature algorithm
	SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"`

	// Renewal status. Value could be one of either:
	//    1: The subscription renewal is normal.
	//    0: The user has canceled subscription renewal.
	AutoRenewStatus int64 `json:"autoRenewStatus"`

	// Refund order ID. This parameter has a value only when NotificationType is CANCEL(1).
	RefundPayOrderID string `json:"refundPayOrderId,omitempty"`

	// Product ID.
	ProductID string `json:"productId"`

	// App ID.
	ApplicationID string `json:"applicationId,omitempty"`

	// Expiration reason. This parameter has a value only when NotificationType is RENEWAL(2) or INTERACTIVE_RENEWAL(3), and the renewal is successful.
	ExpirationIntent int64 `json:"expirationIntent,omitempty"`
}

StatusUpdateNotification JSON content when unmarshal NotificationRequest.StatusUpdateNotification https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-notifications-about-subscription-events-0000001050706084#EN-US_TOPIC_0000001050706084__section18290165220716

type SubNotification added in v1.26.3

type SubNotification struct {
	//Notification service version, which is set to v2.
	Version string `json:"version,omitempty"`

	//Notification message, in JSON format. For details, please refer to statusUpdateNotification.
	StatusUpdateNotification string `json:"statusUpdateNotification"`

	// Signature string of the statusUpdateNotification field. Find the signature algorithm from the value of signatureAlgorithm.
	//After your server receives the signature string, you need to use the IAP public key to verify the signature of statusUpdateNotification (in JSON format). For details, please refer to Verifying the Signature in the Returned Result.
	//For details about how to obtain the public key, please refer to Querying IAP Information.
	NotificationSignature string `json:"notificationSignature"`

	//Signature algorithm.
	SignatureAlgorithm string `json:"signatureAlgorithm"`
}

SubNotification JSON content when unmarshal NotificationRequest.SubNotification https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-notifications-about-subscription-events-v2-0000001385268541

type SubscriptionNotification

type SubscriptionNotification struct {
	// Notification message, which is a JSON string. For details, please refer to statusUpdateNotification.
	StatusUpdateNotification string `json:"statusUpdateNotification"`

	// Signature string for the StatusUpdateNotification parameter. The signature algorithm is SHA256withRSA.
	//
	// After your server receives the signature string, you need to use the public payment key to verify the signature of StatusUpdateNotification in JSON format.
	// For details, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/verifying-signature-returned-result-0000001050033088
	//
	// For details about how to obtain the public key, please refer to https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/query-payment-info-0000001050166299
	NotifycationSignature string `json:"notifycationSignature"`

	// Notification service version, which is set to v2.
	Version string `json:"version,omitempty"`

	// Signature algorithm
	SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"`
}

SubscriptionNotification Request parameters when a developer server is called by HMS API.

https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-notifications-about-subscription-events-0000001050706084

type SubscriptionNotificationV2 added in v1.26.3

type SubscriptionNotificationV2 struct {
	// Notification service version, which is set to v2.
	Version string `json:"version,omitempty"`

	//Notification type. The value can be:
	//ORDER: order
	//SUBSCRIPTION: subscription
	EventType string `json:"eventType,omitempty"`

	//Timestamp of the time when a notification is sent (in UTC), which is the number of milliseconds from 00:00:00 on January 1, 1970 to the time when the notification is sent.
	NotifyTime int64 `json:"notifyTime,omitempty"`

	//App ID.
	ApplicationID string `json:"applicationId,omitempty"`
	// Content of an order notification, which is returned when eventType is ORDER.
	OrderNotification OrderNotification `json:"orderNotification,omitempty"`

	//Content of a subscription notification, which is returned when eventType is SUBSCRIPTION.
	SubNotification SubNotification `json:"subNotification,omitempty"`
}

SubscriptionNotificationV2 Request parameters when a developer server is called by HMS API.

https://developer.huawei.com/consumer/en/doc/HMSCore-References/api-notifications-about-subscription-events-v2-0000001385268541

type SubscriptionVerifyResponse

type SubscriptionVerifyResponse struct {
	ResponseCode      string `json:"responseCode"`                // Response code, if = "0" means succeed, for others see https://developer.huawei.com/consumer/en/doc/HMSCore-References/server-error-code-0000001050166248
	ResponseMessage   string `json:"responseMessage,omitempty"`   // Response descriptions, especially when error
	InappPurchaseData string `json:"inappPurchaseData,omitempty"` // InappPurchaseData JSON string
}

SubscriptionVerifyResponse JSON response after requested {rootUrl}/sub/applications/v2/purchases/get

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL