跳转至

开发指引

一、支付中签约方式(主要应用于免密支付场景)

第一步 : 请求支付中签约接口,获取预支付id (prepayId),此步骤需要根据不同支付方式选择不同的tradeType。
第二步 : 按照不同支付方式的不同规则,按要求唤起支付收银台。
第三步 : 用户完成支付,钱包通过支付中签约接口中商户上传的通知回调地址(notifyUrl),将支付结果返回给商户,同时将签约结果通过contractNotifyUrl通知给商户,两次通知皆为异步通知。

二、纯签约方式(主要应用于VIP自动续费场景)

目前提供两种方式接入,请按照实际情况选择

1、接入方式一

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/**   注意:调用签约前请初始化钱包sdk,初始化方法详见API
    * @param activityContext Activity 上下文
    * @param authInfo {@link SPAuthInfo} 宿主App的用户登录态对象,含app登录态(即userToken)、用户id(即uhid)。必传,若为null,则无法唤起该功能
    * @param url             预签约地址(由服务端生成)
    * @param signCallback    签约结果回调
    */
   public static void walletSign(
           @NonNull Activity activityContext,
           @NonNull SPAuthInfo authInfo,
           @NonNull String url,
           SPWalletInterfaces.SPIWalletSignCallback signCallback);

2、接入方式二

通过Action打开签约页面

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    // Action 名称"opensdk.intent.action.AUTO.SIGN_PAY",不可变更
    Intent intent = new Intent("opensdk.intent.action.AUTO.SIGN_PAY");
    // 程序包名,默认填写当前应用
    intent.setPackage(getPackageName());
    // 自动续费url地址.拼接规则为:sechme://host/path?sessionId=xxxxx&needLogin=true
    // 注意:needLogin在自动签约这必填true
    intent.putExtra("wb_url", url + "&needLogin=true");
    //签约回调商户Action,此action需要和商户mainfest.xml文件里配置的一样
    intent.putExtra("callback", "com.xxx.xxx.xx");
    startActivity(intent);
商户接收结果回调页面配置示例
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
        <activity
           //此界面是商户需要接收结果的页面,请按实际填写
           //   //签约回调商户Action,此action需要和商户mainfest.xml文件里配置的一样 intent.putExtra("callback", "com.xxx.xxx.xx");
            android:name="com.alvin.wallet.ui.DeepLinkPayResultActivity"
            android:exported="true"
            android:theme="@style/Theme_Transparent">
            <intent-filter>
                //此处的值由商户填入,需要商户传递到sdk,如何传请往上看
                <action android:name="com.xxx.xx.xx" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
商户端接收回调
1
2
3
4
    // 返回码
    String code = getIntent().getStringExtra("code");
    // 返回信息
    String message = getIntent().getStringExtra("message");

3、接入方式三

通过deeplink方式打开签约页面

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
    StringBuffer sb = new StringBuffer();
    // sdk签约页面sechme,不可修改
    sb.append("common://pay/autopay");
    sb.append("?");
    // 回调页面sechme,由商户配置,名称由商户传递过来,此名称需要和androidmainfest.xml配置的sechme一致,值请用Base64编码
    sb.append("callback=" + Base64.encode("common://pay/autopay/cancel".getBytes()));
    // url地址,例如:http://xxxx.xxx.xxx/xxx?sessionId=121212&needLogintrue  
    //  注意needLogin请必填true
    sb.append("&address=" + Base64.encode((url + "&needLogin=true").getBytes()));
    // 地址+号需要转义
    String sendBuf = sb.toString().replace("+", "%2B");
    Uri uri1 = Uri.parse(sendBuf);
    Intent it = new Intent(Intent.ACTION_VIEW, uri1);
    startActivity(it);

    //H5直接访问:common://pay/autopay?callback=xxxxxxxxxxxx&address=xxxxxxxxxxx&needLogin=xxxxxxxxxxxxx
商户接收结果回调页面配置示例
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
        <activity
            //此界面是商户需要接收结果的页面,请按实际填写
            android:name="com.alvin.wallet.ui.DeepLinkPayResultActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                //host path scheme是由商户传递过来,如何传递请看上面   sb.append("callback=" + Base64.encode("common://pay/autopay/cancel".getBytes()));
                <data
                    android:host="pay"
                    android:path="/autopay/cancel"
                    android:scheme="common" />
            </intent-filter>
        </activity>
商户端接收回调
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 if (uri != null) {
      if (uri.getScheme().equals("common")
          && uri.getHost().equals("pay")
          && uri.getPath().equals("/autopay/cancel")) {
        textView.setText("code为"
                + uri.getQueryParameter("code")
                + "message为"
                + uri.getQueryParameter("message"));
      }
    }

//返回码说明   code:"0"未签约  "1":表示已签约  "2":表示签约失败

Back to top