dev-master
9999999-devPaloma Shop client library
MIT
The Requires
The Development Requires
by Astina
Paloma Shop client library
PHP client library for the Paloma Shop. Facilitates the access to the following APIs (see https://docs.paloma.one/ for details and code examples):, (*1)
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., (*2)
// 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);
Hint: Find more examples at https://docs.paloma.one/., (*3)
Get product for a category, sorted by price:, (*4)
$page = $catalog->search(new SearchRequest(...));
Get cart (e.g. to render shopping cart view):, (*5)
$order = $checkout->getCart();
Add product to cart:, (*6)
$order = $checkout->addCartItem('12345', 1);
Update cart item quantity:, (*7)
$checkout->updateCartItem('123' /* order item id */, 2 /* quantity */);
Remove a cart item:, (*8)
$checkout->removeCartItem('123');
Get cart items count:, (*9)
// Number of order items $checkout->getCart()->itemsCount(); // Number of items times quantities $checkout->getCart()->unitsCount();
Set order addresses:, (*10)
$billingAddress = new Address(...); $shippingAddress = new Address(...); $checkout->setAddresses($billingAddress, $shippingAddress);
Initialize payment:, (*11)
$payment = $checkout->initializePayment(new PaymentInitParameters(...));
Use $payment->getProviderParams()
to create payment URL or to render payment form., (*12)
Place the order:, (*13)
$orderPurchase = $checkout->purchase(); echo 'Purchased order ' . $orderPurchase->getOrderNumber() . '!';
Paloma Shop client library
MIT