/**
         * 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);
        }
        public static AndroidOnPayListener create(AndroidPayApi api, AndroidOrder order, PaySDKHandler handler)
        {
            AndroidOnPayListener l = new AndroidOnPayListener();

            l.PayOrder      = order;
            l.PayApi        = api;
            l.OnPayListener = handler;
            return(l);
        }
Пример #3
0
        public void payWithTicketId(string ticketId, PaySDKChannel channel, PaySDKHandler handler)
        {
            AndroidTicketOrder aOrder = new AndroidTicketOrder();

            aOrder.setTicketId(ticketId);
            AndroidPayApi        api      = createPayApi(channel);
            AndroidOnPayListener listener = AndroidOnPayListener.create(api, aOrder, handler);

            api.pay(aOrder, listener);
        }
        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);
        }
Пример #5
0
        public void payWithOrder(PaySDKOrder order, PaySDKChannel channel, PaySDKHandler handler)
        {
            AndroidPayOrder aOrder = new AndroidPayOrder();

            aOrder.setAmount((int)order.amount);
            aOrder.setBody(order.body);
            aOrder.setDescription(order.des);
            aOrder.setMetadata(order.metadata);
            aOrder.setOrderNo(order.orderId);
            aOrder.setSubject(order.subject);
            AndroidPayApi        api      = createPayApi(channel);
            AndroidOnPayListener listener = AndroidOnPayListener.create(api, aOrder, handler);

            api.pay(aOrder, listener);
        }
Пример #6
0
        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();
        }
Пример #7
0
 public void pay(AndroidPayOrder order, AndroidOnPayListener callback)
 {
     payInner(order, callback);
 }