2017 © Pedro Peláez
 

library payfort-start-php

Payfort Start makes accepting online payments in the Middle East a piece of cake

image

robustastudio/payfort-start-php

Payfort Start makes accepting online payments in the Middle East a piece of cake

  • Wednesday, March 7, 2018
  • by alash3al
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 71 % Grown

The README.md

Build Status, (*1)

Start PHP

Start makes accepting payments in the Middle East ridiculously easy. Sign up for an account at https://start.payfort.com., (*2)

Getting Started

Using Start with your PHP project is simple., (*3)

Install via Composer

If you're using Composer (and really, who isn't these days amirite?), you can simply run:, (*4)

php composer.phar require robustastudio/payfort-start-php

.. or add a line to your composer.json file:, (*5)

{
    "require": {
        "robustastudio/payfort-start-php": "*"
    }
}

Now, running php composer.phar install will pull the library directly to your local vendor folder., (*6)

Install Manually

Get source code of the latest release from github repository: https://github.com/RobustaStudio/payfort-start-php/releases/latest and copy it to your project., (*7)

Inside your php file add this:, (*8)


Note for Windows: Before you start development with start-php, please check that your php_curl can work with our ssl certificate (TLSv1.2). You can do this by running unit tests. If you see "SSL connection error" it means that you need to install a new php version (at least 5.5.19)., (*9)

Note: If you're running on a shared host, then you may need to set the allow_url_fopen flag for the php commands. For the install command, for example, this would look like php -d allow_url_fopen=On composer.phar install. The -d overrides the php.ini settings, where allow_url_fopen is usually set to Off., (*10)

Using Start

You'll need an account with Start if you don't already have one (grab one real quick at start.payfort.com and come right back .. we'll wait)., (*11)

Got an account? Great .. let's do this., (*12)

1. Initializing Start

To get started, you'll need to initialize Start with your secret API key. Here's how that looks (fear not .. we're using a test key, so no real money will be exchanging hands):, (*13)

require_once('vendor/autoload.php'); # At the top of your PHP file

# Initialize Start object
Start::setApiKey('test_sec_k_25dd497d7e657bb761ad6');

That's it! You probably want to do something with the Start object though -- it gets really bored when it doesn't have anything to do., (*14)

Let's run a transaction, shall we., (*15)

2. Processing a transaction through Start

Now, for the fun part. Here's all the code you need to process a transaction with Start:, (*16)

Start_Charge::create(array(
  "amount" => 10500, // AED 105.00
  "currency" => "aed",
  "card" => array(
    "number" => "4242424242424242",
    "exp_month" => 11,
    "exp_year" => 2016,
    "cvc" => "123"
  ),
  "description" => "Charge for test@example.com"
));

This transaction should be successful since we used the 4242 4242 4242 4242 test credit card. For a complete list of test cards, and their expected output you can check out this link here., (*17)

How can you tell that it was successful? Well, if no exception is raised then you're in the clear., (*18)

3. Handling Errors

Any errors that may occur during a transaction is raised as an Exception. Here's an example of how you can handle errors with Start:, (*19)

try {
  // Use Start's bindings...
} catch(Start_Error_Banking $e) {
  // Since it's a decline, Start_Error_Banking will be caught
  print('Status is:' . $e->getHttpStatus() . "\n");
  print('Code is:' . $e->getErrorCode() . "\n");
  print('Message is:' . $e->getMessage() . "\n");

} catch (Start_Error_Request $e) {
  // Invalid parameters were supplied to Start's API

} catch (Start_Error_Authentication $e) {
  // There's a problem with that API key you provided

} catch (Start_Error $e) {
  // Display a very generic error to the user, and maybe send
  // yourself an email

} catch (Exception $e) {
  // Something else happened, completely unrelated to Start

}

Testing Start

It's probably a good idea to run the unit tests to make sure that everything is fine and dandy. That's also simple.. just run this command from the root of your project folder:, (*20)

php vendor/bin/phpunit tests --bootstrap vendor/autoload.php

Note: you'll need to pull the development dependencies as well, using composer update --dev in order to run the test suites., (*21)

Contributing

Read our Contributing Guidelines for details, (*22)

Copyright (c) Payfort., (*23)

The Versions

07/03 2018

dev-master

9999999-dev

Payfort Start makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

payments payfort online payments middle east

07/03 2018

v1.0

1.0.0.0

Payfort Start makes accepting online payments in the Middle East a piece of cake

  Sources   Download

The Development Requires

payments payfort online payments middle east