This package provides a wrapper around Prodigi Printing API orders. It offers an eloquent way to create, retrieve and cancel orders in Prodigi for Laravel applications.
First make sure to configure the repository in your composer.json by running:
composer config repositories.prodigi vcs https://github.com/Wingly-Company/prodigiThen install the package by running:
composer require wingly/prodigiYou need to configure your Prodigi API key in your .env file.
PRODIGI_API_KEY=your_prodigi_key
You should also set the API environment to be either "sandbox" or "production"
PRODIGI_API=sandbox
To create a new order you should use the create method of the Order class. Check the Prodigi documentation for all the available parameters.
$order = Order::create([
'shippingMethod' => 'Overnight',
'recipient' => [
...
],
'items' => [
...
]
])To retrieve an order from Prodigi you should use the find method of the Order class.
$order = Order::find('ord_840797');To cancel an order first retrieve an instance of your order and then use the cancel method.
$order = Order::find('ord_840797');
$order->cancel();You might want to check if the order is cancelable before you call the cancel action. In that case you can use the canCancel method.
$order = Order::find('ord_840797');
if ($order->canCancel()) {
$order->cancel();
}Prodigi can make callbacks to a custom URL whenever the status of one of your orders changes. By default, a route that points to a webhook controller is configured through the Prodigi service provider. All incoming Prodigi webhook requests will be handled there. Make sure that you have set up your callback URL under the integrations section of the Prodigi dashboard. The webhook controller listens to the prodigi/webhook URL path.
To secure your webhooks you must add a signed URL to Prodigi dashboard. For convenience the package contains a console command that will generate a secure URL for you. Copy the signed URL and add it to Prodigi dashboard. A middleware is in place to validate the signed route requests.
php artisan prodigi:signYou gonna need to list the URI as an exception to the VerifyCsrfToken middleware included in your application.
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'prodigi/*'
];
}