PHP code example of sharpapi / laravel-ecommerce-thank-you-email
1. Go to this page and download the library: Download sharpapi/laravel-ecommerce-thank-you-email library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sharpapi / laravel-ecommerce-thank-you-email example snippets
namespace App\Http\Controllers;
use GuzzleHttp\Exception\GuzzleException;
use SharpAPI\EcommerceThankYouEmail\EcommerceThankYouEmailService;
class EmailController extends Controller
{
protected EcommerceThankYouEmailService $thankYouEmailService;
public function __construct(EcommerceThankYouEmailService $thankYouEmailService)
{
$this->thankYouEmailService = $thankYouEmailService;
}
/**
* @throws GuzzleException
*/
public function generateThankYouEmail(string $productName)
{
$statusUrl = $this->thankYouEmailService->generateThankYouEmail(
$productName,
'English', // optional language
250, // optional maximum length
'Friendly', // optional voice tone
'Include information about our loyalty program' // optional context
);
$result = $this->thankYouEmailService->fetchResults($statusUrl);
return response()->json($result->getResultJson());
}
}
use GuzzleHttp\Exception\ClientException;
try {
$statusUrl = $this->thankYouEmailService->generateThankYouEmail('Sony PlayStation 5', 'English', 250);
} catch (ClientException $e) {
echo $e->getMessage();
}
bash
php artisan vendor:publish --tag=sharpapi-ecommerce-thank-you-email