2017 © Pedro Peláez
 

library cards-sdk

Experimental

image

paystack/cards-sdk

Experimental

  • Tuesday, May 9, 2017
  • by ibrahimlawal
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

paystack-cards-sdk

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

A PHP library for charging cards on Paystack., (*2)

Paystack, (*3)

Requirements

  • Curl 7.34.0
  • PHP 5.4.0 or more recent
  • OpenSSL v1.0.1 or more recent

Install

Via Composer

``` bash $ composer require paystack/cards-sdk, (*4)


## Usage ### Step 1: Initialize a Paystack transaction When a transaction is initialized via our api, we provide an `access_code`. You should keep track of This throughout the lifetime of your transaction as it is required for every call below. ### Step 2: Fetch a paystack device id Using PaystackJS, save the device's id and send when making a chargeCard request. ### Step 3: Create a function that initiates a `Paystack\Cards` object This function would be reused everytime you want to send us `card details`, `pin`, `phone` or `token`.
function paystackCards(){
    return new PaystackCards(
        PAYSTACK_SECRET,
        function ($transaction) {
            respond(['status'=>'success','data'=>['reference'=>$transaction->data->reference]]);
        },
        function ($message) {
            respond(['status'=>'failed','message'=>$message]);
        },
        function ($message) {
            respond(['status'=>'authpin','message'=>$message]);
        },
        function ($message) {
            respond(['status'=>'authotp','message'=>$message]);
        },
        function ($message) {
            respond(['status'=>'authphone','message'=>$message]);
        },
        function ($message) {
            respond(['status'=>'timeout','message'=>$message]);
        },
        function ($url) {
            respond(['status'=>'auth3DS','url'=>$url]);
        }
    );
}

### Step 4: Build card details Use our `Paystack\Cards\CardBuilder` class to create a card object to charge.
$cardbuilder = new Paystack\Cards\CardBuilder();
$card = $cardbuilder
    ->withPan(filter_input(INPUT_POST, 'pan'))
    ->withCvc(filter_input(INPUT_POST, 'cvc'))
    ->withExpiryMonth(filter_input(INPUT_POST, 'exp_month'))
    ->withExpiryYear(filter_input(INPUT_POST, 'exp_year'))
    ->build();

### Step 5: Send card details (and a `pin` when requested)
$paystackCards->chargeCard(
    $access_code,
    $device,
    $card,
    $pin);

### Step 6: Send otp when requested
$paystackCards->validateOtp(
    $access_code,
    $otp);

### Step 7: Send phone when requested
$paystackCards->validatePhone(
    $access_code,
    $phone);


## Change log Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. ## Testing ``` bash $ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details. Check our todo list for features already intended., (*5)

Security

If you discover any security related issues, please email paystack.valley@gmail.com instead of using the issue tracker., (*6)

Credits

License

The MIT License (MIT). Please see License File for more information., (*7)

The Versions