Skip to content

Repository files navigation

Prodigi

Introduction

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.

Installation

First make sure to configure the repository in your composer.json by running:

composer config repositories.prodigi vcs https://github.com/Wingly-Company/prodigi

Then install the package by running:

composer require wingly/prodigi

Configuration

You 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

Usage

Creating orders

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' => [
        ...
    ]
])

Retrieving orders

To retrieve an order from Prodigi you should use the find method of the Order class.

$order = Order::find('ord_840797');

Canceling orders

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();
}

Processing Prodigi Webhooks

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.

Signed Webhook URL

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:sign

CSRF Protection

You 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/*'
    ];
}

About

A wrapper around Prodigi Print API

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages