fixed api url for portal sessions
This commit is contained in:
@@ -12,9 +12,7 @@ class PaddleCustomerPortalService
|
||||
*/
|
||||
public function createSession(string $customerId, array $options = []): array
|
||||
{
|
||||
$payload = [
|
||||
'customer_id' => $customerId,
|
||||
];
|
||||
$payload = [];
|
||||
|
||||
if (! empty($options['subscription_ids'])) {
|
||||
$payload['subscription_ids'] = array_values(
|
||||
@@ -22,6 +20,6 @@ class PaddleCustomerPortalService
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->post('/customer-portal-sessions', $payload);
|
||||
return $this->client->post("/customers/{$customerId}/portal-sessions", $payload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class BillingPortalTest extends TenantTestCase
|
||||
'*paddle.com/customers' => Http::response([
|
||||
'data' => ['id' => 'cus_123'],
|
||||
], 200),
|
||||
'*paddle.com/customer-portal-sessions' => Http::response([
|
||||
'*paddle.com/customers/*/portal-sessions' => Http::response([
|
||||
'data' => [
|
||||
'urls' => [
|
||||
'general' => [
|
||||
@@ -32,7 +32,12 @@ class BillingPortalTest extends TenantTestCase
|
||||
$response->assertOk();
|
||||
$response->assertJsonPath('url', 'https://portal.example/overview');
|
||||
|
||||
Http::assertSent(fn (Request $request) => $request->hasHeader('Paddle-Version', '1'));
|
||||
Http::assertSent(function (Request $request): bool {
|
||||
$path = parse_url($request->url(), PHP_URL_PATH);
|
||||
|
||||
return $request->hasHeader('Paddle-Version', '1')
|
||||
&& $path === '/customers/cus_123/portal-sessions';
|
||||
});
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'id' => $this->tenant->id,
|
||||
@@ -63,7 +68,7 @@ class BillingPortalTest extends TenantTestCase
|
||||
], 200);
|
||||
}
|
||||
|
||||
if ($path === '/customer-portal-sessions' && $request->method() === 'POST') {
|
||||
if ($path === '/customers/cus_existing/portal-sessions' && $request->method() === 'POST') {
|
||||
return Http::response([
|
||||
'data' => [
|
||||
'urls' => [
|
||||
|
||||
Reference in New Issue
Block a user