#gruneth_api

1 messages ยท Page 1 of 1 (latest)

lethal sunBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1276265015607033958

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

shy cedar
#

Current Code in Go:

func (paymentHandler *PaymentHandler) updateSubscriptionToNewCustomer(customerSourceID, customerDestinationID, subscriptionID string) error {
timestamp := time.Now().Format("2006-01-02_15-04-05")
updateParams := &stripe.SubscriptionParams{
Customer: stripe.String(customerDestinationID),
Metadata: map[string]string{
fmt.Sprintf("transfer_ownership_%s", timestamp): fmt.Sprintf("Transferred this subscription from customerSourceID %s to customerDestinationID %s", customerSourceID, customerDestinationID),
},
}
_, err := subscription.Update(subscriptionID, updateParams)
if err != nil {
paymentHandler.Log.Error("Error transferring subscription to new owner", zap.Error(err))
return errors.New("error transferring subscription to new owner")
}
return nil
}

viral geodeBOT
jovial scroll
#

Hello, unfortunately we don't support switching the customer on a subscription at the moment. You could delete and recreate the subscription object with another customer object, but there isn't a way to copy the PaymentMethod that is paying for the subscription over, so it will typically require the other customer to enter payment method details

shy cedar
#

Hello, thanks for your time.

#

Currently I just attach the payment method as a default payment method to the stripe customer. Any subscription just takes the default payment then. So when switching the subscription to a new stripe customer he would need to add a payment method. That would not be the problem. But deleting and creating a new subscription is not ideal for me as the subscriptionID is used at many places for me.

#

There is no other workaround?

jovial scroll
#

Unfortunately not, we don't have a way of keeping that subscription ID across customers. If it helps with a solution you can set your own ID as metadata on the subscription and could use that across subscriptions that you logically consider to be the same one.

shy cedar
#

Hm alright. Just a follow up question. Would it be a solution if a customer has more then one subscription then I deny the transfer of ownership but if he has only one subscription that I change the e-mail of that customer to the new owner? Would that bad practise?

jovial scroll
#

Good point. Changing the info on the customer itself could be a viable workaround. Though yes that would make it tricky if you have two subscriptions but someone only wanted to change ownership on one. For that you may have to break in to multiple customers

shy cedar
#

It is fine if the customer has more then one subscription that he cannot transfer ownership. Will try this. Thank you very much for your time. Very much appriciate your awesome help.

#

This can be closed. ๐Ÿ™‚ Have a nice evening.

jovial scroll
#

Of course! Sorry we couldn't support your original usecase but I'm happy to hear it sounds like this is still workable for you