#xfechx
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
should be "subscription_cancel"=>["subscription"=>"sub_xxxx"] instead
I have the following, I get error:
'type'=> 'subscription_cancel',
'subscription_cancel' => $subscription_id,
]```
ah ok, perfect
thanks
yes, i saw it, but was confused about it, will try what you just sent through
ok, it works now, but I would still like to show invoice history, and customer details, can this also be 'bundled' with the flow?
when I don't pass any flow or subscripition, I can see a page where invoices are listed for that customer, and also can update details for the customer
with the flow enabled, I can just see cancel or pause the subscription.
well if you're using that option the point of it is that it's a deep link specifically to the part of the portal for cancelling the subscription
you can just not pass it at all if you want the normal flow with the history/details
but if I don't pass it, then I won't target a specific subscrpition
I want to target the specific subscrpition, and have the ability to edit customer details, and see customer invoicing history for that subscription
makes sense. The portal can't cover all use cases sorry
so, with flow, can I only choose one?
'invoice_history' => ['enabled' => true],
'subscription_cancel' => ['enabled' => true],
'subscription_pause' => ['enabled' => true],
'customer_update' => [
'allowed_updates' => ['name', 'address', 'email', 'phone', 'shipping', 'tax_id'],
'enabled' => true,
],
],```
I don't understand the question sorry
I can only choose one feature at a time? when creating the portal configuration?
also, I have another question, I have the error Stripe API Error: The session's customer does not match the subscription's customer.
I am getting customer like this:
$connected_account = array('stripe_account' => $connect);
try {
// Retrieve customer with the given email
$customers = \Stripe\Customer::all(["email" => $email], $connected_account);
if (!empty($customers->data)) {
return $customers->data[0]->id;
} else {
return null;
}
} catch (\Stripe\Exception\ApiErrorException $e) {
// Handle Stripe API errors
error_log("Stripe Error: " . $e->getMessage());
return null;
}
}```
not sure, you can test and see if it throws an error
then you can have multiple
a flow is not the same thing as a feature
you're confusing the concepts
ok, i understand -
however one defines the subscription in the flow data, and I want the portal to be referent to that subscription, not only to the customer id.
sure and that's not possible
like I said: makes sense. The portal can't cover all use cases sorry
makes total sense as a feature request but not possible today
well bear in mind there can be multiple customers with same email address, in your code you just take the first one. Maybe that introduces an issue?
this is something you need to debug, you control and can see exactly what "cus_xxx" and "sub_xxx" IDs you pass to the API calls you make and you can look up those IDs in your Stripe Dashboard and check your code and log variables and understand what might be happening.
ok, ideally my webhook retrieves the customer_id but to make it backwards compatible, I have to retrieve invoice from subscription, is this possible?
well a Subscription has a field latest_invoice that is the ID of the most recent Invoice.
you can also list all the Invoices belonging to a certain Subscription ID.
does that get what you need?
API reference:
https://docs.stripe.com/api/subscriptions/object#subscription_object-latest_invoice
https://docs.stripe.com/api/invoices/list#list_invoices-subscription
ok, I can see the subscription. But now I cannot seem to retrieve the customer from latest invoice. Where can I log this, for a connected express account?
But now I cannot seem to retrieve the customer from latest invoice
what code are you currently using to attempt to do that?
one moment
try {
// Prepare optional parameters for Stripe API requests
$options = [];
if (!is_null($connect)) {
$options['stripe_account'] = $connect;
}
$subscription = \Stripe\Subscription::retrieve($subscription_id, $options);
// Retrieve the latest invoice associated with the subscription
$latest_invoice_id = $subscription->latest_invoice;
$invoice = \Stripe\Invoice::retrieve($latest_invoice_id, [], $options);
// Extract customer ID from the invoice
$customer_id = $invoice->customer;
return $customer_id;
} catch (\Stripe\Exception\ApiErrorException $e) {
// Handle Stripe API errors
error_log("Stripe Error: " . $e->getMessage());
return null;
}
}```
👋 taking over for my colleague. Let me catch up.
you don't need to retrieve the invoice to get the Customer ID
it's already present on the level of the subscription. https://docs.stripe.com/api/subscriptions/object#subscription_object-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.