Skip to content

massimo-me/satispay-php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SensioLabsInsight Build Status

Satispay PHP SDK

  • Check Bearer
  • Users
  • Charges
  • Amounts
  • Refunds

Install

Download composer

$ composer require chiarillomassimo/satispay-php-sdk

API: Init

use ChiarilloMassimo\Satispay\Authorization\Bearer;
use ChiarilloMassimo\Satispay\Satispay;

$satispay = new Satispay(
    new Bearer('osh_...'),
    'sandbox'
);

API: Check Bearer

Check Authorization

if ($satispay->getBearerHandler()->isAuthorized()) {
 ....
};

API: Users

Creation

$satispay->getUserHandler()->createByPhoneNumber('+39 yourphone')

$user = new User(null, '+39 yourphone');
$satispay->getUserHandler()->persist($user)

Get

$satispay->getUserHandler()->findOneById('id')

Find

$satispay->getUserHandler()->find()
$satispay->getUserHandler()->find(50, 'starting_id', 'ending_id')

$users = $satispay->getUserHandler()->find();

foreach ($users as $user) {
    //...
}

API: Charge

Create

use ChiarilloMassimo\Satispay\Model\Charge;

$charge = new Charge();

$user = $satispay->getUserHandler()->createByPhoneNumber('+39 yourphone');

$charge
    ->setUser($user)
    ->setAmount(15) // 0.15 €
    ->setCallbackUrl('http://fakeurl.com/satispay-callback')
    ->setCurrency('EUR')
    ->setDescription('Test description')
    ->setExpireMinutes(20)
    ->setExtraFields([
        'orderId' => 'id',
        'extra' => 'extra'
    ])
    ->setSendMail(false);
    
$satispay->getChargeHandler()->persist($charge, true);

$charge->isPaid(); //false
$charge->getStatus(); //Charge::STATUS_REQUIRED

Get

$satispay->getChargeHandler()->findOneById('charge_id')

Update

$charge = $satispay->getChargeHandler()->findOneById('charge_id')
$charge->setDescription('My fantastic description!!')

$satispay->getChargeHandler()->update($charge)

Find

$satispay->getChargeHandler()->find()
$satispay->getChargeHandler()->find(50, 'starting_id', 'ending_id')

$charges = $satispay->getChargeHandler()->find();

foreach ($charges as $charge) {
    //...
}

API: Refund

Creation

use \ChiarilloMassimo\Satispay\Model\Refund;

$charge = $satispay->getChargeHandler()->findOneById('id');

$refund = new Refund();
$refund
    ->setCharge($charge)
    ->setDescription('Test')
    ->setAmount(15)
    ->setReason(Refund::DUPLICATE);

$satispay->getRefundHandler()->persist($refund);

Get

$satispay->getRefundHandler()->findOneById('id'));

Update

$refund = $satispay->getRefundHandler()->findOneById('id');
$refund->setDescription('My fantastic description!!');

$satispay->getRefundHandler()->update($refund);

Find

$satispay->getRefundHandler()->find()
$satispay->getRefundHandler()->find(50, 'starting_id', 'ending_id')

$refunds = $satispay->getRefundHandler()->find();

foreach ($refunds as $refund) {
    //...
}

API: Amounts

Get

$amount = $satispay->getAmountHandler()->findBy(
    new DateTime('2018-01-01'),
    new DateTime('now')
);