The Button API is designed around REST. Request parameters must be given as JSON-encoded request body.

The only unusual request parameter is api_key which is sent as a basic authentication username. You can generate and manage API keys in your Button dashboard. API keys are secret and should be treated like passwords by storing them somewhere secure.

from pybutton import Client

client = Client('sk-XXX')

response = client.orders.create({
    'total': 50,
    'currency': 'USD',
    'order_id': '2007',
    'finalization_date': '2017-08-02T19:26:08Z',
    'btn_ref': 'srctok-XXX',
    'customer': {
        'id': 'mycustomer-1234',
        'email_sha256': hashlib.sha256("[email protected]".lower().strip()).hexdigest(),
    },
})
var client = require('@button/button-client-node')('sk-XXX');

client.orders.create({
  total: 50,
  currency: 'USD',
  order_id: '1989',
  finalization_date: '2017-08-02T19:26:08Z',
  btn_ref: 'srctok-XXX',
  customer: {
    id: 'mycustomer-1234',
    email_sha256: crypto.createHash('sha256').update('[email protected]'.toLowerCase().trim()).digest('hex')
  }
}, function(err, res) {
    // ...
});
require 'button'

client = Button::Client.new('sk-XXX')

response = client.orders.create({
  total: 50,
  currency: 'USD',
  order_id: '1994',
  finalization_date: '2017-08-02T19:26:08Z',
  btn_ref: 'srctok-XXX',
  customer: {
    id: 'mycustomer-1234',
    email_sha256: Digest::SHA256.hexdigest('[email protected]'.downcase.strip)
  }
})
curl https://api.usebutton.com/v1/order \
  -X POST \
  -u YOUR_API_KEY: \
  -H "Content-Type: application/json" \
  -d '{
    "total": 50,
    "currency": "USD",
    "order_id": "1994",
    "finalization_date": "2017-08-02T19:26:08Z",
    "btn_ref": "srctok-XXX",
    "customer": {
      "id": "mycustomer-1234",
      "email_sha256": "'`echo -n "[email protected]" | openssl dgst -sha256`'"
    }
  }'