繁体   English   中英

Stripe API 调用(支付意图创建)失败:x509 证书由未知机构签名

[英]Stripe API call (Payment Intent creation) failed: x509 certificate signed by unknown authority

我正在尝试像此示例一样在服务器端(使用 Go)实例化 PaymentIntent,但遇到此错误Request failed with error: Post "https://api.stripe.com/v1/payment_intents": x509: certificate signed by unknown authority 我已确保分配如下所示的测试密钥,但错误仍然存在。 和SSL证书有关系吗? 我正在使用 Docker (localhost) 在本地测试我的应用程序。

我的代码:

import (
    "github.com/stripe/stripe-go"
    "github.com/stripe/stripe-go/paymentintent"
)

func CreateStripePaymentIntent(subtotal float32) (string, error) {
    // Create a PaymentIntent with amount and currency
    stripe.Key = os.Getenv("STRIPE_SECRET_KEY")

    fmt.Println(stripe.Key)

    params := &stripe.PaymentIntentParams{
        Amount:   stripe.Int64(int64(subtotal)),
        Currency: stripe.String(string(stripe.CurrencyUSD)),
    }

    pi, err := paymentintent.New(params)

    if err != nil {
        return "", fmt.Errorf("pi.New: %v", err) // =======> ERROR HERE WHEN CALLING STRIPE API
    }


    return pi.ClientSecret, nil
}

由于我使用scratch Docker 映像运行服务器,因此没有 SSL 证书可供使用。 只需要从第一阶段复制证书(我的是多阶段构建) COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM