iodigital / peachpayment
A library to help integrate Peach Payments
Installs: 3 220
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 1
Open Issues: 10
Requires
- guzzlehttp/guzzle: ^6.5
- illuminate/support: ~5|~6|~7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- mockery/mockery: ^1.1
- orchestra/testbench: ~3|~4
- php-vcr/php-vcr: ^1.4
- phpmd/phpmd: @stable
- phpunit/phpunit: ^8.0
- sempro/phpunit-pretty-print: ^1.0
- squizlabs/php_codesniffer: 3.*
- dev-master
- 1.0.0
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-dependabot/composer/guzzlehttp/psr7-1.9.1
- dev-dependabot/composer/symfony/http-kernel-4.4.50
- dev-dependabot/composer/guzzlehttp/guzzle-7.4.5
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/composer/league/flysystem-1.1.4
- dev-dependabot/npm_and_yarn/glob-parent-5.1.2
- dev-dependabot/npm_and_yarn/hosted-git-info-2.8.9
- dev-dependabot/composer/laravel/framework-6.20.26
- dev-tweaks-and-fixes
- dev-cleanup
- dev-feature.send-unique-transaction-id
- dev-fix-route-registration
- dev-syntax-fixes
- dev-webhook-events
- dev-handle-webhooks
This package is auto-updated.
Last update: 2024-11-19 23:30:58 UTC
README
This is a work in progress.
Installation
Via Composer
$ composer require iodigital/peachpayment
This package uses auto discovery but can be added to your config/app.php
providers
by adding \IoDigital\PeachPayment\PeachPaymentServiceProvider::class,
You can publish the assets with the following:
php artisan vendor:publish --tag=peachpayment-config
php artisan vendor:publish --tag=peachpayment-migrations
Config file
The configuration file provides you with the ability of adding your production and test Peach Payment credentials. The package does a check against your app environment.
The variables that can be used are:
PEACH_PAYMENTS_USER_ID
PEACH_PAYMENTS_PASSWORD
PEACH_PAYMENTS_AUTHORIZATION_HEADER
PEACH_PAYMENTS_ENTITY_ID_ONCE_OFF
PEACH_PAYMENTS_ENTITY_ID_RECURRING
PEACH_PAYMENTS_TEST_MODE
PEACH_PAYMENTS_NOTIFICATION_URL
PEACH_PAYMENTS_WEBHOOK_SECRET_KEY
Migrations
payment_cards
This table can be used in conjunction with Server to Server functionality.
payment_results
This table can be used to store the results of transactions.
payment_events
This table can be used to store the event data received from webhooks.
Usage
This package provides the ability of using Server to Server and COPYandPay. Fairly simple to get either one going:
$client = (new PeachPayment())->initServerToServer(); // or $client = (new PeachPayment())->initCopyAndPay();
As explained further below, you can also override your Peach Payment credentials on the fly:
$client = (new PeachPayment())->initServerToServer($settings);
Where $settings
is a fluent class.
Methods available to Server to Server:
registerCard(CardBuilder $card); registerCardDuringPayment(CardBuilder $card); repeatedPayment(PaymentCard $card, $owner, int $amount, string $type = PaymentScheme::REPEATED_PAYMENT); oneClickPayment(PaymentCard $card, int $amount); paymentStatus(string $paymentId); deleteCard(string $registrationId); // Available options for $type in repeatedPayment() PaymentScheme::INITIAL_PAYMENT; PaymentScheme::REPEATED_PAYMENT;
Methods available to COPYandPAY:
prepareCheckout(int $amount); getCheckoutRegistrationResult($checkoutId); registerCard(); registerCardDuringPayment(int $amount); repeatedPayment(PaymentCard $card, $owner, int $amount, string $type = PaymentScheme::REPEATED_PAYMENT); paymentStatus(string $checkoutId);
To determine the result of a transaction with Peach Payment, you can use the Response class:
$response = new \IoDigital\PeachPayment\Api\Response(); $response->isSuccessfulResponse($resultCode); // true|false $response->isValidationError($resultCode); // true|false
Saving the response is also available:
$response->save($result, $paymentCard);
Webhooks
The following change needs to be made in your app/Http/Middleware/VerifyCsrfToken.php
file:
protected $except = [ config('peachpayment.webhook_url') ];
Helpers
Setting.php
This class allows you to inject or modify your Peach Payment credentials on a per usage basis. By default, it uses the variables given in the config file and you only have to override the variables needed.
Usage is fairly straightforward:
$settings = new Setting(); $settings->setUser('lorem') ->setPassword('ipsum') ->setEntityIdOnceOff('dolor'); $pay = (PeachPayment())->initServerToServer($settings);
This should provide flexibility in certain edge cases.
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
- [author name][link-author]
- [All Contributors][link-contributors]
License
license. Please see the license file for more information.