Direct repricing
13152
page-template,page-template-full_width,page-template-full_width-php,page,page-id-13152,page-child,parent-pageid-13017,strata-core-1.0.4,strata-child-theme-ver-1.0.0,strata-theme-ver-3.0.6,ajax_fade,page_not_loaded,wpb-js-composer js-comp-ver-5.7,vc_responsive

Direct repricing

Direct repricing via Link My Store feature

 

This is the most elegant and efficient method to perform repricing. In essence, if you integrate your online store with Price2Spy using Link My Store – Price2Spy will be able to perform price changes on your store.

The stores where Price2Spy currently supports this feature are

 

Direct repricing via Web Hook

 

This repricing method is applicable no matter what eCommerce platform you may be using. However, it does mean certain involvement from your IT.

The way this repricing method actually works is that Price2Spy will send a HTTP(S) request to your server, containing the information your software would need in order to perform the price change within your own system.

The HTTP(S) request will be sent to the URL you specify in your Price2Spy account Settings (please see Repricing tab) and will contain

 

  • Header parameter Authorization which will contain value defined in AUTH_CODE (also defined in your Account Settings (Repricing tab). This way your application can check the authenticity of the repricing request coming from Price2Spy.
  • Repricing data in JSON format, containing following elements
    • productName – product name as defined in your Price2Spy account
    • productInternalId – product’s internal ID, as defined in your Price2Spy account (usually used for looking up product in your own database)
    • productSku – product’s SKU, as defined in your Price2Spy account (sometimes used for looking up product in your own database)
    • producLinkMyStorelId – (only applicable if you have integrated your Price2Spy with your own store, using ‘Link My Store’ feature) – in this case this is the field you should use for looking up the product in your own database
    • currentPrice – current price of your product, as known to Price2Spy
    • suggestedPrice – new price, as defined in Price2Spy’s repricing module
    • dateRepricingRequestSent – the timestamp when this repricing HTTP(s) request was sent (according to Price2Spy’s server time)

 

Here is one example of such JSON code

{
“productName” : “GIGATRON GAME BAYONET”,
“productInternalId” : “673-11-54”,
“productSku” : “10782722AES”,
producLinkMyStorelId” : ““,
“currentPrice” : 150.0,
“suggestedPrice” : 118.8,
“dateRepricingRequestSent” : “2017-10-27 01:52:43”
}

 

Based on response received from your Web server, Price2Spy will log this repricing request as Success or Failure.

Please find below a PHP code sample that can be used to process a Webhook repricing request

$app->post(‘/web-hook’, function (Request $request, Response $response) {

 

// Get Authorization header from request
$authorization = $request->getHeader(‘Authorization’);
$headerValue = $authorization[0];
// Get Authorization code from your aplication settings
$webHookAuthorizationCode = $this->settings[‘webHookAuthorizationCode’];

 

// Check Authorization code
if ($headerValue === $webHookAuthorizationCode) {
// Get request body data
$body = $request->getParsedBody();

 

// Here you can parse JSON data
$suggestedPrice = $body[‘suggestedPrice’];
print_r($suggestedPrice);

 

$productSku = $body[‘productSku’];
print_r($productSku);

 

$dateRepricingRequestSent = $body[‘dateRepricingRequestSent’];
print_r($dateRepricingRequestSent);

 

$productLinkMyStoreId = $body[‘productLinkMyStoreId’];
print_r($productLinkMyStoreId);

 

$currentPrice = $body[‘currentPrice’];
print_r($currentPrice);

 

$productInternalId = $body[‘productInternalId’];
print_r($productInternalId);

 

$productName = $body[‘productName’];
print_r($productName);

 

die(“OK”);
} else {
die(‘Authorization failed’);
}
});