你的应用支持银联支付吗? JPay 0.0.4 版本发布

JPay 0.0.4 版本发布了,该版本添加银联手机控件支付的支持。

添加支付相关的权限

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="org.simalliance.openmobileapi.SMARTCARD" />
    <uses-permission android:name="android.permission.NFC" />
    <uses-feature android:name="android.hardware.nfc.hce"/>

添加银联支付组件

 <!-- 银联支付 -->
        <uses-library android:name="org.simalliance.openmobileapi" android:required="false"/>
        <activity
            android:name="com.unionpay.uppay.PayActivity"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden"
            android:excludeFromRecents="true"
            android:windowSoftInputMode="adjustResize"/>
        <activity
            android:name="com.unionpay.UPPayWapActivity"
            android:configChanges="orientation|keyboardHidden|fontScale"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize" >
        </activity>
        <!-- 银联支付 end -->

唤起App支付

JPay.getIntance(mContext).toUUPay("01",tn, new JPay.JPayListener() 
            @Override
            public void onPaySuccess() 
                Toast.makeText(mContext, "支付成功", Toast.LENGTH_SHORT).show();
            

            @Override
            public void onPayError(int error_code, String message) 
                Toast.makeText(mContext, "支付失败>" + error_code + " " + message, Toast.LENGTH_SHORT).show();
            

            @Override
            public void onPayCancel() 
                Toast.makeText(mContext, "取消了支付", Toast.LENGTH_SHORT).show();
            

            @Override
            public void onUUPay(String dataOrg, String sign, String mode) 
                Toast.makeText(mContext, "支付成功>需要后台查询订单确认>"+dataOrg+" "+mode, Toast.LENGTH_SHORT).show();
            
        });

添加回调监听

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
        try 
            UPPay.getInstance(this).onUUPayResult(data);
         catch (JSONException e) 
            e.printStackTrace();
        
        super.onActivityResult(requestCode, resultCode, data);
    }

View original: 

你的应用支持银联支付吗? JPay 0.0.4 版本发布