Download the PHP package wingly/pwinty without Composer
On this page you can find all versions of the php package wingly/pwinty. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wingly/pwinty
More information about wingly/pwinty
Files in wingly/pwinty
Package pwinty
Short Description A laravel package to work with pwinty image printing API
License MIT
Homepage https://github.com/Wingly-Company/pwinty
Informations about the package pwinty
Pwinty
This package makes working with Pwinty image-printing API in Laravel applications a breeze. You can place orders, add images and submit them for shipping. You can also subscribe to Pwinty webhooks after you configure your callback URL at the Pwinty dashboard.
Installation
You can install this package through composer.
Usage
Database migrations
The Pwinty service provider registers it's own database migrations, so make sure that you run your migrations after installing the package. A new orders table will be created to hold all your users orders.
Pwinty environment setup
You need to configure your Pwinty API key and merchant ID in your .env
file.
You should also set the API environment to be either "sandbox" or "production"
Working with orders
Add the Orderer trait to your model. The trait provides methods to create and retrieve orders easily.
By default the App\User
model is used. You can change this by specifying a different model in your .env
file.
Creating orders
To create a new order first retrieve an instance of your orderer model and use the newOrder
method to create an order. This method will return you an instance of the OrderBuilder
where you can set your order parameters. You should finish the order by calling the create
method last. Check the Pwinty documentation for all available parameters.
Adding images to orders
After creating an order you can add images to the order by calling the addImage
method on your Order
instance. The method requires an identification code of the product for this image and the image's URL. You can add multiple images to the order by chaining the addImage
method.
Submitting an order
When you are ready you can submit your order to Pwinty for processing. The validity of the order will first be checked and then submitted. If the order is not ready to be submitted an OrderUpdateFailure
exception will be thrown. You can check if an order is submitted by calling the submitted
method on your Order
instance.
Cancelling an order
You can cancel an open order at any given time by calling the cancel
method on your Order
instance. If the order status is not cancellable an OrderUpdateFailure
exception will be thrown. You can check if an order is cancelled by calling the cancelled
method.
Updating an order
You can update any attribute of an open order by calling the updatePwintyOrder
on your Order
instance. If the order status is not updatable an OrderUpdateFailure
exception will be thrown. The method will return you the raw Pwinty order object.
Getting the raw Pwinty order
You can get the raw Pwinty order object by calling the asPwintyOrder
method on your Order
instance. Check the Pwinty documentation for an example response.
Processing Pwinty Webhooks
Pwinty 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 Pwinty service provider. All incoming Pwinty webhook requests will be handled there.
Make sure that you have set up your callback URL under the integrations section of the Pwinty dashboard. The webhook controller listens to the pwinty/webhook
URL path.
Signed Webhook URL
To secure your webhooks you must add a signed URL to Pwinty 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 Pwinty dashboard. A middleware is in place to validate the signed route requests.
CSRF Protection
You gonna need to list the URI as an exception to the VerifyCsrfToken
middleware included in your application.
Events
The package emits a Wingly\Pwinty\Events\WebhookProcessed
event when a webhook was processed. The event contains the full payload of the Pwinty webhook.
You can listen to this event if your application requires to take any actions when a webhook is received.
Changelog
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details.
Credits
- Dimitris Karapanos
- All Contributors
License
The MIT License (MIT). Please see the license file for more information.
All versions of pwinty with dependencies
illuminate/database Version ^8.0
illuminate/support Version ^8.0
guzzlehttp/guzzle Version ^7.0