接入指南
接入支付有礼
接口调用时序图

推广计划状态流转图

1.
2.
第一步:创建推广计划
1.
delivery_target_rule#delivery_merchant_rule
(指定支付成功页)**线下支付:**转账收款码(TRANSFER_QRCODE_PAY)、当面付快捷版(OFFLINE_PAYMENT)、新当面付收单产品(FACE_TO_FACE_PAYMENT)、支付宝当面付(ALIPAY_F2F_PAYMENT)、线下条码收单(BARCODE_PAY_OFFLINE)、线下扫码支付(QR_CODE_OFFLINE)、 扫码即时到账(PAIPAI_FAST_PAY )、线下声波支付(SOUNDWAVE_PAY_OFFLINE)
**无线支付:**快捷手机安全支付(QUICK_MSECURITY_PAY )、快捷手机wap支付(QUICK_WAP_WAY )、无线下单支付(WAP_CREATE_TRADE)
**网站支付:快捷即时到账(FAST_INSTANT_TRADE_PAY)、即时到账收款(TRADE_FAST_PAY)、大快捷即时到帐收款(QUICK_TRADE_FAST_PAY)、普通银直联收款(PUREGW_FAST_PAY)
代扣:**商户代扣(GENERAL_WITHHOLDING)、周期扣款(CYCLE_PAY_AUTH)
1.
delivery_target_rule#delivery_promo_tags
(订单优惠标记)请求参数名称 | 参数 | 类型 | 是否必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|---|
业务拓展参数 | business_params | BusinessParams | 可选 | 商户传入业务信息,应用于营销参数直传场景,格式为json格式 | ||
订单优惠标记 | └delivery_promo_tags | String | 可选 | 680 | 支付有礼-订单优惠标记,按json格式。 1.订单优惠标记限制: * 单个优惠标最大长度32字节 。多个标记值以英文逗号分隔 。 * 单个优惠标仅支持字母/数字 /下划线2.建议订单优惠标记数量控制在20个以内 | memberLevel1,memberLevel2 |
JSONObject businessParams = new JSONObject();
businessParams.put("delivery_promo_tags", "xxxx,xxxxx,xxxx");
bizContent.put("business_params", businessParams);
1.
2.
3.
请求示例
package com.java.sdk.demo;
import com.alipay.v3.ApiException;
import com.alipay.v3.ApiClient;
import com.alipay.v3.util.model.AlipayConfig;
import com.alipay.v3.Configuration;
import com.alipay.v3.api.AlipayMarketingActivityDeliveryApi;
import com.alipay.v3.model.*;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AlipayMarketingActivityDeliveryApiCreate {
public static void main(String[] args) throws ApiException {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// 初始化alipay参数(全局设置一次)
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com");
alipayConfig.setAppId("<-- 请填写您的AppId,例如:2019091767145019 -->");
alipayConfig.setPrivateKey("<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->");
alipayConfig.setAlipayPublicKey("<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->");
defaultClient.setAlipayConfig(alipayConfig);
AlipayMarketingActivityDeliveryApi api = new AlipayMarketingActivityDeliveryApi();
AlipayMarketingActivityDeliveryCreateModel data = new AlipayMarketingActivityDeliveryCreateModel();
data.setDeliveryBoothCode("PAYMENT_RESULT");
data.setOutBizNo("20170101000001654bb46ba");
DeliveryPlayConfig deliveryPlayConfig = new DeliveryPlayConfig();
DeliverySingleSendConfig deliverySingleSendConfig = new DeliverySingleSendConfig();
DeliveryContentInfo deliveryContentInfoHeryB = new DeliveryContentInfo();
DeliveryActivityContentInfo deliveryActivityContentDRYmx = new DeliveryActivityContentInfo();
deliveryActivityContentDRYmx.setActivityId("20122131234434557567");
deliveryContentInfoHeryB.setDeliveryActivityContent(deliveryActivityContentDRYmx);
DeliveryMiniAppContentInfo deliveryAppContentnowJu = new DeliveryMiniAppContentInfo();
deliveryAppContentnowJu.setMiniAppId("2018052160106010");
deliveryAppContentnowJu.setMiniAppDeliveryType("SERVICE_DIRECT");
List<String> serviceCodeListERrbO = new ArrayList<String>();
serviceCodeListERrbO.add("2020030921000303380758");
deliveryAppContentnowJu.setServiceCodeList(serviceCodeListERrbO);
deliveryContentInfoHeryB.setDeliveryAppContent(deliveryAppContentnowJu);
deliveryContentInfoHeryB.setDeliveryContentType("ACTIVITY");
DeliveryDisplayInfo deliveryDisplayInfogKaFX = new DeliveryDisplayInfo();
deliveryDisplayInfogKaFX.setMainTitle("手机租赁免押金");
deliveryDisplayInfogKaFX.setSubTitle("随时随地享受社保服务");
deliveryContentInfoHeryB.setDeliveryDisplayInfo(deliveryDisplayInfogKaFX);
deliverySingleSendConfig.setDeliveryContentInfo(deliveryContentInfoHeryB);
deliveryPlayConfig.setDeliverySingleSendConfig(deliverySingleSendConfig);
DeliveryFullSendConfig deliveryFullSendConfig = new DeliveryFullSendConfig();
deliveryFullSendConfig.setDeliveryFloorAmount("1.00");
DeliveryContentInfo deliveryContentInfotfUPZ = new DeliveryContentInfo();
DeliveryActivityContentInfo deliveryActivityContentiUuej = new DeliveryActivityContentInfo();
deliveryActivityContentiUuej.setActivityId("20122131234434557567");
deliveryContentInfotfUPZ.setDeliveryActivityContent(deliveryActivityContentiUuej);
DeliveryMiniAppContentInfo deliveryAppContentMOqrW = new DeliveryMiniAppContentInfo();
deliveryAppContentMOqrW.setMiniAppId("2018052160106010");
deliveryAppContentMOqrW.setMiniAppDeliveryType("SERVICE_DIRECT");
List<String> serviceCodeListNlnBE = new ArrayList<String>();
serviceCodeListNlnBE.add("2020030921000303380758");
deliveryAppContentMOqrW.setServiceCodeList(serviceCodeListNlnBE);
deliveryContentInfotfUPZ.setDeliveryAppContent(deliveryAppContentMOqrW);
deliveryContentInfotfUPZ.setDeliveryContentType("ACTIVITY");
DeliveryDisplayInfo deliveryDisplayInfoXZxMS = new DeliveryDisplayInfo();
deliveryDisplayInfoXZxMS.setMainTitle("手机租赁免押金");
deliveryDisplayInfoXZxMS.setSubTitle("随时随地享受社保服务");
deliveryContentInfotfUPZ.setDeliveryDisplayInfo(deliveryDisplayInfoXZxMS);
deliveryFullSendConfig.setDeliveryContentInfo(deliveryContentInfotfUPZ);
deliveryPlayConfig.setDeliveryFullSendConfig(deliveryFullSendConfig);
data.setDeliveryPlayConfig(deliveryPlayConfig);
DeliveryBaseInfo deliveryBaseInfo = new DeliveryBaseInfo();
deliveryBaseInfo.setDeliveryName("本店优惠第十期投放计划");
deliveryBaseInfo.setDeliveryBeginTime("2017-01-01 00:00:01");
deliveryBaseInfo.setDeliveryEndTime("2017-01-01 00:00:01");
data.setDeliveryBaseInfo(deliveryBaseInfo);
DeliveryTargetRule deliveryTargetRule = new DeliveryTargetRule();
deliveryTargetRule.setDeliveryPromoTags("memberLevel1,memberLevel2");
DeliveryCityCodeRule deliveryCityCodeRule = new DeliveryCityCodeRule();
deliveryCityCodeRule.setAllCity(true);
List<String> cityCodes = new ArrayList<String>();
cityCodes.add("100100");
deliveryCityCodeRule.setCityCodes(cityCodes);
deliveryTargetRule.setDeliveryCityCodeRule(deliveryCityCodeRule);
DeliveryMerchantRule deliveryMerchantRule = new DeliveryMerchantRule();
List<DeliveryMerchantInfo> deliveryMerchantInfos = new ArrayList<DeliveryMerchantInfo>();
DeliveryMerchantInfo deliveryMerchantInfos0 = new DeliveryMerchantInfo();
deliveryMerchantInfos0.setMerchantIdType("PID");
deliveryMerchantInfos0.setMerchantId("2088xxxxx");
deliveryMerchantInfos.add(deliveryMerchantInfos0);
deliveryMerchantRule.setDeliveryMerchantInfos(deliveryMerchantInfos);
deliveryMerchantRule.setDeliveryMerchantMode("MANUAL_INPUT_MERCHANT");
deliveryTargetRule.setDeliveryMerchantRule(deliveryMerchantRule);
data.setDeliveryTargetRule(deliveryTargetRule);
data.setMerchantAccessMode("SELF_MODE");
try {
AlipayMarketingActivityDeliveryCreateResponseModel response = api.create(data);
} catch (ApiException e) {
AlipayMarketingActivityDeliveryCreateDefaultResponse errorObject = (AlipayMarketingActivityDeliveryCreateDefaultResponse) e.getErrorObject();
System.out.println("调用失败:" + errorObject);
}
}
}
第二步:查询推广计划
请求示例
package com.java.sdk.demo;
import com.alipay.v3.ApiException;
import com.alipay.v3.ApiClient;
import com.alipay.v3.util.model.AlipayConfig;
import com.alipay.v3.Configuration;
import com.alipay.v3.api.AlipayMarketingActivityDeliveryApi;
import com.alipay.v3.model.*;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AlipayMarketingActivityDeliveryApiQuery {
public static void main(String[] args) throws ApiException {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// 初始化alipay参数(全局设置一次)
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com");
alipayConfig.setAppId("<-- 请填写您的AppId,例如:2019091767145019 -->");
alipayConfig.setPrivateKey("<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->");
alipayConfig.setAlipayPublicKey("<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->");
defaultClient.setAlipayConfig(alipayConfig);
AlipayMarketingActivityDeliveryApi api = new AlipayMarketingActivityDeliveryApi();
String deliveryId = "20121231231242353";
AlipayMarketingActivityDeliveryQueryModel data = new AlipayMarketingActivityDeliveryQueryModel();
data.setMerchantAccessMode("AGENCY_MODE");
try {
AlipayMarketingActivityDeliveryQueryResponseModel response = api.query(deliveryId, data);
} catch (ApiException e) {
AlipayMarketingActivityDeliveryQueryDefaultResponse errorObject = (AlipayMarketingActivityDeliveryQueryDefaultResponse) e.getErrorObject();
System.out.println("调用失败:" + errorObject);
}
}
}
第三步:终止推广计划
1.
请求示例
package com.java.sdk.demo;
import com.alipay.v3.ApiException;
import com.alipay.v3.ApiClient;
import com.alipay.v3.util.model.AlipayConfig;
import com.alipay.v3.Configuration;
import com.alipay.v3.api.AlipayMarketingActivityDeliveryApi;
import com.alipay.v3.model.*;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AlipayMarketingActivityDeliveryApiStop {
public static void main(String[] args) throws ApiException {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// 初始化alipay参数(全局设置一次)
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com");
alipayConfig.setAppId("<-- 请填写您的AppId,例如:2019091767145019 -->");
alipayConfig.setPrivateKey("<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->");
alipayConfig.setAlipayPublicKey("<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->");
defaultClient.setAlipayConfig(alipayConfig);
AlipayMarketingActivityDeliveryApi api = new AlipayMarketingActivityDeliveryApi();
String deliveryId = "20121231231242353";
AlipayMarketingActivityDeliveryStopModel data = new AlipayMarketingActivityDeliveryStopModel();
data.setOutBizNo("20170101000001654bb46ba");
data.setMerchantAccessMode("SELF_MODE");
try {
AlipayMarketingActivityDeliveryStopResponseModel response = api.stop(deliveryId, data);
} catch (ApiException e) {
AlipayMarketingActivityDeliveryStopDefaultResponse errorObject = (AlipayMarketingActivityDeliveryStopDefaultResponse) e.getErrorObject();
System.out.println("调用失败:" + errorObject);
}
}
}
消息通知
1.
2.
3.
ISV_GATEWAY_URL?charset=GBK&biz_content=
{
"out_biz_no":"abscd123341",
"event_time":"12342425435232423",
"delivery_id":"20121231231242353",
"delivery_status":"ACTIVE",
"delivery_error_msg":"素材不合格",
"delivery_booth_code":"PAYMENT_RESULT"
&msg_method=alipay.marketing.activity.delivery.changed&utc_timestamp=1516797622752&version=1.1&sign_type=RSA2¬ify_id=d275fec564e62af6bedbcee73f3f05fi5x&app_id=2013121700999429&sign=I+Y/lvqYUEEc10EPdpntRhFIQ==
第一步:订阅消息
第二步:验签
第三步:反馈消息接收结果
success
表示消息获取成功,支付宝就会停止发送异步通知。如果返回 fail
或其它值,表示消息获取失败,支付宝会根据 投递重试策略 重新发送消息到应用网关地址。success
,验签失败返回 fail
,重新接收异步进行处理。响应值 | 描述 | 是否重试 |
---|---|---|
fail | 消息获取失败 | 重试 |
success | 消息获取成功 | 不重试 |
修改于 2023-11-22 02:18:29