跳转型一键激活支持用户在提交会员开卡资料后跳转至商户自定义的网页。不同于普通一键激活,跳转型一键激活的激活会员卡动作由商户完成,商户可以在跳转到的网页内做激活、激活奖励、开卡条件判断等逻辑,同时也保证了开卡的实时性,适合使用自定义卡号的商户使用。
开发使用的是: 盛派SDK
本文章主要说一下,跳转型一键激活遇见的坑
此处的 wx_activate 必须为true,并且activate_url必须置空,否则领取后会员卡后无法激活(点击激活按钮无效)
/// <summary> /// 是否支持跳转型一键激活,填true或lse /// </summary> public bool? wx_activate_after_submit { get; set; } /// <summary> /// 跳转型一键激活跳转的地址链接,请填写http://或者https://开头的链接 /// </summary> public string wx_activate_after_submit_url { get; set; } /// <summary> /// 设置为true时会员卡支持一键开卡,不允许同时传入activate_url字段,否则设置wx_activate失效。填入该字段后仍需调用接口设置开卡项方可生效,详情见 一键开卡 。 /// </summary> public bool wx_activate { get; set; }
在创建完会员卡后,必须调用设置开卡字段接口(没设置,点击激活按钮无效)
URL:https://api.weixin.qq.com/card/membercard/activateuserform/set?access_token=TOKEN 这个API用来设置
var wxset = _wxSetService.GetList(m => m.shopid == shopid).FirstOrDefault(); if (wxset == null) { throw new Exception("请先配置微信设置"); } ActivateUserFormSetData data = new ActivateUserFormSetData(); data.card_id = result_cardId; var common_field_id_list = new string[] { "USER_FORM_INFO_FLAG_NAME","USER_FORM_INFO_FLAG_MOBILE","USER_FORM_INFO_FLAG_BIRTHDAY","USER_FORM_INFO_FLAG_DETAIL_LOCATION" }; data.optional_form = new BaseForm() { common_field_id_list = common_field_id_list }; data.required_form = new BaseForm() { common_field_id_list = common_field_id_list }; try { var authorizer_access_token = get_access_token(wxset.appid, wxset.authorizer_refresh_token); var setResult = CardApi.ActivateUserFormSet(authorizer_access_token, data); if (setResult.errcode == Senparc.Weixin.ReturnCode.请求成功) { return Json(new SuccessActionResult("创建/更新会员卡成功", result_cardId)); } else { return Json(new SuccessActionResult("创建/更新会员卡成功,但是创建选填项出错,请删除重试", result_cardId)); } } catch (Exception ex) { Logger.Debug("创建发生异常:" + ex.Message + ex.StackTrace); return Json(new SuccessActionResult("创建/更新会员卡成功,但是创建选填项出错,因为:" + ex.Message, result_cardId)); }
