You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.6 KiB
85 lines
2.6 KiB
|
2 weeks ago
|
/*
|
||
|
|
* Copyright 2024. Huawei Technologies Co., Ltd. All rights reserved.
|
||
|
|
*
|
||
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
|
* you may not use this file except in compliance with the License.
|
||
|
|
* You may obtain a copy of the License at
|
||
|
|
*
|
||
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
*
|
||
|
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
|
* See the License for the specific language governing permissions and
|
||
|
|
* limitations under the License.
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
|
||
|
|
package harmonyos
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
)
|
||
|
|
|
||
|
|
const (
|
||
|
|
URL_SUB_STATUS_QUERY = "/subscription/harmony/v1/application/subscription/status/query"
|
||
|
|
|
||
|
|
URL_SUB_SHIPPED_CONFIRM = "/subscription/harmony/v1/application/purchase/shipped/confirm"
|
||
|
|
)
|
||
|
|
|
||
|
|
type SubscriptionService struct {
|
||
|
|
IapServer
|
||
|
|
}
|
||
|
|
|
||
|
|
// SubStatusQuery This API is used to query the latest status of an auto-renewable subscription.
|
||
|
|
// Params:
|
||
|
|
//
|
||
|
|
// purchaseOrderId: Order ID of a purchase.
|
||
|
|
// purchaseToken: Purchase token of a product, which you can obtain from the information returned after a purchase or an order query.
|
||
|
|
//
|
||
|
|
// Return:
|
||
|
|
//
|
||
|
|
// nil
|
||
|
|
//
|
||
|
|
// Exception:
|
||
|
|
//
|
||
|
|
// nil
|
||
|
|
func (subService *SubscriptionService) SubStatusQuery(purchaseOrderId string, purchaseToken string) {
|
||
|
|
bodyMap := make(map[string]interface{})
|
||
|
|
bodyMap["purchaseOrderId"] = purchaseOrderId
|
||
|
|
bodyMap["purchaseToken"] = purchaseToken
|
||
|
|
resp, err := subService.httpPost(URL_ROOT+URL_SUB_STATUS_QUERY, bodyMap)
|
||
|
|
if err != nil {
|
||
|
|
// TODO: Need to replace it with the actual business logic.
|
||
|
|
fmt.Println("Error:", err)
|
||
|
|
}
|
||
|
|
// TODO: Need to replace it with the actual business logic.
|
||
|
|
fmt.Println("sub status query response is:", resp)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SubShippedConfirm This API is used to acknowledge that a purchased subscription has been delivered to the user.
|
||
|
|
// Params:
|
||
|
|
//
|
||
|
|
// purchaseOrderId: Order ID of a purchase.
|
||
|
|
// purchaseToken: Purchase token of a product, which you can obtain from the information returned after a purchase or an order query.
|
||
|
|
//
|
||
|
|
// Return:
|
||
|
|
//
|
||
|
|
// nil
|
||
|
|
//
|
||
|
|
// Exception:
|
||
|
|
//
|
||
|
|
// nil
|
||
|
|
func (subService *SubscriptionService) SubShippedConfirm(purchaseOrderId string, purchaseToken string) {
|
||
|
|
// pack the request body
|
||
|
|
bodyMap := make(map[string]interface{})
|
||
|
|
bodyMap["purchaseOrderId"] = purchaseOrderId
|
||
|
|
bodyMap["purchaseToken"] = purchaseToken
|
||
|
|
resp, err := subService.httpPost(URL_ROOT+URL_SUB_SHIPPED_CONFIRM, bodyMap)
|
||
|
|
if err != nil {
|
||
|
|
// TODO: Need to replace it with the actual business logic.
|
||
|
|
}
|
||
|
|
// TODO: Need to replace it with the actual business logic.
|
||
|
|
fmt.Println("sub shipped confirm response is:", resp)
|
||
|
|
}
|