PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Payment » Payment_Process » Bug #1265

Add handler support to typeFieldMap

Details

Request #1265Add handler support to typeFieldMap
Submitted2004-04-23 04:33 UTC
Fromaashley at optimiser dot com
StatusClosed
PackagePayment_Process
PHP Version5.0.0RC1 (Release Candidate 1)
OSAll
Roadmaps(Not assigned)

Comments

[2004-04-23 04:33 UTC] aashley at optimiser dot com

Description:
------------
Added handler support to setPayment. The processor I'm building requires the expiry month and year as seperate fields, so I've added the handler code from _process to setPayment() in Common.php

patch:

--- /usr/share/pear/Payment/Process/Common.php 2004-04-13 15:45:48.000000000 +0800
+++ Common.php 2004-04-21 22:37:25.000000000 +0800
@@ -229,10 +229,25 @@
// Map over the payment specific fiels. Check out
// $_typeFieldMap for more information.
$paymentType = $payment->getType();
- foreach ($this->_typeFieldMap[$paymentType] as $key => $val) {
- if(!isset($this->_data[$val])) {
- $this->_data[$val] = $this->_payment->$key;
+ foreach ($this->_typeFieldMap[$paymentType] as $generic => $specific) {
+ $func = '_handle'.ucfirst($generic);
+ if (method_exists($this, $func)) {
+ //$this->debug("Calling {$func} to handle {$generic}");
+ $result = $this->$func();
+ if (PEAR::isError($result)) {
+ return $result;
+ }
+ } else {
+ // TODO This may screw things up - the problem is that
+ // CC information is no longer member variables, so we
+ // can't overwrite it. You could always handle this with
+ // a _handle funciton. I don't think it will cause problems,
+ // but it could.
+ if (!isset($this->_data[$specific])) {
+ $this->_data[$specific] = $this->_payment->$generic;
+ }
}
+
}

return true;

[2004-04-30 07:54 UTC] aashley at optimiser dot com

here's the patch again, if this doesnt work give us a yell and ill send it via email.

--- Common.orig.php 2004-04-30 16:02:08.905151105 +0800
+++ Common.php 2004-04-21 22:37:25.000000000 +0800
@@ -229,10 +229,25 @@
// Map over the payment specific fiels. Check out
// $_typeFieldMap for more information.
$paymentType = $payment->getType();
- foreach ($this->_typeFieldMap[$paymentType] as $key => $val) {
- if(!isset($this->_data[$val])) {
- $this->_data[$val] = $this->_payment->$key;
+ foreach ($this->_typeFieldMap[$paymentType] as $generic => $specific) {
+ $func = '_handle'.ucfirst($generic);
+ if (method_exists($this, $func)) {
+ //$this->debug("Calling {$func} to handle {$generic}");
+ $result = $this->$func();
+ if (PEAR::isError($result)) {
+ return $result;
+ }
+ } else {
+ // TODO This may screw things up - the problem is that
+ // CC information is no longer member variables, so we
+ // can't overwrite it. You could always handle this with
+ // a _handle funciton. I don't think it will cause problems,
+ // but it could.
+ if (!isset($this->_data[$specific])) {
+ $this->_data[$specific] = $this->_payment->$generic;
+ }
}
+
}

return true;

[2004-04-30 15:47 UTC] joe at joestump dot net

It's still borking - could you email me the patch?

[2004-06-18 05:09 UTC] aashley at optimiser dot com

I've updated the patch for so it works with Payment Process 0.5.7

Its available at http://frood.cernun.net/stuff/Common.php-handle-support-typeFieldMap.patch

I've also made changes to the patch so that in setPayment() the payment object is passed in by reference and linked to the current object by reference, no copying.

[2004-06-21 21:59 UTC] daviidu at everydns dot net

Can you clarify what (why) you are doing this in your patch:

+ if(isset($this->_payment->$generic))
+ {
+ $this->_data[$specific] = $this->_payment->$generic;
+ }

What's the order that things should happen with what I pasted above and what is just above that in your patch?

-davidu

[2004-06-22 00:59 UTC] aashley at optimiser dot com

why i was doing? something to do with writing code at 3am :), ive updated the patch with the intended behaviour