Tag Archives: bt.tn

PayPal bttn for Commerce

By

PayPal bttnIn my first rotation of PayPal’s Technology Leadership Program (TLP), I was fortunate enough to work on our Western Europe region out of our Paris office. The team there wanted to tap into the Internet of Things (IoT) market and with PayPal’s strategic movement from just a button on a website to existing across all contexts – including the offline world — it was clear that a physical button that integrates with our Braintree APIs was something worth investigating.

After some investigation, we found bt.tn, a start-up that has an innovative approach to buttons and is based out of Helsinki, Finland. Over the course of a few months, we had a working prototype, and today we have open-sourced this integration to allow anyone to integrate a bttn with PayPal. This technology will allow a business to associate their customer in a Braintree vault to a physical button and can be used over cell data, wifi, or the Sigfox network.

This product realizes the full potential of bttn and a Braintree-enabled merchant account in a way that most people might not think of. In order to avoid any database usage, the code was written to leverage both Braintree and bttn features that allowed for us to save information in these systems without the need for a database. All of this was done with a very small amount of code.

This first comes into play in recording the status of a bttn. There are two custom Braintree fields that are important to discuss. bttn_status is defined as either ACTIVE: Able to be used by a consumer, ONBOARDED: The consumer has shown interested in receiving a bttn or the bttn is being sent to the consumer, or UNREGISTERED: The consumer no longer has a button linked to their account in the merchant’s Braintree vault. A bttn_code is the unique code that is generated by bttn after the bttn has been registered. An example of the function to update bttn_status is supplied below.


function updateButtonStatusOnBraintree($braintreeCustomerId, $status)
{
  $statuses = array("ACTIVE", "ONBOARDED", "UNREGISTERED");
  if( !in_array($status, $statuses) )
  {
    die("Status: $status not in list of valid statuses.");
  }

  $updateResult = Braintree_Customer::update(
    $braintreeCustomerId,
    [
      'customFields' => array(
        "bttn_status" => $status
      )
    ]
  );
  return $updateResult->success;
}

See web/lib/braintree.php for more details.

Once the bttn is associated with a consumer, another call to the bttn API to associate metadata with the bttn must be performed. This is where the Braintree Customer ID, bt_id, is stored along with charge_type and url. The url parameter is called whenever the bttn is pressed. In our case, this happens to be process_button_push.php. The charge_type parameter indicates whether the payment should be fixed price (a single amount), reorder (charge the customer’s previous order amount), or selection (send the customer a selection of things to purchase via email, SMS, or push notification).
We have worked with bttn to make getting started easy.

  1. Purchase a bttn and fill out this form to enable the bttn-for-commerce integration. You will receive an email from bttn with your BTTN_API_KEY and BTTN_API_MERCHANT_NAME.
  2. When you receive your button, register it.
  3. Apply the bttn-for-commerce action to your bttn.

More specific steps and screenshots are available in the paypal-bttn GitHub project which is meant to be a proof of concept.