Skip to content
Beanstream Payments edited this page Mar 27, 2015 · 4 revisions

Welcome to the Beanstream PHP SDK wiki!

(NOTE: This wiki is still under development)

Here you will find out all the information you need to get started accepting credit card and Interac payments on your website.

The PHP Beanstream SDK makes payments simple and painless. You can get up and running in 3 steps:

Want to jump ahead? Check out our API documentation.

Step 1: Create a Test Account

Head over to the Beanstream site and click the Quick Start button to create your account. Take note of the Merchant ID it gives you.

Step 2: Download the SDK

The suggested method is to use Composer to download the SDK. In your PHP project directory create a composer.json file and put this code in it:

{
  "require": {
    "beanstream/beanstream": "dev-master"
  }
}

Install the dependencies from the command line with: composer install

Step 3: Run this example code

Create a test class in your project and add the following code:

<?php
require 'vendor/autoload.php';

$merchant_id = 'YOUR_MERCHANT_ID'; //your merchant ID (must be a 9 digit string)
$payments_api_key = 'YOU_PAYMENTS_API_PASSCODE'; //payments-specific API passcode
$api_version = 'v1'; //default
$platform = 'www'; //default

//Create Beanstream Gateway
$beanstream = new \Beanstream\Gateway($merchant_id, $payments_api_key, $platform, $api_version);

//Example Card Payment Data
$payment_data = array(
        'order_number' => 'orderNumber0011ty',
        'amount' => 1.00,
        'payment_method' => 'card',
        'card' => array(
            'name' => 'Mr. Card Testerson',
            'number' => '4030000010001234',
            'expiry_month' => '07',
            'expiry_year' => '22',
            'cvd' => '123'
        )
);
$complete = TRUE; //set to FALSE for PA

//Try to submit a Card Payment
try {

    $result = $beanstream->payments()->makeCardPayment($payment_data, $complete);
    print_r( $result );
    /*
     * Handle successful transaction, payment method returns
     * transaction details as result, so $result contains that data
     * in the form of associative array.
     */
} catch (\Beanstream\Exception $e) {
    /*
     * Handle transaction error, $e->code can be checked for a
     * specific error, e.g. 211 corresponds to transaction being
     * DECLINED, 314 - to missing or invalid payment information
     * etc.
     */
}

Switch the merchant ID value from YOUR_MERCHANT_ID to your actual merchant ID.

Next, head to the Merchant Member Area and navigate to

Administration -> Account -> Order Settings

Copy the API Key and replace the ApiKey variable's "YOUR_API_PASSCODE" with your actual API key.

Run the code to make a payment!

Clone this wiki locally