Embedding into SaaS Products (Association of Existing Users with Purchased Products)
If you are offering a SaaS product on the SaaSus Platform, you will need to implement consideration for multitenant in the purchase flow by existing users.
Please finish the implementation until the test phase of the 'Confirmation of Integration with AWS Marketplace'. Since it will be subject to review by the AWS Marketpalce Support team, you will not be allowed to list it without proper implementation.
When an existing user purchases a product from AWS Marketplace and signs in to your SaaS, the association between the existing user and the purchased product has not completed yet.
This is because the purchased product needs to be associated with the tenant. In the SaaSus Platform specifications, an existing user may belong to multiple tenants. Since SaaSus Platform cannot comprehend that, you are required to implement an association between the purchased product and the tenant the user belongs to, on your side.
Process of Implementation
-
Implement judgment procedure for when an existing user purchases a product from AWS Marketplace and signs in, coming to the Callback page.
When a user purchases a product from AWS Marketplace and signs in, coming to the Callback page, the registration_token parameter is assigned to the Callback URL set by you. Implement a process to determine its existence and make a branch based on that.
https://example.com/defaultcallback?code=xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx®istration_token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
-
Create an account selection page to be used.
If there is a registration_token parameter, it should display a page to select which account to purchase as below.
Create the select box content from user information $request->userinfo
who made the request.
- PHP
// Callback destination
function index(Request $request)
{
// Various user information, tenant information is set in $request->userinfo
return view('selectAccount.index', ['tenants' => $request->userinfo["tenants"]]);
}
In the View side, create a select box using tenants
and set tenant["id"]
to Value to use the selected account information.
- HTML
<select name="tenant_id">
@foreach ($tenants as $tenant)
<option value="{{ $tenant["id"] }}">{{ $tenant["name"] }}</option>
@endforeach
</select>
- Execute SAASUS AUTH API's LinkAwsMarketplace for the selected account.
After choosing an account, callLinkAwsMarketplace
.
- PHP
// The process when 'Get started with this account' is pressed
function post(Request $request)
{
// Use SaaSus SDK
$client = new ApiClient();
$auth_api_client = $client->getAuthClient();
// Set AWS Marketplace and tenant linking parameters
$link_marketplace_param = new CreateLinkAwsMarketplaceParam();
// Meet the tenant ID sent from the account selection page
$link_marketplace_param->setTenantId($request->tenant_id);
$link_marketplace_param->setAccessToken($request->_token);
// registration_token received at the time of Callback
$link_marketplace_param->setRegistrationToken($request->registration
// Linking the purchased product and the tenant
$auth_api_client->LinkAWSMarketplace($link_marketplace_param);
// Transition to the product page
return view('xxxxxxxxxxx.index', ['xxxxx' => $xxxxxx]);
}