2017 © Pedro Peláez
 

library payjp

a simple wrapper for Pay.JP payments

image

asaokamei/payjp

a simple wrapper for Pay.JP payments

  • Monday, May 9, 2016
  • by asaokamei
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

PayJp

a simple wrapper classes for Pay.JP and WebPay payment services., (*1)

!!!NOT FULLY TESTED nor USED!!!, (*2)

License

MIT License, (*3)

PSR

PSR-1, PSR-2, and PSR-4., (*4)

install

composer require "asaokamei/payjp"

to see a demo, try, (*5)

cd payjp
composer install
cd demo
php -S localhost:8888

and browse http://localhost:8888/., (*6)

Getting Started

Get public and secret api keys from Pay.jp or WebPay.jp., (*7)

define('PAY_JP_SECRET_KEY', 'sk_test_*****'); // your secret key.

Then, create a factory for charges, as, (*8)

// for Pay.jp
$factory = AsaoKamei\PayJp\PayJp\ChargeFactory::forge(PAY_JP_SECRET_KEY); 

// for WebPay.jp
$factory = AsaoKamei\PayJp\WebPay\ChargeFactory::forge(PAY_JP_SECRET_KEY); 

charge to a credit card

get a credit token ($_POST['payjp-token'] for pay.jp or $_POST['webpay-token'] for WebPay.jp)., (*9)

$charge  = $factory->create($_POST['service-token']);

if (!$charge_id = $charge->charge(1000)) {
    var_dump($charge->getError());
}

You can authorize the credit, by,, (*10)

$charge_id = $charge->authorize(1000);

and save the $charge_id for later use., (*11)

capture, cancel, or refund

$charge = $factory->retrieve($charge_id);

then, do one of the following., (*12)

$charge->capture();
$charge->cancel();
$charge->refund(500);

You can only refund once for pay.jp., (*13)

Testing

To run the test, please obtain api keys for test from Pay.jp and WebPay., (*14)

Set the secret and public api keys to tests/services.ini accordingly., (*15)

Then, run phpunit using tests/phpunit.xml configuration., (*16)

Notice

  • refund is not working for pay.jp.

The Versions

09/05 2016

dev-master

9999999-dev

a simple wrapper for Pay.JP payments

  Sources   Download

MIT

The Development Requires

by Asao

09/05 2016

0.0.2

0.0.2.0

a simple wrapper for Pay.JP payments

  Sources   Download

MIT

The Development Requires

by Asao

08/05 2016

0.0.1

0.0.1.0

a simple wrapper for Pay.JP payments

  Sources   Download

MIT

The Development Requires

by Asao

08/05 2016

dev-webpay

dev-webpay

a simple wrapper for Pay.JP payments

  Sources   Download

MIT

The Development Requires

by Asao