Summary


Blockonomics payment buttons/links are highly configurable. The article gives an overview on how you can programmatically create payment buttons/links to suit your business needs. Blockonomics uses a concept of child product to enable this feature


Parent Product

This product has to be created manually from Merchant > Payment Buttons. The parent product defines the default values of the product like Product name, code description, price etc It also defines also what customer fields must be accepted in input form and currency (USD/EUR etc)


Parent Product defines the default values of the product


Child Product

Child Products can be created programmatically from a parent product. A child product inherits all values of the parent product. Multiple child products can be created from a single parent product. A child product is allowed to modify the following attributes:

  • Product Name
  • Product Description
  • Value (Price of the Product)
  • Add custom data


API 


POST https://www.blockonomics.co/api/create_child_product

Request Body(JSON encoded - All fields are optional): {"parent_uid": "uid of parent product", "product_name": "name", "product_description": "description," "value": price, "extra_data": "custom_data"}

Headers: {Authorization: Bearer APIKey}


Examples / Use Cases


Cart Checkout

You have a custom website / ecommerce store. On checkout you want the customer to pay the cart value in bitcoin. 


Product Name: Order# 342

Product Description: 1 Red T-shirt. 2 Khaki Trousers (Cart Details)  

Value: 500 (Cart Value)


curl -H 'Authorization: Bearer 2cDNOlCN985d7Rx3atSDOlmMeYaxzho2uPmHheIw4eU' 
-d'{"parent_uid": "b5c04c7c395011ea", "product_name": "Order #412", 
"product_description": "1 Red T-shirt\n2 Khaki Trousers", value:500"}' 
https://www.blockonomics.co/api/create_child_product



Recurring/Subscription Invoices

You charge 5USD per month for your streaming service. Each month you can create an automated invoice and send it to your customer for payment. Since the price of product is same, you just change the product_name for each month. Price and other details are automatically taken from the parent product


Product Name: Invoice For February 2020


curl -H 'Authorization: Bearer 2cDNOlCN985d7Rx3atSDOlmMeYaxzho2uPmHheIw4eU' 
-d'{"parent_uid": "b5c04c7c395011ea", "product_name": "Invoice For February 2020"}' 
https://www.blockonomics.co/api/create_child_product



Adding Custom Data

You customer is already logged in your website and you want to attach data to the invoice to identify the customer. This can be done by using extra_data field. In this example I also want to give the customer a discounted price, so I also changed the price field


Extra Data: "customer_id: btcjohn22"

Value: 250.16 (Price of the product)


curl -H 'Authorization: Bearer 2cDNOlCN985d7Rx3atSDOlmMeYaxzho2uPmHheIw4eU' 
-d'{"parent_uid": "b5c04c7c395011ea",
 "extra_data": "customer_id: btcjohn22", "value": 250.16}'
https://www.blockonomics.co/api/create_child_product



Adding Custom Data via JS(Only Payment Buttons)


For payment buttons, custom data can also be specified on the client side by a data-extra HTML attribute without the need of creating a child product

You can change this attribute via JS and it will be  picked up before form submission   


<a href="" class="blockoPayBtn" data-toggle="modal"data-extra="customer_id: btcjohn22" data-uid="f7570454529a11e7">                               


Using the Child Product

API will return a uid like this f7570454529a11e7-1ee5f340. You can set this uid to a payment button / payment link


Payment Button

<a href="" class="blockoPayBtn" data-toggle="modal" data-uid="f7570454529a11e7-1ee5f340"><img width=160 src="https://www.blockonomics.co/img/pay_with_bitcoin_medium.png"> </a>


Payment Link

https://www.blockonomics.co/pay-url/f7570454529a11e7-1ee5f340


Order Details / Callback Notifications

Order details can fetched via API. HTTP Callback Notiifcations also work via Order Hook URL. Please see our payment button API for more details