wstore programmer guide purchases. agenda 1.purchase api integration – credit card – paypal...

12
WStore Programmer Guide Purchases

Upload: stella-martin

Post on 18-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

WStore Programmer GuidePurchases

Page 2: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Agenda

1. Purchase API integration– Credit card– PayPal

2. Purchase redirection integration3. Purchase notifications

Page 3: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

PURCHASESWStore Programmer Guide

Page 4: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Purchase API integration

WStore supports to integrate purchases with different external applications using the purchases API directly. Using this method to integrate purchases requires the developer to take into account the payment method since it is possible that it needs to redirect users to the PayPal confirmation page. The requests to perform a purchase directly using the purchases API are different depending on the payment method selected.

Page 5: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Purchase API integration

Credit card

The following request shows how to perform a purchase using a credit card. If no tax address or credit card provided, then default values stored in user’s profile are used. Moreover, the field offering used to identify the offering to be purchased could contain different values, apart for the method used in the request (organization, name, version), it is also possible to provide the URL of the USDL in the Repository GEi (description_url field in offering requests), this method is useful to purchase offerings that have been searched in a Marketplace GEi. The plan label field is used to identify the price plan when there are more than one, if only a plan exists this field is not mandatory.

Page 6: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Purchase API integration

POST /api/contracting HTTP 1.1 Content-Type: application/json { “offering”: { “organization”: "CoNWeT" “name”: "SmartCityLights" “version”: "1.0" }, "plan_label": "update", “tax_address”: { “street”: "C/Los alamos n 17", “city”: "Santander", “postal”: "39011", “country”: "Spain" } “payment_info”: { “payment_method”: “credit card”, “credit_card”: { “number”: "546798367265", “type”: "MasterCard", “expire_year”: "2018", “expire_month”: "5", “cvv2”: "111" } } }

WStore responds with a 201 Created code is the request is successful.

Page 7: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Purchase API integration

PayPal

The following request shows how to perform a purchase using a PayPal account. Note that if no tax address provided the default value is used:

POST /api/contracting HTTP 1.1 Content-Type: application/json Accept: application/json { “offering”: { “organization”: "CoNWeT" “name”: "SmartCityLights" “version”: "1.0" }, "plan_label": "update", “tax_address”: { “street”: "C/Los alamos n 17", “city”: "Santander", “postal”: "39011", “country”: "Spain" } “payment_info”: { “payment_method”: “paypal” } }

Page 8: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Purchase API integration

If the request is success WStore will respond with a redirection URL. This URL is created by PayPal and the user browser should be redirected to that window, since, PayPal requires user authentication and confirmation to perform the payment. Response:

HTTP/1.1 200 OK Content-Type: application/json Vary: Cookie {

"redirection_link": "http://paypalredirectionlink.com/" }

Page 9: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Purchase redirection integration

WStore also supports to integrate external applications with the purchase process using WStore web interface to perform the payment. To integrate an application using this method, the client application requests for a purchase formulary for a concrete offering and WStore responds with a redirection URL where the client application should redirect the user browser in order to start the purchasing process:

POST /api/contracting/form HTTP 1.1 Content-Type: application/json Accept: application/json {

"offering": { "organization": "CoNWeT", "name": "SmartCityLights", "version": 1.0, }, "redirect_uri": "http://customerredirecturi.com"

}

Page 10: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Purchase redirection integration

Note that the offering field, used to identify the offering, could also contain the URL pointing to the USDL description in the Repository GEi (description_url field in offering request) in order to allow to integrate WStore with a solution that uses a Marketplace GEi for searching offerings. Response:

HTTP/1.1 200 OK Content-Type: application/json Vary: Cookie {

"url": "http://wstore.lab.fi-ware.eu/contracting/form?ID=63865adf6c2ca6f7" }

The URL returned should be used to redirect the user browser. This URL points to a formulary that allows the user to pay using the WStore GUI. When the user ends the purchase, the window is closed and WStore sends a notification to the client application using the redirect URI provided in the call.

Page 11: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Purchase notifications

When a service provider publish an offering in WStore, s/he should provide an URL where s/he can receive a notification when her offering is purchased in order to know the customer and the purchase reference. The provided URL should support a POST request with the following structure:

POST notification_url HTTP 1.1 Content-Type: application/json {

"offering": { "organization": "CoNWeT", "name": "SmartCityLights", "version": "1.0" } "reference": "51c2d2825d9af944d0d1cfe0", "customer": "santander_crm"

}

Page 12: WStore Programmer Guide Purchases. Agenda 1.Purchase API integration – Credit card – PayPal 2.Purchase redirection integration 3.Purchase notifications

Thanks!Thanks!