我在 Stripe 仪表板中创建了自定义付款配置 (https://dashboard.stripe.com/test/settings/ payment_methods) Stripe 为我提供了一个以“pmc_”开头的配置 ID
我的想法是我可以在某个地方使用这个 id 作为属性,但我发现没有办法在 SessionCreateParams 中做到这一点。 我发现的唯一的东西是 SessionCreateParams.PaymentMethodType 接受枚举。
这个解决方案对我来说也很好,但不幸的是这个枚举有点有限。 我想提供 Google Pay、Apple Pay 和 PayPal,但到目前为止我只能在 Strips 仪表板上选择此类付款,但没有枚举...
这是我到目前为止的服务(我使用了代码片段,因为代码片段总是存在格式问题)
@Service
@RequiredArgsConstructor
public class StripeService implements StripeServiceInterface {
private PaymentsRepository paymentsRepository;
private static void init() {
Stripe.apiKey = "censored";
}
@Override
public Map<String, String> createSession(StripeCheckoutDTO stripeCheckoutDTO) throws StripeException {
init();
SessionCreateParams params = SessionCreateParams.builder()
.addPaymentMethodType(SessionCreateParams.PaymentMethodType.GIROPAY)
.addPaymentMethodType(SessionCreateParams.PaymentMethodType.KLARNA)
.addPaymentMethodType(SessionCreateParams.PaymentMethodType.CARD)
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("http://localhost:4200/payment-successful")
.setCancelUrl("http://localhost:4200/payment-declined")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setQuantity(stripeCheckoutDTO.getQuantity())
.setPriceData(
SessionCreateParams.LineItem.PriceData.builder()
.setCurrency(stripeCheckoutDTO.getCurrency())
.setUnitAmount(stripeCheckoutDTO.getAmount())
.setProductData(
SessionCreateParams.LineItem.PriceData.ProductData.builder()
.setName(stripeCheckoutDTO.getName())
.build())
.build())
.build())
.build();
Session session = Session.create(params);
Map<String, String> responseData = new HashMap<>();
responseData.put("id", session.getId());
return responseData;
}
}
我希望有人能告诉我如何激活PayPal等付款方式或如何使用Configuration-ID