The Smartpay PHP library offers easy access to Smartpay API from applications written in PHP.
- PHP 5.6+
- Smartpay
API keys & secrets
. You can find your credential at thesettings > credentials
page on your dashboard.
Composer is a dependency manager for PHP projects.
Download Composer from their website: https://getcomposer.org/download/
If you are using macos to develop with homebrew, you can use the command to install Composer:
brew install composer
composer install smartpay-co/sdk-php
The package needs to be configured with your own API keys, you can find them on your dashboard.
$api = new \Smartpay\Api('<YOUR_SECRET_KEY>', '<YOUR_PUBLIC_KEY>')
You can find the description and requirement for request payload in API Document.
$payload = [
'items' => [
[
'name' => 'オリジナルス STAN SMITH',
'amount' => 1000,
'currency' => 'JPY',
'quantity' => 1,
],
[
'currency' => 'JPY',
'amount' => 500,
'name' => 'Merchant special discount',
'kind' => 'discount'
],
[
'currency' => 'JPY',
'amount' => 100,
'name' => 'explicit taxes',
'kind' => 'tax'
]
],
'customerInfo' => [
'accountAge' => 20,
'email' => 'merchant-support@smartpay.co',
'firstName' => '田中',
'lastName' => '太郎',
'firstNameKana' => 'たなか',
'lastNameKana' => 'たろう',
'address' => [
'line1' => '北青山 3-6-7',
'line2' => '青山パラシオタワー 11階',
'subLocality' => '',
'locality' => '港区',
'administrativeArea' => '東京都',
'postalCode' => '107-0061',
'country' => 'JP',
],
'dateOfBirth' => '1985-06-30',
'gender' => 'male',
],
'shippingInfo' => [
'line1' => '北青山 3-6-7',
'line2' => '青山パラシオタワー 11階',
'subLocality' => '',
'locality' => '港区',
'administrativeArea' => '東京都',
'postalCode' => '107-0061',
'country' => 'JP',
],
'reference' => 'order_ref_1234567',
'successUrl' => 'https://docs.smartpay.co/example-pages/checkout-successful',
'cancelUrl' => 'https://docs.smartpay.co/example-pages/checkout-canceled'
];
Create a checkout session by using checkoutSession
method with your request payload.
$session = $api->checkoutSession($payload);
Then, you can redirect your customer to the session url by calling redirectUrl
method:
$session->redirectUrl()
Install dependencies
composer i
Run test in the folder
./vendor/bin/phpunit tests
The package is available as open source under the terms of the MIT License.