AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do","app_id","your private_key","json","GBK","alipay_public_key","RSA2");
AlipayMarketingCashlessvoucherTemplateCreateRequest request = new AlipayMarketingCashlessvoucherTemplateCreateRequest();
request.setBizContent("{" +
"\"voucher_type\":\"CASHLESS_FIX_VOUCHER\"," +
"\"brand_name\":\"星巴克\"," +
"\"publish_start_time\":\"2017-04-2500:00:00\"," +
"\"publish_end_time\":\"2017-04-3023:59:59\"," +
"\"voucher_valid_period\":\"{\\\"type\\\":\\\"ABSOLUTE\\\",\\\"start\\\":\\\"2017-01-1000:00:00\\\",\\\"end\\\":\\\"2017-01-1323:59:59\\\"}\"," +
"\"voucher_available_time\":\"[{\\\"day_rule\\\":\\\"1,2,3,4,5\\\",\\\"time_begin\\\":\\\"09:00:00\\\",\\\"time_end\\\":\\\"22:00:00\\\"}]\"," +
"\"out_biz_no\":\"20170101000001654bb46ba\"," +
"\"voucher_description\":\"[\\\"1、本券不可兑换现金,不可找零。\\\",\\\"2、每个用户最多可以领取1张。\\\",\\\"3、如果订单发生退款,优惠券无法退还。\\\"]\"," +
"\"voucher_quantity\":100," +
"\"amount\":1.01," +
"\"floor_amount\":10.00," +
"\"rule_conf\":\"{\\\"PID\\\":\\\"2088512417841101,2088512417841102\\\",\\\"STORE\\\":\\\"123456,678901\\\"}\"," +
"\"notify_uri\":\"https://www.yourdomain.com/reieve/voucher/flux\"," +
"\"extension_info\":\"{\\\"useMode\\\":\\\"H5\\\",\\\"useModeData\\\":{\\\"url\\\":\\\"http://www.yourdomian.com/yourusepage.htm\\\",\\\"signType\\\":\\\"RSA2\\\"}}\"" +
"}");
AlipayMarketingCashlessvoucherTemplateCreateResponse response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", "app_id", "merchant_private_key", "json", "1.0", "RSA2", "alipay_public_key", "GBK", false);
AlipayMarketingCashlessvoucherTemplateCreateRequest request= new AlipayMarketingCashlessvoucherTemplateCreateRequest() ;
request.BizContent="{" +
"\"voucher_type\":\"CASHLESS_FIX_VOUCHER\"," +
"\"brand_name\":\"星巴克\"," +
"\"publish_start_time\":\"2017-04-2500:00:00\"," +
"\"publish_end_time\":\"2017-04-3023:59:59\"," +
"\"voucher_valid_period\":\"{\\\"type\\\":\\\"ABSOLUTE\\\",\\\"start\\\":\\\"2017-01-1000:00:00\\\",\\\"end\\\":\\\"2017-01-1323:59:59\\\"}\"," +
"\"voucher_available_time\":\"[{\\\"day_rule\\\":\\\"1,2,3,4,5\\\",\\\"time_begin\\\":\\\"09:00:00\\\",\\\"time_end\\\":\\\"22:00:00\\\"}]\"," +
"\"out_biz_no\":\"20170101000001654bb46ba\"," +
"\"voucher_description\":\"[\\\"1、本券不可兑换现金,不可找零。\\\",\\\"2、每个用户最多可以领取1张。\\\",\\\"3、如果订单发生退款,优惠券无法退还。\\\"]\"," +
"\"voucher_quantity\":100," +
"\"amount\":1.01," +
"\"floor_amount\":10.00," +
"\"rule_conf\":\"{\\\"PID\\\":\\\"2088512417841101,2088512417841102\\\",\\\"STORE\\\":\\\"123456,678901\\\"}\"," +
"\"notify_uri\":\"https://www.yourdomain.com/reieve/voucher/flux\"," +
"\"extension_info\":\"{\\\"useMode\\\":\\\"H5\\\",\\\"useModeData\\\":{\\\"url\\\":\\\"http://www.yourdomian.com/yourusepage.htm\\\",\\\"signType\\\":\\\"RSA2\\\"}}\"" +
"}";
AlipayMarketingCashlessvoucherTemplateCreateResponse response=client.execute(request);
Console.WriteLine(response.Body);
$aop = new AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = 'your app_id';
$aop->rsaPrivateKey = '请填写开发者私钥去头去尾去回车,一行字符串';
$aop->alipayrsaPublicKey='请填写支付宝公钥,一行字符串';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='GBK';
$aop->format='json';
$request = new AlipayMarketingCashlessvoucherTemplateCreateRequest ();
$request->setBizContent("{" .
"\"voucher_type\":\"CASHLESS_FIX_VOUCHER\"," .
"\"brand_name\":\"星巴克\"," .
"\"publish_start_time\":\"2017-04-2500:00:00\"," .
"\"publish_end_time\":\"2017-04-3023:59:59\"," .
"\"voucher_valid_period\":\"{\\\"type\\\":\\\"ABSOLUTE\\\",\\\"start\\\":\\\"2017-01-1000:00:00\\\",\\\"end\\\":\\\"2017-01-1323:59:59\\\"}\"," .
"\"voucher_available_time\":\"[{\\\"day_rule\\\":\\\"1,2,3,4,5\\\",\\\"time_begin\\\":\\\"09:00:00\\\",\\\"time_end\\\":\\\"22:00:00\\\"}]\"," .
"\"out_biz_no\":\"20170101000001654bb46ba\"," .
"\"voucher_description\":\"[\\\"1、本券不可兑换现金,不可找零。\\\",\\\"2、每个用户最多可以领取1张。\\\",\\\"3、如果订单发生退款,优惠券无法退还。\\\"]\"," .
"\"voucher_quantity\":100," .
"\"amount\":1.01," .
"\"floor_amount\":10.00," .
"\"rule_conf\":\"{\\\"PID\\\":\\\"2088512417841101,2088512417841102\\\",\\\"STORE\\\":\\\"123456,678901\\\"}\"," .
"\"notify_uri\":\"https://www.yourdomain.com/reieve/voucher/flux\"," .
"\"extension_info\":\"{\\\"useMode\\\":\\\"H5\\\",\\\"useModeData\\\":{\\\"url\\\":\\\"http://www.yourdomian.com/yourusepage.htm\\\",\\\"signType\\\":\\\"RSA2\\\"}}\"" .
"}");
$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
echo "成功";
} else {
echo "失败";
}
https://openapi.alipay.com/gateway.do?timestamp=2013-01-01 08:08:08&method=alipay.marketing.cashlessvoucher.template.create&app_id=4602&sign_type=RSA2&sign=ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE&version=1.0&biz_content=
{
"voucher_type":"CASHLESS_FIX_VOUCHER",
"brand_name":"星巴克",
"publish_start_time":"2017-04-25 00:00:00",
"publish_end_time":"2017-04-30 23:59:59",
"voucher_valid_period":"{\"type\": \"ABSOLUTE\", \"start\": \"2017-01-10 00:00:00\", \"end\": \"2017-01-13 23:59:59\"}",
"voucher_available_time":"[{\"day_rule\": \"1,2,3,4,5\", \"time_begin\": \"09:00:00\", \"time_end\": \"22:00:00\"}]",
"out_biz_no":"20170101000001654bb46ba",
"voucher_description":"[\"1、本券不可兑换现金,不可找零。\",\"2、每个用户最多可以领取1张。\",\"3、如果订单发生退款,优惠券无法退还。\"]",
"voucher_quantity":100,
"amount":1.01,
"floor_amount":10.00,
"rule_conf":"{\"PID\": \"2088512417841101,2088512417841102\", \"STORE\": \"123456,678901\"}",
"notify_uri":"https://www.yourdomain.com/reieve/voucher/flux",
"extension_info":"{\"useMode\":\"H5\",\"useModeData\":{\"url\":\"http://www.yourdomian.com/yourusepage.htm\",\"signType\":\"RSA2\"}}"
}
//为确保安全通信,需自行验证响应示例中的sign值是否为蚂蚁金服所提供。