Authenticated resource that creates a payment button, page, or iFrame to accept bitcoin on your website. This can be used to accept bitcoin for an individual item or to integrate with your existing shopping cart solution. For example, you could create a new payment button for each shopping cart on your website, setting the total and order number in the button at checkout.

The code param returned in the response can be used to generate an embeddable button, payment page, or iFrame. Coinbase stores the underlying model in the same way, so the code can be used to generate any of these payment methods. Click one of the links above to see sample code showing how the code parameter is used.

You can set a variety of options on payment buttons. These correspond to the options used on the button generator page.

These include type, style, custom, variable_price, include_email, include_address, custom redirect urls, and more. For a description of each of these see the documentation below.

Examples

# Request
POST https://coinbase.com/api/v1/buttons
{
  "button": {
    "name": "test",
    "type": "buy_now",
    "price_string": "1.23",
    "price_currency_iso": "USD",
    "custom": "Order123",
    "callback_url": "http://www.example.com/my_custom_button_callback",
    "description": "Sample description",
    "type": "buy_now",
    "style": "custom_large",
    "include_email": true
  }
}

# Response
{
  "success": true,
  "button": {
    "code": "93865b9cae83706ae59220c013bc0afd",
    "type": "buy_now",
    "style": "custom_large",
    "text": "Pay With Bitcoin",
    "name": "test",
    "description": "Sample description",
    "custom": "Order123",
    "callback_url": "http://www.example.com/my_custom_button_callback",
    "price": {
      "cents": 123,
      "currency_iso": "USD"
    }
  }
}
  

Params

Param name Description
button
required

Button object containing the following params


Value: Must be a Hash
button[name]
required

The name of the item for which you are collecting bitcoin. For example, Acme Order #123 or Annual Pledge Drive


Value: Must be String
button[price_string]
required

Price as a decimal string, for example 1.23. Can be more then two significant digits if price_currency_iso equals BTC.


Value: Must be String
button[price_currency_iso]
required

Price currency as an ISO 4217 code such as USD or BTC. This determines what currency the price is shown in on the payment widget.


Value: Must be String
button[type]
optional

One of buy_now, donation, and subscription. Default is buy_now.


Value: Must be String
button[repeat]
optional

Required if ‘type’ is subscription. Must be one of never, daily, weekly, every_two_weeks, monthly, quarterly, and yearly


Value: Must be String
button[style]
optional

One of buy_now_large, buy_now_small, donation_large, donation_small, subscription_large, subscription_small, custom_large, custom_small, and none. Default is buy_now_large. none is used if you plan on triggering the payment modal yourself using your own button or link.


Value: Must be String
button[text]
optional

Allows you to customize the button text on custom_large and custom_small styles. Default is Pay With Bitcoin.


Value: Must be String
button[description]
optional

Longer description of the item in case you want it added to the user’s transaction notes.


Value: Must be String
button[custom]
optional

An optional custom parameter. Usually an Order, User, or Product ID corresponding to a record in your database.


Value: Must be String
button[custom_secure]
optional

Set this to true to prevent the custom parameter from being viewed or modified after the button has been created. Use this if you are storing sensitive data in the custom parameter which you don’t want to be faked or leaked to the end user. Defaults to false. Note that if this value is set to true, the custom parameter will not be included in success or failure URLs, but it WILL be included in callbacks to your server.


Value: Must be Boolean
button[callback_url]
optional

A custom callback URL specific to this button. It will receive the same information that would otherwise be sent to your Instant Payment Notification URL. If you have an Instant Payment Notification URL set on your account, this will be called instead — they will not both be called.


Value: Must be String
button[success_url]
optional

A custom success URL specific to this button. The user will be redirected to this URL after a successful payment. It will receive the same parameters that would otherwise be sent to the default success url set on the account.


Value: Must be String
button[cancel_url]
optional

A custom cancel URL specific to this button. The user will be redirected to this URL after a canceled order. It will receive the same parameters that would otherwise be sent to the default cancel url set on the account.


Value: Must be String
button[info_url]
optional

A custom info URL specific to this button. Displayed to the user after a successful purchase for sharing. It will receive the same parameters that would otherwise be sent to the default info url set on the account.


Value: Must be String
button[auto_redirect]
optional

Auto-redirect users to success or cancel url after payment. (Cancel url if the user pays the wrong amount.)


Value: Must be Boolean
button[variable_price]
optional

Allow users to change the price on the generated button.


Value: Must be Boolean
button[choose_price]
optional

Show some suggested prices


Value: Must be Boolean
button[include_address]
optional

Collect shipping address from customer (not for use with inline iframes).


Value: Must be Boolean
button[include_email]
optional

Collect email address from customer (not for use with inline iframes).


Value: Must be Boolean
button[price1]
optional

Suggested price 1


Value: Must be String
button[price2]
optional

Suggested price 2


Value: Must be String
button[price3]
optional

Suggested price 3


Value: Must be String
button[price4]
optional

Suggested price 4


Value: Must be String
button[price5]
optional

Suggested price 5


Value: Must be String
comments powered by Disqus