1. Go to this page and download the library: Download payjp/payjpv2-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
payjp / payjpv2-php example snippets
onfigure Bearer authorization with API key
$config = PAYJPV2\Configuration::getDefaultConfiguration()
->setAccessToken(getenv('PAYJP_API_KEY'));
$customersApi = new PAYJPV2\Api\CustomersApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
try {
// Create a customer
$createRequest = new \PAYJPV2\Model\CustomerCreateRequest();
$createRequest->setEmail('[email protected]');
$createRequest->setDescription('Test customer');
$customer = $customersApi->createCustomer($createRequest);
echo "Created customer: " . $customer->getId() . "\n";
// List customers
$customerList = $customersApi->getAllCustomers(limit: 10);
foreach ($customerList->getData() as $c) {
echo " - " . $c->getId() . " (" . ($c->getEmail() ?? 'no email') . ")\n";
}
} catch (Exception $e) {
echo 'Exception when calling CustomersApi: ', $e->getMessage(), PHP_EOL;
}