asaokamei / payjp
a simple wrapper for Pay.JP payments
Installs: 24
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/asaokamei/payjp
Requires (Dev)
- payjp/payjp-php: 0.0.x
- webpay/webpay: ~2.2
This package is auto-updated.
Last update: 2025-10-28 19:52:53 UTC
README
a simple wrapper classes for Pay.JP and WebPay payment services.
!!!NOT FULLY TESTED nor USED!!!
License
MIT License
PSR
PSR-1, PSR-2, and PSR-4.
install
composer require "asaokamei/payjp"
to see a demo, try
cd payjp composer install cd demo php -S localhost:8888
and browse http://localhost:8888/.
Getting Started
Get public and secret api keys from Pay.jp or WebPay.jp.
define('PAY_JP_SECRET_KEY', 'sk_test_*****'); // your secret key.
Then, create a factory for charges, as
// 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).
$charge = $factory->create($_POST['service-token']); if (!$charge_id = $charge->charge(1000)) { var_dump($charge->getError()); }
You can authorize the credit, by,
$charge_id = $charge->authorize(1000);
and save the $charge_id for later use.
capture, cancel, or refund
$charge = $factory->retrieve($charge_id);
then, do one of the following.
$charge->capture(); $charge->cancel(); $charge->refund(500);
You can only refund once for pay.jp.
Testing
To run the test, please obtain api keys for test from Pay.jp and WebPay.
Set the secret and public api keys to tests/services.ini accordingly.
Then, run phpunit using tests/phpunit.xml configuration.
Notice
- refundis not working for pay.jp.