承接 pricemotion/sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pricemotion/sdk

最新稳定版本:v1.2.2

Composer 安装命令:

composer require pricemotion/sdk

包简介

Provides logic shared between Pricemotion integrations for PHP e-commerce systems

README 文档

README

This SDK is used internally for Pricemotion's integrations with different e-commerce systems. It may also be used by customers to integrate with custom or unsupported systems.

Currently this SDK does not provide a complete interface for Pricemotion's API. What it does contain is logic for handling webhook requests, and for processing the XML returned by the Pricemotion API.

Links:

Getting started

Installation is easy, whether you use Composer or not.

With Composer

Run:

composer require pricemotion/sdk

Make sure that vendor/autoload.php is required in your scripts.

Without Composer

Download the source code from the Releases page on GitHub.

Extract it.

Require autoload.php in your scripts.

Dependency injection

If you use a framework that supports automatic dependency injection (autowiring) such as Symfony, or have manually integrated a dependency container such as PHP-DI in your project, you should be able to use it to automatically initialize most of the classes in this SDK.

Handling webhooks

A cache is required for storing Pricemotion's public keys, so that they do not have to retrieved on each request. Any cache that implements Symfony's cache contract is supported.

For example, you might install symfony/cache using Composer and initialize it as follows:

use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$cache = new FilesystemAdapter();

With the cache ready, you can decode incoming webhook requests as follows:

use Pricemotion\Sdk\Crypto\SignatureVerifier;
use Pricemotion\Sdk\Api\WebhookRequestFactory;

$body = file_get_contents('php://input');

$signatureVerifier = new SignatureVerifier($cache);
$webhookRequestFactory = new WebhookRequestFactory($signatureVerifier);
$webhookRequest = $webhookRequestFactory->createFromRequestBody($body);
$product = $webhookRequest->getProduct();

Using product data

Getting the EAN:

$product->getEan()->toString();

Getting the product name:

$product->getName();

Getting the price statistics:

$product->getLowestPrice();
$product->getAveragePrice();
$product->getMedianPrice();
$product->getHighestPrice();

Getting the offers ranked from lowest to highest price:

foreach ($product->getOffers() as $offer) {
  $offer->getSeller();
  $offer->getPrice();
}

统计信息

  • 总下载量: 1.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固