QR Code Metadata
Metadata are fields passed to the Turbo API and returned back. These extra fields can be supplied as additional POST fields to our API.
One scenario where this would be useful, is to supply a customer name and account number to tie the payment to the customer and their corresponding account.
We will return these values in two places:
1) In the API JSON response object in the
metadata array.
2) In webhooks when payments are completed. To receive these webhooks from our server, please set a webhook URL under Settings > Payments in the Turbo dashboard.
Parameters
To view all parameters, see
QR.
example
optional - any amount of fields with a name of your choice. If you want to tie the payment to customer ABC123 with account number XYZ456, then the metadata fields would look like this: customer=ABC123&account_number=XYZ456
curl \
-X POST \
-d api_key=TURBO_API_KEY \
-d amount=1.00 \
-d customer=ABC123 \
-d account_number=XYZ456 \
https://api.tur.bo/qr
<?php
$api_url ='https://api.tur.bo';
$api_path='/qr';
$api_key ='TURBO_API_KEY';
$amount =1.00;
$metadata=array( 'customer'=>'ABC123','account_number'=>'XYZ456' );
$fields =array( 'api_key'=>$api_key,'amount'=>$amount,$metadata );
$opts =array( 'form_params'=>$fields );
try {
$client =new GuzzleHttp\Client( array( 'base_uri'=>$api_url ) );
$response=$client->post( $api_path,$opts );
$json =$response->getBody();
echo $json;
}
catch( Exception $e ) {
echo 'error = ',$e->getMessage(),"\n";
}
?>
#!/usr/bin/python
import requests
import json
api_url="https://api.tur.bo/qr"
result=requests.post( api_url,data="api_key=TURBO_API_KEY&amount=1.00&customer=ABC123&account_number=XYZ456" )
print( json.dumps( result.json() ) )
#!/usr/bin/env ruby
require 'uri'
require 'net/http'
api_url="https://api.tur.bo/qr"
uri =URI( api_url )
result =Net::HTTP.post_form( uri,'api_key'=>'TURBO_API_KEY','amount'=>'1.00','customer'=>'ABC123','account_number'=>'XYZ456' )
puts result.body
{
"ach":"no",
"amount":"1.00",
"api_path":"/qr",
"branding":"logo",
"created":1698859189,
"domain":"tur.bo",
"error":false,
"id":"abc123",
"metadata":[{ "customer":"ABC123","account_number":"XYZ456" }]
"msg":"OK",
"name":null,
"qr":"https://api.tur.bo/images/abc123.png",
"reusable":"yes",
"reusable_limit":null,
"show_link":"yes",
"show_name":"yes",
"show_price":"yes",
"status":"created",
"success_url":null,
"url":"https://tur.bo/abc123"
}
JSON response object |
Key |
Value |
error |
true or false depending on if an error has occurred in the API request |
msg |
OK if all is well, otherwise will include descriptive error text |
created |
timestamp for QR code creation |
amount |
payment amount to be collected |
type |
qr |
status |
created |
id |
ID of the QR code that can be used for looking up payment status |
url |
the payment URL for this item |
qr |
URL where the QR code can be accessed |
metadata |
a list of any extra fields passed to the Turbo API about the payment |
branding |
sets a logo in the center of the QR code. supported values are: none for no logo. id to show the unique payment ID. turbo to use the Turbo logo. logo to use your own logo, if one has been uploaded in the customer dashboard |
name |
if set, adds a descriptive name above the QR code. useful for short product names, if name is too long it will be omitted |
show_link |
either yes or no, to show the payment link as text below the QR code. defaults to yes |
show_price |
either yes or no, to show the payment amount as text below the QR code. defaults to yes |