public void Pay(string payid, Action <PaymentResult> action) { paymentResultCallback = action; if (jc == null) { //如果未接sdk,则模拟一个支付成功的结果 PaymentResult result = new PaymentResult(); result.code = "100"; result.payid = payid; result.text = "test data."; paymentResultCallback?.Invoke(result); } else { jc.CallStatic("payment", payid, ""); } }
//支付回调 private void OnPay(string buf) { PaymentResult result = JsonUtility.FromJson <PaymentResult>(buf); paymentResultCallback?.Invoke(result); }