Stripe中的 googlePay 和 applePay (Java)

编程知识 行业动态 更新时间:2024-06-13 00:22:27

Stripe中的 googlePay 和 applePay (Java)

在网站中接入stripe的googlepay和applepay工作主要在前端,后端需要配合前端做少量工作,前端部分可参考官方文档:https://stripe/docs/stripe-js/elements/payment-request-button

流程如下图所示

在pom文件中引入依赖

<dependency>
            <groupId>com.stripe</groupId>
            <artifactId>stripe-java</artifactId>
            <version>20.62.0</version>
        </dependency>

后端Java代码:

//googlekey
    public  Map<String,Object> googlekey(BigDecimal money) throws StripeException {
        Stripe.apiKey = key;
        PaymentIntentCreateParams params =
                PaymentIntentCreateParams.builder()
                        .setCurrency("usd")
                        .setAmount(money.longValue()*100)
                        .build();
        PaymentIntent intent = PaymentIntent.create(params);
        Map<String,Object> result=new HashMap<>();
        result.put("clientSecret",intent.getClientSecret());
        result.put("googlePayId",intent.getId());
        return result;
    }


    public  Boolean googleRefund(String googlePayId) throws StripeException {
        Stripe.apiKey = key;
        Refund refund = Refund.create(RefundCreateParams.builder()
                .setPaymentIntent(googlePayId)
                .build());
        return true;
    }

更多推荐

Stripe中的 googlePay 和 applePay (Java)

本文发布于:2023-04-02 12:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/e1a037075eda10852bd815b0d8fa384b.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:googlePay   Stripe   Java   applePay

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!