使用測(cè)試數(shù)據(jù),我可以創(chuàng)建一個(gè)客戶并附加一種付款方式,但我的所有訂閱都處于這種狀態(tài)。這是我目前創(chuàng)建訂閱的代碼:// StripeCreateSubscription create a new subscription with fixed price for userfunc 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", }我需要做什么才能讓我的訂閱完成付款?
盡管附加了付款詳細(xì)信息,但條帶付款不完整?
繁華開滿天機(jī)
2022-10-17 10:01:30