LaravelPackages.net
Acme Inc.
Toggle sidebar
shabananavas/php-bluesnap-sdk

A PHP SDK for the BlueSnap API

6.757
0
v0.3.5
About shabananavas/php-bluesnap-sdk

shabananavas/php-bluesnap-sdk is a Laravel package for a php sdk for the bluesnap api. It currently has 0 GitHub stars and 6.757 downloads on Packagist (latest version v0.3.5). Install it with composer require shabananavas/php-bluesnap-sdk. Discover more Laravel packages by shabananavas or browse all Laravel packages to compare alternatives.

Last updated

BlueSnap PHP Library

This (unofficial) library standardizes and simplifies working with the BlueSnap API.

All the standard API documentation is applicable to this library.

View the BlueSnap documentation here: https://developers.bluesnap.com/

This library currently supports:

  • CardTransactions
  • VaultedShoppers
  • Vendors
  • Subscriptions
  • Plans (Subscriptions)
  • Refunds
  • Reports
  • Generating a Hosted Payment Fields token

Installation

Install this package with composer

composer require shabananavas/php-bluesnap-sdk

Usage

Initialize the library in your class constructor

public function __construct()
{
    $environment = 'sandbox'; // or 'production'
    \Bluesnap\Bluesnap::init($environment, 'YOUR_API_KEY', 'YOUR_API_PASSWORD');
}

Create a New Hosted Payment Fields Token

public function getHostedPaymentFieldsToken() {
  $data = \Bluesnap\HostedPaymentFieldsToken::create();
  return $data['hosted_payment_fields_token'];
}

Create a New Transaction

public function createTransaction()
{
    $response = \Bluesnap\CardTransaction::create([
        'creditCard' => [
            'cardNumber' => '4263982640269299',
            'expirationMonth' => '02',
            'expirationYear' => '2018',
            'securityCode' => '837'
        ],
        'amount' => 10.00,
        'currency' => 'USD',
        'recurringTransaction' => 'ECOMMERCE',
        'cardTransactionType' => 'AUTH_CAPTURE',
    ]);

    if ($response->failed())
    {
        $error = $response->data;
        
        // handle error
    }

    $transaction = $response->data;
    
    return $transaction;
}

See examples for further details on using the library

License

This package is licensed under the MIT License

Star History Chart