/** * java -> jni -> c# 的第一个函数 */ private static int willPayFunction(IntPtr jListener, IntPtr jOrder, IntPtr jApi, IntPtr jTicket) { object l = GCNativeKeeper.getInstance().find(jListener); AndroidOnPayListener callback = (AndroidOnPayListener)l; string ticket = AndroidJNI.GetStringUTFChars(jTicket); return(callback.onWillPay(ticket) ? 1 : 0); }
private static void payEndFunction(IntPtr jListener, IntPtr jOrder, IntPtr jApi, IntPtr jResult) { object l = GCNativeKeeper.getInstance().unKeep(jListener); AndroidOnPayListener callback = (AndroidOnPayListener)l; AndroidPayResult result = new AndroidPayResult(jResult); AndroidOrder order = callback.PayOrder; AndroidPayApi api = callback.PayApi; PaySDKStatus status = toPayStatus(result.getPayCode()); string ticketId = order.getTicketId(); int channelErrorCode = toInt(result.getPayChannelCode()); string channelErrorDes = result.getPayChannelMessage(); callback.onPayEnd(status, ticketId, channelErrorCode, channelErrorDes); }
private void payInner(AndroidOrder order, AndroidOnPayListener callback) { CxxJavaObject.callJavaStart(); IntPtr jApi = getLocalJavaObject(); IntPtr jApiClazz = CxxJavaObject.getJavaClass(jApi); IntPtr jApiPayMethod = CxxJavaObject.getJavaMethodID(jApiClazz, "pay", "(Lcom/mob/paysdk/Order;Lcom/mob/paysdk/OnPayListener;)V"); IntPtr jorder = order.getLocalJavaObject(); AndroidOnPayListener cxx = callback; IntPtr jListener = cxx.getLocalJavaObject(); IntPtr gRef = cxx.getJavaObject(); GCNativeKeeper.getInstance().keep(gRef, cxx); AndroidJNI.CallVoidMethod(jApi, jApiPayMethod, CxxJavaObject.createJavaParam(jorder, jListener)); CxxJavaObject.callJavaEnd(); }