This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//buyable has one or many payments | |
//should this be absolutely required? | |
$buyable; | |
//creating a new payment | |
//this will inject the appropriate gateway automatically, if one exists | |
$payment = new PaypalPayment(); //or | |
$payment = Payment::create('PaypalPayment'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// | |
$payment->returnTo($controller,$action,$id); | |
$payment->process(); | |
class PaymentGatewayController extends Controller{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* goal: build SQL filter, based on parameter array | |
*/ | |
//a hypothetical filter(parameters) for a new order item. | |
//This data would typically come from request parameters. | |
$filter = array( | |
'Size' => 20, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Helper class to create a filter for matching a dataobject, | |
* using field values or relationship ids and only those ids. | |
* | |
* Combining fields defines a way to uniquely identify an object. | |
* | |
* Useful for finding if a dataobject with given field values exists. | |
* Protects against SQL injection, and searching on unauthroised fields. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Weight extends Decimal{ | |
function Nice(){ | |
//return in format appropriate to value eg 2grams instead of 0.002kg | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RunningTotalExtension extends Extension{ | |
private static $runningtotal = 0; | |
function RunningTotal(){ | |
return self::$runningtotal ++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Payment extends DataObject{ | |
} | |
interface PaymentProcessor{ | |
function setup(); //prepare for | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Catch gateway-triggered requests | |
*/ | |
class PaymentController extends Controller{ | |
function init(){ | |
$this->processor = $this->getProcessorForPayment(); //somehow get the right processor to continue handling | |
//Perhaps the processor class is sent in the url, eg: mysite/paymentcontrol/PayPal/?extradata=.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyController extends Controller{ | |
static $url_segment = 'mycontroller'; | |
function Link($action = ""){ | |
return Controller::join_links(self::$url_segment,$action); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name: dummypayment | |
--- | |
Director: | |
rules: | |
'dummy/external/$Action/$ID': 'DummyExternalGateway_Controller' | |
'payment/$MethodName/$Action/$ID': 'Payment_Controller_GatewayHosted' | |
# first idea (tied to gateway): |
OlderNewer