VNP Input Webservices - Shopping Cart
Using these services you can build your own ecommerce site, you can add and remove products in a shopping cart. You can also set special prices for any product and use VirtualNewspaper shop engine to complete the purchase process.

As soon as a product is added to the shopping cart from any external shopping page, a call to these services will need to be triggered, adding or removing products within VirtualNewspaper ecommerce engine.
Once the user completes his shopping process, he will be redirected to the standard VirtualNewsPaper ecommerce engine, enabling him to pay (and eventually activate) his order.
Warning:
All of the below described POST calls, need to be url encoded
01) Add a product
When an end user chooses to add a product inside his own shopping cart, a POST request to this service has to be made.
Example : http://checkout.editorname.com/webservice/shop/cartAdd.jsp?productId=492&_=1407775530572
Parameters
| PARAMETER NAME | VALUE FORMAT | DESCRIPTION |
|---|---|---|
| productId | int | VirtualNewspaper unique Product ID (available in VirtualNewspaper back-end) |
| _ | symbol (underscore) | Not a mandatory field. If set to a valid timestamp, this field may prevent the usage of older browser |
Code Example
02) Remove a product
When an user chooses to remove a product from his cart, a POST request to this service will remove the product on the VirtualNewspaper ecommerce user session.
Example : http://checkout.editorname.com/webservice/shop/cartRemove.jsp?productId=492&_=1407775530572
Parameters
| PARAMETER NAME | VALUE FORMAT | DESCRIPTION |
|---|---|---|
| productId | int | VirtualNewspaper unique Product ID (available in VirtualNewspaper back-end) |
| _ | symbol (underscore) | Not a mandatory field. If set to a valid timestamp, this field may prevent the usage of older browser |
Code Example
03) Add a product providing a custom price
When an user chooses to add a product to his cart, a POST request to this service will add the same product on VirtualNewspaper ecommerce user session, eventually providing a custom price, different from the default one set within the product itself.
Example : http://checkout.editorname.com/webservice/shop/cartAdd.jsp?productId=179&_=1407775530572&ts=1407775530572&authCode=396360741fdc4ba600c60df579bc3b70&price_179=9.5
Parameters
| PARAMETER NAME | VALUE FORMAT | DESCRIPTION |
|---|---|---|
| productId | int | VirtualNewspaper unique Product ID (can be found in VirtualNewspaper back-end) |
| _ | symbol (underscore) | Not a mandatory field. If set to a valid timestamp, this field may prevent the usage of older browser |
| ts | int | A key that changes on every single request (you could use a timestamp for example) |
| authCode | String | An md5 hash of ts parameter concatenated to the Private WS key (you can find your own in the Settings module) e.g. md5(ts+privateKeyWS) |
| price_[productId] | float | The custom price you want set to this product. it must contain the ID of the product (in this case the name of this parameter will be price_179) |
Code Example
Important:
If the authCode is wrong, no message will be provided and the product will be added to the cart with its default price.
04) Go to cart
As soon as an user completes his shopping process, you can be provide a button to redirect him to VirtualNewspaper payment flow.
Example : http://checkout.editorname.com/webservice/shop/initCheckout.jsp
Each of the above described services, will reply as follow :
{
"cart": {
"total":14.3,
"items": [
{
"product": {
"fullprice":16.9,
"weight":1,
"productDescription":"Description",
"label":"Label",
"productId":492,
"currency":"EUR",
"months":1,
"price":14.3,
"imageLink":"http://checkout.editorname.com/upload/a261c1b1871a0de09c8333a1662a93a8.jpg",
"issues":"",
"titles":"[ecommerce]",
"productName":"Name",
"availability":61
},
"singlePrice":14.3,
"cartQuantity":1,
"totalPrice":14.3
}
],
"totalWeight":1,
"currency":"EUR"
},
"success":true
}
NOTES
Prices are automatically calculated.
Whenever a custom price is set for a certain product, you will not be able to modify it during the current session. Any attempt of adding product to the cart will increase only its quantity.