Documentation
¶
Index ¶
- Constants
- Variables
- type AtResponse
- type CallbackType
- type OrderNotification
- type Pay
- func (p *Pay) BuildAuthorization() (string, error)
- func (p *Pay) ConfirmPurchase(purchaseToken, productId string, accountFlag int)
- func (p *Pay) DealNotification(information string) (err error)
- func (p *Pay) GetAppAt() (string, error)
- func (p *Pay) SendRequest(url string, bodyMap map[string]string) (string, error)
- func (p *Pay) VerifyRsaSign(content string, sign string, publicKey string) error
- func (p *Pay) VerifyToken(purchaseToken, productId string, accountFlag int) (res *PurchaseTokenData, err error)
- type PurchaseTokenData
- type StatusUpdateNotification
- type SubNotification
- type VerifyTokenRes
Constants ¶
View Source
const ( INITIAL_BUY = 0 CANCEL = 1 RENEWAL = 2 INTERACTIVE_RENEWAL = 3 NEW_RENEWAL_PREF = 4 RENEWAL_STOPPED = 5 RENEWAL_RESTORED = 6 RENEWAL_RECURRING = 7 ON_HOLD = 9 PAUSED = 10 PAUSE_PLAN_CHANGED = 11 PRICE_CHANGE_CONFIRMED = 12 DEFERRED = 13 )
View Source
const (
TokenUrl = "https://oauth-login.cloud.huawei.com/oauth2/v3/token"
)
Variables ¶
View Source
var RequestHttpClient = http.Client{Timeout: time.Second * 5}
default http client with 5 seconds timeout
Functions ¶
This section is empty.
Types ¶
type AtResponse ¶
type AtResponse struct {
AccessToken string `json:"access_token"`
}
type CallbackType ¶
type CallbackType struct {
Version string `json:"version"`
NotifyTime int64 `json:"notifyTime"`
EventType string `json:"eventType"`
ApplicationId string `json:"applicationId"`
OrderNotification *OrderNotification `json:"orderNotification"`
SubNotification *SubNotification `json:"subNotification"`
}
type OrderNotification ¶
type Pay ¶
type Pay struct {
ClientSecret string `json:"client_secret"`
ClientId string `json:"client_id"`
//TokenUrl string `json:"token_url"`
ApplicationPublicKey string `json:"application_public_key"`
}
func (*Pay) BuildAuthorization ¶
func (*Pay) ConfirmPurchase ¶
ConfirmPurchase 发货后确认购买接口(华为支付)消耗商品 功能:通知华为支付平台当前订单已完成发货,触发支付完成流程(需在商品实际发货后调用) 参数说明:
purchaseToken: 华为支付返回的购买令牌(唯一标识一笔具体的购买交易,由客户端支付成功后返回) productId: 应用内商品的唯一标识(需与客户端发起支付时使用的productId一致) accountFlag: 账户标识(用于区分不同账户体系/环境,如0-普通用户、1-企业用户,具体值由业务定义)
func (*Pay) DealNotification ¶
func (*Pay) SendRequest ¶
func (*Pay) VerifyRsaSign ¶
func (*Pay) VerifyToken ¶
func (p *Pay) VerifyToken(purchaseToken, productId string, accountFlag int) (res *PurchaseTokenData, err error)
VerifyToken 验证回调订单 您可以调用本接口向华为应用内支付服务器校验支付结果中的购买令牌,确认支付结果的准确性。
type PurchaseTokenData ¶
type PurchaseTokenData struct {
AutoRenewing bool `json:"autoRenewing" dc:"表示订阅是否自动续费"`
OrderId string `json:"orderId" dc:"订单ID,唯一标识一笔订单"`
PackageName string `json:"packageName" dc:"应用的包名"`
ApplicationId int `json:"applicationId" dc:"应用ID,以整数形式表示"`
ApplicationIdString string `json:"applicationIdString" dc:"应用ID的字符串形式"`
Kind int `json:"kind" dc:"购买类型的某种标识,具体含义可能取决于业务逻辑"`
ProductId string `json:"productId" dc:"商品ID,用于标识购买的商品"`
ProductName string `json:"productName" dc:"商品名称"`
PurchaseTime int64 `json:"purchaseTime" dc:"购买时间,可能是某种特定格式的时间表示"`
PurchaseTimeMillis int64 `json:"purchaseTimeMillis" dc:"购买时间,以毫秒为单位的时间戳"`
PurchaseState int `json:"purchaseState" dc:"购买状态,不同的整数值代表不同的状态,具体含义取决于业务逻辑"`
DeveloperPayload string `json:"developerPayload" dc:"开发者自定义负载数据"`
PurchaseToken string `json:"purchaseToken" dc:"购买令牌"`
ResponseCode string `json:"responseCode" dc:"响应代码,用于表示购买操作的响应结果"`
ConsumptionState int `json:"consumptionState" dc:"消费状态,不同的整数值代表不同的消费状态,具体含义取决于业务逻辑"`
Confirmed int `json:"confirmed" dc:"确认状态,不同的整数值代表不同的确认情况,具体含义取决于业务逻辑"`
PurchaseType int `json:"purchaseType" dc:"购买类型,不同的整数值代表不同的购买类型,具体含义取决于业务逻辑"`
Currency string `json:"currency" dc:"货币类型"`
Price int `json:"price" dc:"商品价格"`
Country string `json:"country" dc:"购买所在国家"`
PayOrderId string `json:"payOrderId" dc:"支付订单ID"`
PayType string `json:"payType" dc:"支付类型"`
SdkChannel string `json:"sdkChannel" dc:"SDK渠道"`
}
type StatusUpdateNotification ¶
type StatusUpdateNotification struct {
Environment string `json:"environment" dc:"发送通知的环境。PROD:正式环境;Sandbox:沙盒测试"`
NotificationType int `json:"notificationType" dc:"通知事件的类型,具体定义需参考相关文档说明"`
SubscriptionID string `json:"subscriptionId" dc:"订阅ID"`
CancellationDate int64 `` /* 159-byte string literal not displayed */
OrderID string `` /* 255-byte string literal not displayed */
LatestReceipt string `` /* 166-byte string literal not displayed */
LatestReceiptInfo string `` /* 166-byte string literal not displayed */
LatestReceiptInfoSignature string `` /* 329-byte string literal not displayed */
LatestExpiredReceipt string `json:"latestExpiredReceipt" dc:"最近的一笔过期收据的token"`
LatestExpiredReceiptInfo string `` /* 155-byte string literal not displayed */
LatestExpiredReceiptInfoSignature string `` /* 350-byte string literal not displayed */
AutoRenewStatus int `json:"autoRenewStatus" dc:"续期状态。取值说明:1:当前周期到期后正常续期;0:用户已终止续期"`
RefundPayOrderId string `json:"refundPayOrderId" dc:"退款交易号,在notificationType取值为CANCEL时有值"`
ProductID string `json:"productId" dc:"订阅型商品ID"`
ApplicationID string `json:"applicationId" dc:"应用ID"`
ExpirationIntent int `` /* 134-byte string literal not displayed */
PurchaseToken string `json:"purchaseToken" dc:"订阅token,与上述订阅ID字段subscriptionId对应。"`
}
StatusUpdateNotification 订阅状态更新通知
type SubNotification ¶
type SubNotification struct {
StatusUpdateNotification *StatusUpdateNotification `json:"statusUpdateNotification" dc:"通知消息"`
NotificationSignature string `` /* 145-byte string literal not displayed */
Version string `json:"version" dc:"通知版本:v2"`
SignatureAlgorithm string `json:"signatureAlgorithm" dc:"签名算法。"`
}
Click to show internal directories.
Click to hide internal directories.