Index: branches/fundraising/extensions/DonationInterface/gateway_common/donation.api.php |
— | — | @@ -9,28 +9,34 @@ |
10 | 10 | global $wgRequest, $wgParser; |
11 | 11 | |
12 | 12 | $params = $this->extractRequestParams(); |
| 13 | + $options = array(); |
13 | 14 | |
14 | 15 | $gateway = $params['gateway']; |
15 | 16 | |
16 | 17 | // If you want to test with fake data, pass a 'test' param set to true. |
17 | 18 | // You still have to set the gateway you are testing though. |
| 19 | + // It looks like this only works if the Test global variable for that gateway is true. |
18 | 20 | if ( array_key_exists( 'test', $params ) && $params['test'] ) { |
19 | 21 | $params = $this->getTestData( $gateway ); |
| 22 | + $options['testData'] = $params; |
20 | 23 | } |
21 | 24 | |
22 | 25 | $method = $params['payment_method']; |
23 | 26 | |
24 | 27 | if ( $gateway == 'payflowpro' ) { |
25 | | - $gatewayObj = new PayflowProAdapter(); |
| 28 | + $gatewayObj = new PayflowProAdapter( $options ); |
26 | 29 | switch ( $method ) { |
27 | 30 | // TODO: add other payment methods |
28 | 31 | default: |
29 | 32 | $result = $gatewayObj->do_transaction( 'Card' ); |
30 | 33 | } |
31 | 34 | } else if ( $gateway == 'globalcollect' ) { |
32 | | - $gatewayObj = new GlobalCollectAdapter(); |
| 35 | + $gatewayObj = new GlobalCollectAdapter( $options ); |
33 | 36 | switch ( $method ) { |
34 | 37 | // TODO: add other payment methods |
| 38 | + case 'card': |
| 39 | + $result = $gatewayObj->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
| 40 | + break; |
35 | 41 | default: |
36 | 42 | $result = $gatewayObj->do_transaction( 'TEST_CONNECTION' ); |
37 | 43 | } |
— | — | @@ -39,38 +45,46 @@ |
40 | 46 | } |
41 | 47 | |
42 | 48 | //$normalizedData = $gatewayObj->getData(); |
| 49 | + $outputResult = array(); |
| 50 | + $outputResult['message'] = $result['message']; |
| 51 | + $outputResult['status'] = $result['status']; |
| 52 | + $outputResult['returnurl'] = $result['data']['PAYMENT']['RETURNURL']; |
| 53 | + $outputResult['errors'] = implode( '; ', $result['errors'] ); |
43 | 54 | |
44 | | - // Some output |
| 55 | + $this->getResult()->addValue( 'data', 'request', $params ); |
| 56 | + $this->getResult()->addValue( 'data', 'result', $outputResult ); |
| 57 | + |
| 58 | + /* |
45 | 59 | $this->getResult()->setIndexedTagName( $result, 'response' ); |
46 | | - $this->getResult()->addValue( 'data', 'request', $params ); |
47 | 60 | $this->getResult()->addValue( 'data', 'result', $result ); |
| 61 | + */ |
48 | 62 | } |
49 | 63 | |
50 | 64 | public function getAllowedParams() { |
51 | 65 | return array( |
52 | | - 'gateway' => $this->defineParam( 'gateway', true ), |
53 | | - 'test' => $this->defineParam( 'test', false ), |
54 | | - 'amount' => $this->defineParam( 'amount', false ), |
55 | | - 'currency' => $this->defineParam( 'currency', false ), |
56 | | - 'fname' => $this->defineParam( 'fname', false ), |
57 | | - 'mname' => $this->defineParam( 'mname', false ), |
58 | | - 'lname' => $this->defineParam( 'lname', false ), |
59 | | - 'street' => $this->defineParam( 'street', false ), |
60 | | - 'city' => $this->defineParam( 'city', false ), |
61 | | - 'state' => $this->defineParam( 'state', false ), |
62 | | - 'zip' => $this->defineParam( 'zip', false ), |
63 | | - 'email' => $this->defineParam( 'email', false ), |
64 | | - 'country' => $this->defineParam( 'country', false ), |
65 | | - 'card_num' => $this->defineParam( 'card_num', false ), |
66 | | - 'card_type' => $this->defineParam( 'card_type', false ), |
67 | | - 'expiration' => $this->defineParam( 'expiration', false ), |
68 | | - 'cvv' => $this->defineParam( 'cvv', false ), |
69 | | - 'payment_method' => $this->defineParam( 'payment_method', false ), |
70 | | - 'language' => $this->defineParam( 'language', false ), |
| 66 | + 'gateway' => $this->defineParam( true ), |
| 67 | + 'test' => $this->defineParam( false ), |
| 68 | + 'amount' => $this->defineParam( false ), |
| 69 | + 'currency' => $this->defineParam( false ), |
| 70 | + 'fname' => $this->defineParam( false ), |
| 71 | + 'mname' => $this->defineParam( false ), |
| 72 | + 'lname' => $this->defineParam( false ), |
| 73 | + 'street' => $this->defineParam( false ), |
| 74 | + 'city' => $this->defineParam( false ), |
| 75 | + 'state' => $this->defineParam( false ), |
| 76 | + 'zip' => $this->defineParam( false ), |
| 77 | + 'emailAdd' => $this->defineParam( false ), |
| 78 | + 'country' => $this->defineParam( false ), |
| 79 | + 'card_num' => $this->defineParam( false ), |
| 80 | + 'card_type' => $this->defineParam( false ), |
| 81 | + 'expiration' => $this->defineParam( false ), |
| 82 | + 'cvv' => $this->defineParam( false ), |
| 83 | + 'payment_method' => $this->defineParam( false ), |
| 84 | + 'language' => $this->defineParam( false ), |
71 | 85 | ); |
72 | 86 | } |
73 | 87 | |
74 | | - private function defineParam( $paramName, $required = false, $type = 'string' ) { |
| 88 | + private function defineParam( $required = false, $type = 'string' ) { |
75 | 89 | if ( $required ) { |
76 | 90 | $param = array( ApiBase::PARAM_TYPE => $type, ApiBase::PARAM_REQUIRED => true ); |
77 | 91 | } else { |
— | — | @@ -91,15 +105,19 @@ |
92 | 106 | 'city' => 'San Francisco', |
93 | 107 | 'state' => 'CA', |
94 | 108 | 'zip' => '94104', |
95 | | - 'email' => 'test@example.com', |
| 109 | + 'emailAdd' => 'test@example.com', |
96 | 110 | 'country' => 'US', |
97 | | - 'card_num' => '378282246310005', |
98 | | - 'card_type' => 'american', |
99 | | - 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
100 | | - 'cvv' => '001', |
101 | 111 | 'payment_method' => 'card', |
102 | 112 | 'language' => 'en', |
| 113 | + 'card_type' => '1', // Is this valid for PayflowPro? |
103 | 114 | ); |
| 115 | + if ( $gateway != 'globalcollect' ) { |
| 116 | + $params += array( |
| 117 | + 'card_num' => '378282246310005', |
| 118 | + 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
| 119 | + 'cvv' => '001', |
| 120 | + ); |
| 121 | + } |
104 | 122 | return $params; |
105 | 123 | } |
106 | 124 | |
— | — | @@ -116,7 +134,7 @@ |
117 | 135 | 'city' => 'City', |
118 | 136 | 'state' => 'State abbreviation', |
119 | 137 | 'zip' => 'Postal code', |
120 | | - 'email' => 'Email address', |
| 138 | + 'emailAdd' => 'Email address', |
121 | 139 | 'country' => 'Country code', |
122 | 140 | 'card_num' => 'Credit card number', |
123 | 141 | 'card_type' => 'Credit card type', |