Buxter Wiki / Setting up the PHP Buxter API Client
View
 

Setting up the PHP Buxter API Client

This guide will show you how to

 

• Download the PHP API Client from SVN

• Set up a Buxter developer account

• Download a comprehensive demo project to learn from

 

1. Prerequisites

The following components are required to build the buxter project

 

2. Downloading the Library

The buxter PHP client is currently maintained at the project site located at http://code.google.com/p/buxter-api/.

Please enter the following commands.

 

mkdir buxter
cd buxter
svn checkout http://buxter-api.googlecode.com/svn/trunk/php/ buxter-api-read-only

 

Now the source code is transferred to your computer.

 

3. Set up a Buxter developer account

 

If you haven't used Buxter before, you will have to sign up for the service first. This is done by logging into your Facebook account and visiting one of the following URLs and accepting the TOS

 

http://apps.facebook.com/buxtersandbox/ - The Buxter sandbox, for development purposes, where no real money is traded

http://apps.facebook.com/mybuxter/ -The Buxter production system

 

Now click on the "Applications" tab. This is the place where you create the link between Buxter and your own application. 

 

When you click on the "Add" Button you will be able to enter your application details. This will be the base information Buxter will use to communicate with your application.

You will be shown the box below in which you can enter three parameters.



Your application name will be shown whenever someone buys an item from you to signal the customer to whom the payment will go to. 

 

Application url is the location to which the customer will be redirected after he has made or cancelled a purchase of an item. The underlying controller code of this url must be able to verify a few parameters that will be passed by buxter to verify if an item was purchased.

 

The Application Icon URL is a link to the icon you want to use as a brand element in the Buxter UI. It will lend your corporate identity to the transaction, though the entire handling is done on the Buxter side. This parameter is optional.

 


For demonstration purposes we will create an online kitten shop.

 

As you can see on the image to the left, the kitten shop was successfully created. Also, Buxter created a set of parameters for us that are quite important.

 

API Configuration ID we will use this as the identifier to Buxter. The three parameters we entered when we created our application are stored under this configuration id.

 

Secret key this is the data that will be used later to calculate the security hashes that will secure the sales process.

 

Status is the status of the Buxter configuration of your application. On creation it is just "Created", you will have to click on "Activate" to enable the Buxter application to receive payments. This is basically a flag for development purposes, if you switched to active your payment configuration is now live.


 

 

4. Make your first call

 

The following example of a Buxter API call has been simplified. Error handling is excluded.

 

require_once( "BuxterPHPClient.class.php" );
// Create the Buxter Client
$client = 
   BuxterPHPClient::createSandboxClient(
      $apiConfigurationID, $buxterSecretKey );

// Create the transaction and retrieve the redirect link
$createTxResponse = 
   $client->createTransactionLink( $amount, $currency,
      $title, $description,
      $buyerFbUID, $redirectURL, $externalID );

// get the transaction id and store it
$transactionId = $createTxResponse->transactionID;

// ...redirect the user to the buxter checkout, 
// the user pays, then he is returned to your app again
$transactionStatus = 
    $client->queryTransactionStatusByTransactionID($transactionId);
if($transactionStatus=="SUCCESS"){
  echo "Thank you for buying at ACME Inc.";
}else{
  echo "Payment unsuccessful.";
}

Comments (0)

You don't have permission to comment on this page.