使用Adyen Java库创建sepadirectdebit支付会话失败求助
解决Adyen Java库创建SEPA Direct Debit支付会话时的14_0408错误
你在使用Adyen Java库(com.adyen:adyen-java-api-library:20.0.0)创建支付会话时,将allowedPaymentMethods设置为sepadirectdebit收到以下错误:
{"status":422,"errorCode":"14_0408","message":"There are no payment methods available for the given parameters.","errorType":"validation","pspReference":"......"}
而设置为card时可以正常工作,以下是可能的原因和解决方案:
可能的原因及解决方案
1. 币种不符合SEPA要求
SEPA Direct Debit仅支持欧元(EUR),如果请求中设置的币种不是EUR,会直接导致支付方法不可用。
- 解决方案:确保
Amount的currency字段设置为"EUR":pAmount.setCurrency("EUR");
2. 国家代码不在SEPA区域内
SEPA仅支持特定区域的国家(欧盟成员国+冰岛、列支敦士登、挪威、瑞士),如果countryCode设置为非SEPA区域的代码(比如US、CN),会过滤掉SEPA支付方式。
- 解决方案:将
countryCode改为SEPA区域内的代码,例如"DE"(德国)、"FR"(法国)、"NL"(荷兰)等。
3. 商户账户未启用SEPA Direct Debit支付方式
虽然card能正常使用,但SEPA Direct Debit可能未在你的Adyen商户账户中启用。
- 解决方案:登录Adyen Merchant Area,进入Payment Methods页面,确认SEPA Direct Debit处于启用状态,若未启用则提交开通申请。
4. Recurring Processing Model不匹配
你当前设置的UNSCHEDULEDCARDONFILE是针对卡类无卡预授权的模型,并不适用于SEPA Direct Debit。
- 解决方案:根据业务场景替换为兼容的模型:
- 如果需要存储SEPA支付方式用于后续自动扣款,使用
RECURRING:checkoutSessionRequest.setRecurringProcessingModel(CreateCheckoutSessionRequest.RecurringProcessingModelEnum.RECURRING); - 如果是首次支付且仅需存储支付方式用于下次一键支付,使用
ONECLICK。 - 若只是单次支付无需后续扣款,可以直接移除该参数。
- 如果需要存储SEPA支付方式用于后续自动扣款,使用
修改后的测试代码示例
PaymentsApi paymentsApi = new PaymentsApi(client); CreateCheckoutSessionRequest checkoutSessionRequest = new CreateCheckoutSessionRequest(); Amount pAmount = new Amount(); pAmount.setCurrency("EUR"); // 强制使用欧元 pAmount.setValue(1000); // 代表10.00 EUR(单位为最小货币单位) checkoutSessionRequest.setAmount(pAmount); checkoutSessionRequest.setMerchantAccount("你的商户账户ID"); checkoutSessionRequest.setReturnUrl("https://your-website.com/payment-return"); checkoutSessionRequest.setReference("YOUR_ORDER_REF_123"); checkoutSessionRequest.setCountryCode("DE"); // SEPA区域国家代码 checkoutSessionRequest.setShopperReference("UNIQUE_SHOPPER_ID"); checkoutSessionRequest.setShopperEmail("shopper@example.com"); checkoutSessionRequest.storePaymentMethod(true); checkoutSessionRequest.setStorePaymentMethodMode(CreateCheckoutSessionRequest.StorePaymentMethodModeEnum.ENABLED); // 使用SEPA兼容的Recurring模型 checkoutSessionRequest.setRecurringProcessingModel(CreateCheckoutSessionRequest.RecurringProcessingModelEnum.RECURRING); checkoutSessionRequest.setAllowedPaymentMethods(List.of("sepadirectdebit")); CreateCheckoutSessionResponse checkoutSessionResponse = paymentsApi.sessions(checkoutSessionRequest);
内容的提问来源于stack exchange,提问作者Hardik Mehta
相关产品推荐
相关产品推荐

