Skip to content

Commit

Permalink
Lots of work on the behavior and datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Sofer committed Nov 19, 2010
1 parent e62cab1 commit 794ae2b
Show file tree
Hide file tree
Showing 22 changed files with 457 additions and 503 deletions.
78 changes: 34 additions & 44 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,8 @@ This is an attempt to become the defacto solution for shopping cart
implementation in CakePHP. Not to say this in of itself will be the
best shopping cart around, but in fact give developers the resource
to build their own custom shopping cart Application to their own
specifications.
specifications, allowing you to extrapolate from that point forwards.

Hopefully future versions of the brother development app, 'Mocha'
will use future releases of this plugin as a part of it's core. For
now this is a 1-stop plugin that provides you all the resources you
need to build a cart and nothing more, allowing you to extrapolate
from that point forwards.

"Title: ShoppingCart plugin for CakePHP
Authors: Dean Sofer (ProLoser), Jesse Adams (techno-geek)

CakePHP plugin that handles the management of order data in the session. Useful for shopping cart CakePHP applications. Will be used in the Mocha Shopping Cart project brought to you by DualTech Services, inc."

Structure:

Components:
- Cart Session
- Helps track orders for standard carts
- Convenience only, not required
- Instant Payment Notification
- Processes ipn for multiple gateways
- Takes $gateway as an argument
- Relies on the PaymentGatewayBehavior at the model level

Behavior:
- PaymentGateway
- Binds different gateway datasources to the model for IPN and order processing
- Relies on the PaymentGatewayDatasource

Datasource:
- PaymentGateway
- Works as a wrapper for individual payment gateway datasources
- Standardizes the methods and data used for individual datasources
- Stores configurations of different payment gateways

Installation:

Expand All @@ -46,23 +14,24 @@ Installation:
<pre>
var $paypal = array(
'datasource' => 'Cart.PaymentGateway',
'driver' => 'Paypal',
'driver' => 'Cart.Paypal',
'login' => 'standard_username',
'password' => 'password',
);
var $paypalDonations = array(
'datasource' => 'Cart.PaymentGateway',
'driver' => 'Paypal',
'driver' => 'Cart.Paypal',
'login' => 'donations_username',
'password' => 'password',
);
var $google = array(
'datasource' => 'Cart.PaymentGateway',
'driver' => 'GoogleCheckout',
'driver' => 'Cart.GoogleCheckout',
'login' => 'username',
'password' => 'password',
);
</pre>

2. Bind the PaymentGateway behavior (currently the model doesn't matter)
<pre>
Class Order extends AppModel {
Expand All @@ -72,15 +41,36 @@ Class Order extends AppModel {
),
);
}
</pre
</pre>

Components:
- Cart Session
- Helps track orders for standard carts
- Convenience only, not required
- Instant Payment Notification
- Processes ipn for multiple gateways
- Takes $gateway as an argument
- Relies on the PaymentGatewayBehavior at the model level

Behavior:
- PaymentGateway
- Binds different gateway datasources to the model for IPN and order processing
- Relies on the PaymentGatewayDatasource

Datasource:
- PaymentGateway
- Works as a wrapper for individual payment gateway datasources
- Standardizes the methods and data used for individual datasources
- Stores configurations of different payment gateways

Pending Features:
Expected Features:
- Shopping cart session component
- Shopping cart session helper
- Shipping / Tax handling (feature RFC)
- Optional base table for standard products
- Payment gateway behavior
- Payment gateway api datasources (such as Google checkout and
Paypal) that will work through the payment gateway behavior
- Administration tools, such as mass product uploading/editing
- Integration with CSV component for custom importing/exporting
- Payment Gateway Behavior
- Optional Scaffolding: (for those who only need basic functionality)
- ??? Products MVC
- Orders MVC
- OrderLineItems MVC
- Payments (With IPN)
- ??? PaymentLineItems MVC
6 changes: 1 addition & 5 deletions cart_app_controller.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<?php

class CartAppController extends AppController {

}

?>
}
6 changes: 1 addition & 5 deletions cart_app_model.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<?php

class CartAppModel extends AppModel {

}

?>
}
44 changes: 11 additions & 33 deletions config/paypal.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php
/************
/**
* Use these settings to set defaults for the Paypal Helper class.
* The PaypalHelper class will help you create paynow, subscribe, donate, or addtocart buttons for you.
*
* All these options can be set on the fly as well within the helper
*/

class PaypalConfig {

/************
* Each settings key coresponds to the Paypal API. Review www.paypal.com for more.
*/
/**
* Each settings key coresponds to the Paypal API. Review www.paypal.com for more.
*/
var $settings = array(
// Server URL for cart submission
'server' => 'https://www.paypal.com/cgi-bin/webscr',
// cart field => cart-value-slot or value-default
'transaction' => 'txn_id',
'status' => 'payment_status',
'currency_code' => 'USD',
'address' => '',
'item_name' => 'ISV Payment',
Expand All @@ -41,35 +42,12 @@ class PaypalConfig {
'return',
);

/***********
* Test settings to test with using a sandbox paypal account.
*/
/**
* Test settings to test with using a sandbox paypal account.
* Is merged with normal settings above upon use
*/
var $testSettings = array(
// Server URL for cart submission
'server' => 'https://www.sandbox.paypal.com/cgi-bin/webscr',
'currency_code' => 'USD',
'address' => '',
'item_name' => 'ISV Payment',
'invoice' => 'invoice',
'notify_url' => 'notify_url',
'complete' => '/',
'amount' => 'amount',
'address1' => 'address1',
'address2' => 'address2',
'city' => 'city',
'country' => 'country',
'email' => 'email',
'first_name' => 'first_name',
'last_name' => 'last_name',
'night_phone_a' => 'phone1',
'night_phone_b' => 'phone2',
'state' => 'state',
'zip' => 'zip',
'on{n}' => 'option{n}label',
'os{n}' => 'option{n}value',
'cmd' => '_xclick',
'no_note',
'business' => 'username',
'return',
);

}
107 changes: 107 additions & 0 deletions controllers/cart_payments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php
/**
* CartPaymentsController
*
* [Short Description]
*
* @package Cart Plugin
* @author Dean
* @version $Id$
* @copyright
**/

class CartPaymentsController extends AppController {
var $name = 'CartPayments';

var $helpers = array('Html', 'Form');
var $components = array('Session');

function ipn($type = null) {
$this->CartPayment->processIpn($_POST, $type);
}

/**
* Index action
*
* @access public
*/
function index() {
$this->Payment->recursive = 0;
$this->set('cartPayments', $this->paginate());
}

/**
* View action
*
* @access public
* @param integer $id ID of record
*/
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Payment', true));
$this->redirect(array('action' => 'index'));
}
$this->set('payment', $this->Payment->read(null, ));
}

/**
* Add action
*
* @access public
*/
function add() {
if (!empty(->data)) {
$this->Payment->create();
if ($this->Payment->save($this->data)) {
$this->Session->setFlash(__('The Payment has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The Payment could not be saved. Please, try again.', true));
}
}
}

/**
* Edit action
*
* @access public
* @param integer $id ID of record
*/
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Payment', true));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->Payment->save($this->data)) {
$this->Session->setFlash(__('The Payment has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The Payment could not be saved. Please, try again.', true));
}
}
if (empty(->data)) {
$this->data = ->Payment->read(null, $id);
}
}

/**
* Delete action
*
* @access public
* @param integer $id ID of record
*/
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for Payment', true));
$this->redirect(array('action'=>'index'));
}
if ($this->Payment->delete($id)) {
$this->Session->setFlash(__('Payment deleted', true));
$this->redirect(array('action'=>'index'));
}
$this->Session->setFlash(__('Payment was not deleted', true));
$this->redirect(array('action' => 'index'));
}
}
?>
Loading

0 comments on commit 794ae2b

Please sign in to comment.