-
Notifications
You must be signed in to change notification settings - Fork 33
Home
Please note that this SDK still contains some references to the previous 'Beanstream' name.
Also check out our main developer documentation located at dev.na.bambora.com
Head over to the Quick Start Guide and create a developer sandbox account. Take note of the Merchant ID it gives you.
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
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](https://web.na.bambora.com/admin/sDefault.asp 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!