From e3f5745406f9498ded06b91ae3e43448c6745769 Mon Sep 17 00:00:00 2001 From: David Grayston Date: Tue, 3 Dec 2024 20:00:38 +0000 Subject: [PATCH] docs: Add customer portal session example --- examples/customer_portal_session.php | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 examples/customer_portal_session.php diff --git a/examples/customer_portal_session.php b/examples/customer_portal_session.php new file mode 100644 index 0000000..16f2289 --- /dev/null +++ b/examples/customer_portal_session.php @@ -0,0 +1,46 @@ +customerPortalSessions->create( + $customerId, + new CreateCustomerPortalSession([$subscriptionId]), + ); +} catch (ApiError|MalformedResponse $e) { + var_dump($e); + exit; +} + +echo sprintf("Created Customer Portal Session: %s\n", $customerPortalSession->id); +echo sprintf(" - Customer ID: %s\n", $customerPortalSession->customerId); +echo sprintf(" - Created At: %s\n", $customerPortalSession->createdAt->format(DATE_RFC3339_EXTENDED)); +echo sprintf(" - General Overview URL: %s\n", $customerPortalSession->urls->general->overview); + +foreach ($customerPortalSession->urls->subscriptions as $subscriptionUrl) { + echo sprintf(" - Subscription URLs: %s\n", $subscriptionUrl->id); + echo sprintf(" - Update Subscription Payment Method URL: %s\n", $subscriptionUrl->updateSubscriptionPaymentMethod); + echo sprintf(" - Cancel URL: %s\n", $subscriptionUrl->cancelSubscription); +}