Index: branches/fundraising/extensions/DonationInterface/gateway_common/donation.api.php |
— | — | @@ -10,14 +10,27 @@ |
11 | 11 | |
12 | 12 | $params = $this->extractRequestParams(); |
13 | 13 | |
14 | | - $gateway = $wgRequest->getText( 'gateway' ); |
| 14 | + // If you want to test with fake data, pass a 'test' param set to true. |
| 15 | + // You still have to set the gateway you are testing though. |
| 16 | + if ( array_key_exists( 'test', $params ) && $params['test'] ) { |
| 17 | + $params = $this->getTestData(); |
| 18 | + } |
15 | 19 | |
| 20 | + $gateway = $params['gateway']; |
| 21 | + $method = $params['payment_method']; |
| 22 | + |
16 | 23 | if ( $gateway == 'payflowpro' ) { |
17 | 24 | $gatewayObj = new PayflowProAdapter(); |
18 | | - $result = $gatewayObj->do_transaction( 'Card' ); |
| 25 | + switch ( $method ) { |
| 26 | + default: |
| 27 | + $result = $gatewayObj->do_transaction( 'Card' ); |
| 28 | + } |
19 | 29 | } else if ( $gateway == 'globalcollect' ) { |
20 | 30 | $gatewayObj = new GlobalCollectAdapter(); |
21 | | - $result = $gatewayObj->do_transaction( 'TEST_CONNECTION' ); |
| 31 | + switch ( $method ) { |
| 32 | + default: |
| 33 | + $result = $gatewayObj->do_transaction( 'TEST_CONNECTION' ); |
| 34 | + } |
22 | 35 | } else { |
23 | 36 | $this->dieUsage( "Invalid gateway <<<$gateway>>> passed to Donation API.", 'unknown_gateway' ); |
24 | 37 | } |
— | — | @@ -32,22 +45,23 @@ |
33 | 46 | public function getAllowedParams() { |
34 | 47 | return array( |
35 | 48 | 'gateway' => $this->defineParam( 'gateway', true ), |
36 | | - 'amount' => $this->defineParam( 'amount', true ), |
37 | | - 'currency' => $this->defineParam( 'currency', true ), |
38 | | - 'fname' => $this->defineParam( 'fname', true ), |
| 49 | + 'amount' => $this->defineParam( 'amount', false ), |
| 50 | + 'currency' => $this->defineParam( 'currency', false ), |
| 51 | + 'fname' => $this->defineParam( 'fname', false ), |
39 | 52 | 'mname' => $this->defineParam( 'mname', false ), |
40 | | - 'lname' => $this->defineParam( 'lname', true ), |
41 | | - 'street' => $this->defineParam( 'street', true ), |
42 | | - 'city' => $this->defineParam( 'city', true ), |
43 | | - 'state' => $this->defineParam( 'state', true ), |
44 | | - 'zip' => $this->defineParam( 'zip', true ), |
45 | | - 'email' => $this->defineParam( 'email', true ), |
46 | | - 'country' => $this->defineParam( 'country', true ), |
| 53 | + 'lname' => $this->defineParam( 'lname', false ), |
| 54 | + 'street' => $this->defineParam( 'street', false ), |
| 55 | + 'city' => $this->defineParam( 'city', false ), |
| 56 | + 'state' => $this->defineParam( 'state', false ), |
| 57 | + 'zip' => $this->defineParam( 'zip', false ), |
| 58 | + 'email' => $this->defineParam( 'email', false ), |
| 59 | + 'country' => $this->defineParam( 'country', false ), |
47 | 60 | 'card_num' => $this->defineParam( 'card_num', false ), |
48 | 61 | 'card_type' => $this->defineParam( 'card_type', false ), |
49 | 62 | 'expiration' => $this->defineParam( 'expiration', false ), |
50 | 63 | 'cvv' => $this->defineParam( 'cvv', false ), |
51 | 64 | 'payment_method' => $this->defineParam( 'payment_method', false ), |
| 65 | + 'language' => $this->defineParam( 'language', false ), |
52 | 66 | ); |
53 | 67 | } |
54 | 68 | |
— | — | @@ -59,12 +73,51 @@ |
60 | 74 | } |
61 | 75 | return $param; |
62 | 76 | } |
| 77 | + |
| 78 | + private function getTestData() { |
| 79 | + $params = array( |
| 80 | + 'amount' => "35", |
| 81 | + 'currency' => 'USD', |
| 82 | + 'fname' => 'Tester', |
| 83 | + 'mname' => 'T.', |
| 84 | + 'lname' => 'Testington', |
| 85 | + 'street' => '548 Market St.', |
| 86 | + 'city' => 'San Francisco', |
| 87 | + 'state' => 'CA', |
| 88 | + 'zip' => '94104', |
| 89 | + 'email' => 'test@example.com', |
| 90 | + 'country' => 'US', |
| 91 | + 'card_num' => '378282246310005', |
| 92 | + 'card_type' => 'american', |
| 93 | + 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
| 94 | + 'cvv' => '001', |
| 95 | + 'payment_method' => 'card', |
| 96 | + 'language' => 'en', |
| 97 | + ); |
| 98 | + return $params; |
| 99 | + } |
63 | 100 | |
64 | 101 | public function getParamDescription() { |
65 | 102 | return array( |
66 | 103 | 'gateway' => 'Which payment gateway to use - payflowpro, globalcollect, etc.', |
| 104 | + 'test' => 'Set to true if you want to use bogus test data instead of supplying your own', |
67 | 105 | 'amount' => 'The amount donated', |
68 | 106 | 'currency' => 'Currency code', |
| 107 | + 'fname' => 'First name', |
| 108 | + 'mname' => 'Middle name', |
| 109 | + 'lname' => 'Last name', |
| 110 | + 'street' => 'First line of street address', |
| 111 | + 'city' => 'City', |
| 112 | + 'state' => 'State abbreviation', |
| 113 | + 'zip' => 'Postal code', |
| 114 | + 'email' => 'Email address', |
| 115 | + 'country' => 'Country code', |
| 116 | + 'card_num' => 'Credit card number', |
| 117 | + 'card_type' => 'Credit card type', |
| 118 | + 'expiration' => 'Expiration date', |
| 119 | + 'cvv' => 'CVV security code', |
| 120 | + 'payment_method' => 'Payment method to use', |
| 121 | + 'language' => 'Language code', |
69 | 122 | ); |
70 | 123 | } |
71 | 124 | |