Creating a token

It is possible to request the recording of the payment method (and thus token creation) without it being linked to an order.

For this, you need to call the TOKEN API to create a token, with a query similar to the one used for creating a payment.

To create a token using the payment page:

Example of a POST TOKEN call:

POST https://secure.lyra.com/marketplace/tokens/

{
	"marketplace": "9537e049-8862-400a-ae8d-da2ec9ca6051",
	"url_return": "http://www.my-website.com/",
	"buyer": {
		"type": "PRIVATE",
		"first_name": "John",
		"last_name": "Smith",
		"email": “john.smith@lyra.fr",
		"phone_number": "1234",
		"reference": "Buyer_1",
		"address": {
			"zipcode": "59259",
			"street_number": "37",
			"country": "FR",
			"street": "rue Marcel Philippe",
			"city": "Vignoux"
		}
	}
}

Example of a POST TOKEN response:

{
	"token": "d3329266-c8d6-421c-8d2a-10a8ffbcaef6",
	"payment_url": "https://secure.lyra.com/vads-payment/exec.refresh.a;jsessionid=335D2aDb5eF8356Aed2cf3dF.vadpayment02inte01lbg?cacheId=913355311811276000040"
}

Once the token has been created, the Buyer must be redirected to the URL transmitted in payment_url in order to proceed to payment method recording (and thus to creating a token).

To create a token using the embedded form:

Example of a POST TOKEN call:

POST https://secure.lyra.com/marketplace/tokens/embedded/

{
	"marketplace": "9537e049-8862-400a-ae8d-da2ec9ca6051",
	"url_return": "http://www.my-website.com/",
	"buyer": {
		"type": "PRIVATE",
		"first_name": "John",
		"last_name": "Smith",
		"email": “john.smith@lyra.fr",
		"phone_number": "1234",
		"reference": "Buyer_1",
		"address": {
			"zipcode": "59259",
			"street_number": "37",
			"country": "FR",
			"street": "rue Marcel Philippe",
			"city": "Vignoux"
		}
	}
}

Example of a POST TOKEN response:

{
	"token": "d3329266-c8d6-421c-8d2a-10a8ffbcaef6",
	"form_token":"fa0yfV2FQuR3aak1SwsgcuZg195eyJhbW91bnQiOjEwOTAwLCJjdXJyZW5jeSI6IkVVUiIsIm
				1vZGUiOiJURVNUIiwidmVyc2lvbiI6Mywib3JkZXJJZCI6IjVjNDk1N2E5LWNkOGEtNGJhZC1hMGNiLTgxMT
				ZiMWE3ZDdmNiIsInNob3BOYW1lIjoiTHlyYSBTTVMiLCJicmFuZFByaW9yaXR5IjpbIkJBTkNPTlRBQ1QiL
				CJDQiIsIkUtQ0FSVEVCTEVVRSIsIk1BU1RFUkNBUkQiLCVGQVVMVCJ9fX0a702"
}

Once the token is created, the form_token must be inserted in the form (kr-form-token attribute) to proceed to payment method recording (and thus to creating a token).