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.
88 lines
2.7 KiB
88 lines
2.7 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 (
|
||
|
|
"log"
|
||
|
|
)
|
||
|
|
|
||
|
|
const (
|
||
|
|
URL_ORDER_STATUS_QUERY = "/order/harmony/v1/application/order/status/query"
|
||
|
|
|
||
|
|
URL_ORDER_SHIPPED_CONFIRM = "/order/harmony/v1/application/purchase/shipped/confirm"
|
||
|
|
)
|
||
|
|
|
||
|
|
type OrderService struct {
|
||
|
|
IapServer
|
||
|
|
}
|
||
|
|
|
||
|
|
// OrderStatusQuery This API is used to query the latest status of a consumable or non-consumable order.
|
||
|
|
// 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 (orderService *OrderService) OrderStatusQuery(purchaseOrderId string, purchaseToken string) (resp string, err error) {
|
||
|
|
bodyMap := make(map[string]interface{})
|
||
|
|
bodyMap["purchaseOrderId"] = purchaseOrderId
|
||
|
|
bodyMap["purchaseToken"] = purchaseToken
|
||
|
|
|
||
|
|
resp, err = orderService.httpPost(URL_ROOT+URL_ORDER_STATUS_QUERY, bodyMap)
|
||
|
|
if err != nil {
|
||
|
|
// TODO: Need to replace it with the actual business logic.
|
||
|
|
log.Print("Error:", err)
|
||
|
|
} else {
|
||
|
|
// TODO: Need to replace it with the actual business logic.
|
||
|
|
log.Print("order status query response is: ", resp)
|
||
|
|
}
|
||
|
|
return resp, err
|
||
|
|
}
|
||
|
|
|
||
|
|
// OrderShippedConfirm This API is used to acknowledge that a purchased consumable or non-consumable has been delivered.
|
||
|
|
// 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 (orderService *OrderService) OrderShippedConfirm(purchaseOrderId string, purchaseToken string) {
|
||
|
|
bodyMap := make(map[string]interface{})
|
||
|
|
bodyMap["purchaseOrderId"] = purchaseOrderId
|
||
|
|
bodyMap["purchaseToken"] = purchaseToken
|
||
|
|
resp, err := orderService.httpPost(URL_ROOT+URL_ORDER_SHIPPED_CONFIRM, bodyMap)
|
||
|
|
if err != nil {
|
||
|
|
// TODO: Need to replace it with the actual business logic.
|
||
|
|
log.Print("Error:", err)
|
||
|
|
}
|
||
|
|
// TODO: Need to replace it with the actual business logic.
|
||
|
|
log.Print("order shipped confirm response is: ", resp)
|
||
|
|
}
|