paloma / shop-client
Paloma Shop client library
Installs: 2 804
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: >=8.1
- ext-json: *
- egulias/email-validator: ^4.0
- guzzlehttp/guzzle: >=7.4
- monolog/monolog: >=3.3
- psr/cache: >=1.0
- symfony/cache: ^6.2
- symfony/http-foundation: >=6.2
- symfony/intl: ^6.2
- symfony/serializer: ^6.2
- symfony/validator: ^6.2
- symfony/yaml: ^6.2
Requires (Dev)
- phpunit/phpunit: ^8.1
- v3.x-dev
- v3.5.1
- v3.5.0
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.0
- v2.x-dev
- v2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.2
- 2.14.1
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.1
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.1
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.3
- 2.0.2
- 2.0.1
- v2.0.0
- v1.3.1
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- dev-v3-symfony-6.4
- dev-schu-253-customers-in-teams
This package is auto-updated.
Last update: 2024-11-11 14:11:22 UTC
README
PHP client library for the Paloma Shop. Facilitates the access to the following APIs (see https://docs.paloma.one/ for details and code examples):
- Catalog
- Checkout
- Customers
Note: This is v3 of the Paloma Shop PHP Client. It is not backwards-compatible with v2 and is intended to be used together with the Paloma Shop Bundle for Symfony.
Usage
// Create Paloma client $factory = new Paloma\Shop\PalomaClientFactory($options); $client = $factory->create([ 'base_url' => 'https://demo.paloma.one/api/', 'api_key' => 'yourAPIKey', 'channel' => 'yourChannel', 'locale' => 'yourLocale', ]); // Create security service $security = new MyPalomaSecurity(); // implements \Paloma\Shop\Security\PalomaSecurityInterface // Create Paloma catalog $catalog = new \Paloma\Shop\Catalog\Catalog($client, new \Paloma\Shop\Common\PricingContextProvider($security)); // Call API, e.g. fetch catalog categories $categories = $catalog->getCategories(); // Create Symfony validator $validator = new Validator(); // implements Symfony\Component\Validator\Validator\ValidatorInterface // Create Paloma checkout $checkout = new \Paloma\Shop\Checkout\Checkout($client, $security, $validator); // Add cart item $checkout->addCartItem('100-200', 1);
Examples
Hint: Find more examples at https://docs.paloma.one/.
Get product for a category, sorted by price:
$page = $catalog->search(new SearchRequest(...));
Get cart (e.g. to render shopping cart view):
$order = $checkout->getCart();
Add product to cart:
$order = $checkout->addCartItem('12345', 1);
Update cart item quantity:
$checkout->updateCartItem('123' /* order item id */, 2 /* quantity */);
Remove a cart item:
$checkout->removeCartItem('123');
Get cart items count:
// Number of order items $checkout->getCart()->itemsCount(); // Number of items times quantities $checkout->getCart()->unitsCount();
Set order addresses:
$billingAddress = new Address(...); $shippingAddress = new Address(...); $checkout->setAddresses($billingAddress, $shippingAddress);
Initialize payment:
$payment = $checkout->initializePayment(new PaymentInitParameters(...));
Use $payment->getProviderParams()
to create payment URL or to render payment form.
Place the order:
$orderPurchase = $checkout->purchase(); echo 'Purchased order ' . $orderPurchase->getOrderNumber() . '!';