public string GetPayload(Transaction transaction) { var data = Johny.HashtablePool.Claim(); data["orderId"] = EB.Encoding.ToHexString(EB.Crypto.RandomBytes(32)); data["productId"] = transaction.productId; data["algorithm"] = "sha1"; var bytes = Encoding.GetBytes(JSON.Stringify(data)); var hmac = Hmac.Sha1(Encoding.GetBytes(_config.PublicKey)); var payload = SignedRequest.Stringify(bytes, hmac); return(payload); }
public string GetPayload(Transaction transaction) { var data = new Hashtable(); data["orderId"] = EB.Encoding.ToHexString(EB.Crypto.RandomBytes(32)); data["productId"] = transaction.productId; data["algorithm"] = "sha1"; var bytes = Encoding.GetBytes(JSON.Stringify(data)); var hmac = Hmac.Sha1(Encoding.GetBytes(_config.PublicKey)); var payload = SignedRequest.Stringify(bytes, hmac); EB.Debug.Log("---Apple---GetPayload():这里是苹果版本的支付信息,但是不知道是否有地方调用"); return(payload); }
public void PurchaseItem(Item item) { var data = Johny.HashtablePool.Claim(); data["orderId"] = EB.Encoding.ToHexString(EB.Crypto.RandomBytes(32)); data["productId"] = item.productId; data["algorithm"] = "sha1"; if (!string.IsNullOrEmpty(item.LimitedTimeGiftId)) { data["limitedTimeGiftId"] = item.LimitedTimeGiftId; } var bytes = Encoding.GetBytes(JSON.Stringify(data)); var hmac = Hmac.Sha1(Encoding.GetBytes(_config.PublicKey)); var payload = SignedRequest.Stringify(bytes, hmac); Transaction transaction = new Transaction(); transaction.transactionId = data["orderId"].ToString(); transaction.payload = payload; transaction.productId = item.productId; if (!string.IsNullOrEmpty(item.LimitedTimeGiftId)) { transaction.limitedTimeGiftId = item.LimitedTimeGiftId; } if (_config.Verify != null) { _config.Verify(transaction); } else { Complete(transaction); } }
public Manager(Config config) { if (Enabled == true) { _config = config; _rpcs = Johny.HashtablePool.Claim(); _deferred = new EB.Deferred(8); _updateHandle = EB.Coroutines.SetUpdate(_deferred.Dispatch); // load certs //EB.Net.TcpClientFactory.LoadCertStore("Crypto/Certs"); // make the signed request Hashtable data = Johny.HashtablePool.Claim(); data["_id"] = EB.Version.GetMACAddress(); data["type"] = Application.platform.ToString(); data["game"] = _config.game; data["last"] = EB.Time.Now; data["algorithm"] = "hmac-sha1"; var json = EB.JSON.Stringify(data); var key = SignedRequest.Stringify(Encoding.GetBytes(json), Hmac.Sha1(Encoding.GetBytes(_config.serverKey))); var url = _config.serverUrl + "?access_token=" + key; _wsUrl = new EB.Uri(url); Debug.Log("GameTalk Url: " + url); _socket = new EB.Net.TalkWebSocket(); _socket.OnError += this.OnError; _socket.OnRPC += this.OnRPC; Bind(string.Empty, new RPC.Global()); ConnectIfNeeded(); } }