Library setup

We provide PHP library to help you easily integrate your PHP application with Pencepay.

Dependencies

PHP version >= 5.2.1 is required.

The following PHP extensions are required:

  • curl
  • dom
  • hash
  • openssl

Installation

You can install this library via Composer, by adding this to your composer.json:

    {
      "require": {
        "pencepay/pencepay-php": "1.*"
      }
    }

To install, run the command:

composer.phar install

If you wish to use the library without Composer, you can install it manually

git clone https://github.com/pencepay/pencepay-php

Now include the library into your application:

// If you are using Composer, include the Library in your project with:
require_once('vendor/autoload.php');

// or if you are not using Composer, just include the library directly:
require_once('/path/to/pencepay-php/lib/Pencepay.php');

Using the Pencepay Library

Library is now ready to use within your application. You just have to configure your public and secret key, choose the gateway environment and you are ready to run your first transactions.

Pencepay_Context::setPublicKey("your-public-key");
Pencepay_Context::setSecretKey("your-secret-key");
Pencepay_Context::setEnvironment(Pencepay_Context::PRODUCTION);

$transaction = Pencepay_Transaction::create(
    Pencepay_Request_Transaction::build()
        ->orderId('123456')
        ->amount(10.99)
        ->currencyCode('EUR')
        ->creditCard()
            ->cardholderName('John Hancock')
            ->number('4350100010001002')
            ->cvv('313')
            ->expiryMonth(12)
            ->expiryYear(2016)
            ->done()
);

print_r($transaction);

Source

Library is available at GitHub. Please report any issues using the project's Issue Tracker on GitHub.