尽管附加了付款详细信息,但条带付款不完整?

http://img.mukewang.com/634cb78900019dc904560186.jpg

使用测试数据,我可以创建一个客户并附加一种付款方式,但我的所有订阅都处于这种状态。这是我目前创建订阅的代码:


// StripeCreateSubscription create a new subscription with fixed price for user

func StripeCreateSubscription(w http.ResponseWriter, r *http.Request) {

    if r.Method != "POST" {

        SendResponse(w, utils.MakeError("you can only POST to the stripe create customer route"), http.StatusMethodNotAllowed)

        return

    }


    // Decode the JSON payload

    type requestPayload struct {

        PaymentMethodID string `json:"paymentMethodId"`

        PriceID         string `json:"priceId"`

    }


    var payload requestPayload

    if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {

        sendSystemError(w, fmt.Errorf("decode request payload: %v", err))

        return

    }


    // Get the user from the context of who made the request

    uid := r.Context().Value("user_id").(int)


    u := models.User{}

    if err := u.FindByID(uid); err != nil {

        sendSystemError(w, fmt.Errorf("find user by id: %v", err))

        return

    }

    if u.StripeCustomerID == "" {

        sendSystemError(w, errors.New("no customer for the user"))

        return

    }


    // Attach the payment method to the customer

    paymentParams := &stripe.PaymentMethodAttachParams{

        Customer: stripe.String(u.StripeCustomerID),

    }


    pm, err := paymentmethod.Attach(

        payload.PaymentMethodID,

        paymentParams,

    )


    if err != nil {

        sendSystemError(w, fmt.Errorf("attaching payment method failed: %v", err))

    }


    // Check if the user has any active subscriptions, and cancel the others if they're adding one.

    listParams := &stripe.SubscriptionListParams{

        Customer: u.StripeCustomerID,

        Status:   "all",

    }


我需要做什么才能让我的订阅完成付款?


繁华开满天机
浏览 65回答 1
1回答

缥缈止盈

使用固定价格订阅指南default_incomplete显示在创建订阅时明确保持初始发票未被尝试。要完成设置,您需要使用来自应用程序客户端的客户端密码通过支付元素(或卡元素)确认支付。你好像已经在寄回了,你在用吗?client_secret
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go