https://github.com/brandcom/cakephp-paypal
https://github.com/brandcom/cakephp-paypal
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/brandcom/cakephp-paypal
- Owner: brandcom
- Created: 2021-05-10T07:13:44.000Z (about 5 years ago)
- Default Branch: 4.x
- Last Pushed: 2023-02-22T20:02:28.000Z (over 3 years ago)
- Last Synced: 2025-02-20T05:47:16.708Z (over 1 year ago)
- Language: PHP
- Size: 27.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# PayPal Plugin for Cakephp 4.x
## Installation and Usage
Install the Plugin
```
composer require jbennecker/cakephp-paypal
```
Load the Plugin
```
$ bin/cake plugin load PayPal
```
Run Plugin Migrations
```
$ bin/cake migrations migrate -p PayPal
```
Add a file called `app_paypal.php` to your config folder and enter the following info
```
[
'currency' => 'EUR',
],
];
```
The Plugin expects that you have a table called orders and the corresponding entity and table classes. The Order Entity
class must implement the PayPal OrderInterface
```
use PayPal\Model\Entity\OrderInterface;
class Order extends Entity implements OrderInterface
{}
```
And OrdersTable must implement \PayPal\Model\TableOrdersTableInterface
```
use PayPal\Model\TableOrdersTableInterface;
class OrdersTable extends Table implements OrdersTableInterface
{}
```
After you have saved an order you can redirect the user to PayPal using this:
```
return $this->redirect([
'plugin' => 'PayPal',
'controller' => 'Paypals',
'action' => 'pay',
$order->id,
]);
```
This will redirect your customer to PayPal. After the customer has successfully paid, he will be redirected to
```
Router::url(['controller' => 'Orders', 'action' => 'confirm'], true);
```
PayPal will send an IPN to the Plugin. If the IPN successfully
validated, the Plugin calls an Callbackmethod on your OrdersTable class.
PayPal will send an IPN to the Plugin. If the IPN was successfully
validated, the Plugin calls the afterPayment-Callback on your Table-Class.
This Plugin uses [PayPal Payments Standard](https://developer.paypal.com/api/nvp-soap/paypal-payments-standard/gs-PayPalPaymentsStandard/)
See [PayPal sandbox testing guide](https://developer.paypal.com/tools/sandbox/) for using Sandbox testing accounts.
```
public function afterPayment(Order $order): void
{
// Further process the order
}
```