营销活动送红包注意事项:[url]https://openclub.alipay.com/read.php?tid=12196&fid=71[/url]
一、.NET示例和demo
.NET版demo:download:营销活动送红包NET版.zip
二、调用接口
1、创建现金活动接口请求示例
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayMarketingCampaignCashCreateRequest request = new AlipayMarketingCampaignCashCreateRequest(); request.BizContent = "{" + "\"coupon_name\":\"煜雨创建营销活动送红包\"," + "\"prize_type\":\"random\"," + "\"total_money\":\"1.00\"," + "\"total_num\":\"5\"," + "\"prize_msg\":\"煜雨送您大红包\"," + "\"start_time\":\"NowTime\"," + "\"end_time\":\"2018-11-20 22:48:30\"," + "\"merchant_link\":\"https://www.baidu.com\"," + "\"send_freqency\":\"D3|L10\"" + "}"; AlipayMarketingCampaignCashCreateResponse response = client.Execute(request); Console.WriteLine("煜雨创建现金活动:" + response.Body);
接口调用成功示例:
煜雨创建现金活动:{"alipay_marketing_campaign_cash_create_response":{"code":"10000","msg":"Success","crowd_no":"2w0FuES2DFzxla_8YQDpYEjecJbUPuWwacQtqkqe-RrMnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180921149410190701192600920004","pay_url":"http%3A%2F%2Fauthcenter%2Ealipaydev%2Ecom%3Fgoto%3Dhttp%3A%2F%2Fpromoprod%2Ealipaydev%2Ecom%2Fquery%2FopenCashCrowdPay%2Ehtm%3FcrowdNo%3D2w0FuES2DFzxla%5F8YQDpYEjecJbUPuWwacQtqkqe%2DRrMnSZ96O%2DzxUfKlHp5cxmx"},"sign":"m/zWmwWwekxf30SOnxp3sFU8TYyCOZMPBKBQLUuzDxeybnBEu20Yfsbleh10/tzTcUgJFuVXD/pIi7ILnKwf//HGYoC+bOyLi/prjrEdqxVPeiglKXC0azR8AG5hzpqN4K6n1hzZmbtprRCD3eCxiF7QozwDTDvDgeNGM8HUbgn6ylHFbu35iZkhN3UEmVv5QTVPek5S8MfHucOZwITOnB6cQDZBFW/Yw4h6mLDtFdkprAP6PuJOJ1GoVtyUabMPaX0QF4tjDVhbqWN4SxWXixOmMuLTEwey6Lr1vBouEBd9OOjOL4RyvOyLfIoeRJi9+llwn+A+7tQAC2Qrg8+hfA=="}
参数说明:
1>.prize_type:现金红包的发放形式,fixed为固定金额,random为随机金额;
2>.total_money:活动发放的现金总金额,最小金额1.00元;
3>.total_num:红包发放个数,最小1个,最大10000000个;必须设置为整数。
4>.pay_url:支付url,有效期为24个小时,需要商家先对其进行UrlDecode处理,然后使用卖家账号登录支付。
支付流程:
将支付链接pay_url进行decode处理,然后在浏览器直接访问该url使用卖家账号:
2、触发现金红包活动接口请求示例
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayMarketingCampaignCashTriggerRequest request = new AlipayMarketingCampaignCashTriggerRequest(); request.BizContent = "{" + "\"user_id\":\"2088102174701092\"," + "\"crowd_no\":\"2w0FuES2DFzxla_8YQDpYEjecJbUPuWwacQtqkqe-RrMnSZ96O-zxUfKlHp5cxmx\"," + "\"login_id\":\"dvnvqi3054@sandbox.com\"," + "\"order_price\":\"0.20\"," + "\"out_biz_no\":\"2018009204544545454545477\"" + "}"; AlipayMarketingCampaignCashTriggerResponse response = client.Execute(request); Console.WriteLine("煜雨触发现金红包活动:" + response.Body);
接口调用成功示例:
煜雨触发现金红包活动:{"alipay_marketing_campaign_cash_trigger_response":{"code":"40004","msg":"Business Failed","sub_code":"isv.UNKNOW_SYSTEM_ERROR","sub_msg":"系统繁忙,请稍后再试"},"sign":"t092yfg+ZvGtH+u//YJjPsJy5zQWBL0Zit/3NBoVyFpnBYRpNn4CjJWeW9T4a+ZNSCDe4mNVBvOKV4XzTYAbv8qr9XGBtHm0Ld0r4A2G4opFNIdcfuA+cu13GSvt5H+IRZDy10Q3UsqN/LfrMomZYMS8VMXr5S1/L4wPX/ZW3pqmxrXMGBXoeDeMsPVOgI5nmzn/S9X6P0qsC5l/eVTzjMa7OOU3LjE6851drXzIr25b4aosgzB96FHcfDlHrZqKlJodSBK1OVMt2u7K66b4rzNTInXZrblxKlpqsCm0SmN5je46Qax0KrjNNH4gCrHzkcaI26fXuiHZ9g7Bgz+J4w=="}
参数说明:
1>.user_id:用户唯一标识,可通过用户信息授权接口获取;
2>.order_price:设置发送红包的金额,单位为分,100代表1元;
3>.login_id:用户登录账号名:邮箱或手机号。user_id与login_id至少有一个非空,都非空时以user_id为准。
3、更改现金活动状态接口请求示例
require_once 'AopSdk.php';$aop = new AopClient();$aop->appId = '填写你的沙箱appid';$aop->rsaPrivateKey = '填写您的原始私钥';$aop->alipayrsaPublicKey='填写您的支付宝公钥';$aop->gatewayUrl = 'https://openapi.alipaydev.com/gateway.do';$aop->apiVersion = '1.0';$aop->postCharset='utf-8';$aop->format='json';$aop->signType = 'RSA2';$request = new AlipayMarketingCampaignCashStatusModifyRequest ();$request->setBizContent("{" . "\"crowd_no\":\"bmhfAI27oG_m1OVdDzn90MdC2y9YVjhsPLPjJLTHhnDMnSZ96O-zxUfKlHp5cxmx\"," . "\"camp_status\":\"PAUSE\"" . "}");$result = $aop->execute ( $request);var_dump($result);?>
接口调用成功示例:
public 'alipay_marketing_campaign_cash_status_modify_response' => object(stdClass)[10] public 'code' => string '10000' (length=5) public 'msg' => string 'Success' (length=7) public 'sign' => string 'GnpwpMfUdFwQIyyqqdNCTP6obNctCaJ+RE7DwfAYABJTRz5ulLZ6ZZ7jYbur+h//hfG4FNAcKkJ5+yWNWGDj+fWRH25NUoyfZM0PTghWqhZaCuOMTnCn7R5Pm+jVwHDu9ngl8JNY816xD9TcQtqFaUdUufGFxGo/9eY8hmnubSdpp9/6iZn09x//TJPPu4DNU0nWELO3NtDOA/qftg9zWmoE5/sFxqTYbgcLOA71EceTZQ/4DwWpavatOhewATUWflVXP9DwWjBNeONFzUuBwl6BJZOCw3H9ldhC+37x4HDiXoK2E68NZaZRMincmWayrY4SHBq20SHvQUR/VqnOxw==' (length=344)
参数说明:
camp_status:修改后的活动状态,只能设置为PAUSE或者READY或者CLOSED。
4、现金活动列表查询接口请求示例
require_once 'AopSdk.php';$aop = new AopClient();$aop->appId = '填写你的沙箱appid';$aop->rsaPrivateKey = '填写您的原始私钥';$aop->alipayrsaPublicKey='填写您的支付宝公钥';$aop->gatewayUrl = 'https://openapi.alipaydev.com/gateway.do';$aop->apiVersion = '1.0';$aop->postCharset='utf-8';$aop->format='json';$aop->signType = 'RSA2';$request = new AlipayMarketingCampaignCashListQueryRequest ();$request->setBizContent("{" . "\"camp_status\":\"PAID\"," . "\"page_size\":\"5\"," . "\"page_index\":\"1\"" . "}");$result = $aop->execute ( $request);var_dump($result);?>
接口调用成功示例:
public 'alipay_marketing_campaign_cash_list_query_response' => object(stdClass)[10] public 'code' => string '10000' (length=5) public 'msg' => string 'Success' (length=7) public 'page_index' => string '0' (length=1) public 'page_size' => string '5' (length=1) public 'total_size' => string '0' (length=1) public 'sign' => string 't8e83/k/KfvN2JfjYoM6t28qEW52b4fC4YkSO98e80K34a045yXI1ujClvvU5FNTyNA8drwzUZfHMVcp8ijBwJJoNEryY11LP4rrK6oGLC+xg7FyisBANwj94PdRXfiOd/S5NyxbvNYOvFjhN1NJv52MhOdQTCeomAA3yWVK7bfRYb7m4BH1Usdsgex9CwM2AwT39SR8AMHe8ELaWTksS8KMTAKw0/qotT94KZHKKw454etEfEiPoOnMJNJufuEHrWUX/KZLeg4BYAQMz7iUb0IrmZlLV0638dDPx5pkJr9yeNskqtPjsu810xwii5+kJesdUTRUWeozQpNCfM9yIA==' (length=344)
参数说明:
camp_status要查询的活动状态,不填默认返回所有类型。
5、现金活动详情查询接口请求示例
require_once 'AopSdk.php';$aop = new AopClient();$aop->appId = '填写你的沙箱appid';$aop->rsaPrivateKey = '填写您的原始私钥';$aop->alipayrsaPublicKey='填写您的支付宝公钥';$aop->gatewayUrl = 'https://openapi.alipaydev.com/gateway.do';$aop->apiVersion = '1.0';$aop->postCharset='utf-8';$aop->format='json';$aop->signType = 'RSA2';$request = new AlipayMarketingCampaignCashDetailQueryRequest ();$request->setBizContent("{" ."\"crowd_no\":\"bmhfAI27oG_m1OVdDzn90MdC2y9YVjhsPLPjJLTHhnDMnSZ96O-zxUfKlHp5cxmx\"" ."}");$result = $aop->execute ( $request);var_dump($result);?>
接口调用成功示例:
public 'alipay_marketing_campaign_cash_detail_query_response' => object(stdClass)[10] public 'code' => string '10000' (length=5) public 'msg' => string 'Success' (length=7) public 'camp_status' => string 'READY' (length=5) public 'coupon_name' => string '煜雨创建营销活动送红包' (length=33) public 'crowd_no' => string 'bmhfAI27oG_m1OVdDzn90MdC2y9YVjhsPLPjJLTHhnDMnSZ96O-zxUfKlHp5cxmx' (length=64) public 'end_time' => string '2018-12-26 12:48:31' (length=19) public 'origin_crowd_no' => string '20181026169410190701192600817004' (length=32) public 'prize_msg' => string '煜雨送您大红包' (length=21) public 'prize_type' => string 'random' (length=6) public 'send_amount' => string '0.00' (length=4) public 'start_time' => string '2018-10-26 16:00:13' (length=19) public 'total_amount' => string '1.00' (length=4) public 'sign' => string 'ne3iAW8hGGmDuwgKAfAZ83FIQNI3G86IoOOtj2v11tLeg2yb8GjvVL+Zphz5qptaAeOSu/UXHaNkAm/FfspABtpkKpYAIEZTJrRrhlrZUmcKO5HbafN8yTPwKqP5DNb9lYDtA21IePC7fcER8ytgHT9wBgKZjciUhaOEskoIkIzOE9jBiyGILAVN8F0pleQ2PgcCrt3MfgOj/gbRPnPXJzTbh9Hcr9sCIbW9G3ZKzoJ9Ddcw2eZRVWtVAlsTZ4WT+zIgIQFipA3TIRpB+OCZlQqsFCuYsSXPBVmqv2q177cX6nD0yPmVODoz52BZa09lHYSx7YitR+gKalznvLWsCA==' (length=344)
三、显示效果
商户创建完成并生效红包活动后,可在支付宝商家红包后台查看发放情况并下载账单(账单将以T+1时效更新)。
商家红包后台地址:[url]https://hb.alipay.com/mhb/giftList.htm[/url]
钱包中可查询红包的账单信息:
红包说明是固定格式:沙箱环境是:沙箱环境-现金红包;正式环境是:公司名称-现金红包
如果还是报错,请按如下方式进行提问:
正确提问方式:使用环境(沙箱还是正式环境)+接口名称(中文+英文)+ 请求参数 + 报错信息详情