Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -107,12 +107,12 @@ |
108 | 108 | require_once( 'includes/payflowUser.inc' ); |
109 | 109 | |
110 | 110 | $payflow_data = payflowUser(); |
111 | | - |
| 111 | + |
112 | 112 | // make a log entry if the user has submitted the cc form |
113 | 113 | if ( $wgRequest->wasPosted() && $wgRequest->getText( 'process', 0 )) { |
114 | 114 | wfDebugLog( 'payflowpro_gateway', $payflow_data[ 'order_id' ] . " Transaction initiated." ); |
115 | 115 | } |
116 | | - |
| 116 | + |
117 | 117 | // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax |
118 | 118 | if ( $wgRequest->getText( '_cache_', false ) ) { |
119 | 119 | $cache = true; |
— | — | @@ -158,6 +158,7 @@ |
159 | 159 | |
160 | 160 | // Check form for errors and redisplay with messages |
161 | 161 | $form_errors = $this->fnPayflowValidateForm( $data, $this->errors ); |
| 162 | + |
162 | 163 | if ( $form_errors ) { |
163 | 164 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
164 | 165 | } else { // The submitted form data is valid, so process it |
— | — | @@ -256,7 +257,6 @@ |
257 | 258 | } |
258 | 259 | } |
259 | 260 | } |
260 | | - |
261 | 261 | $this->form_class = $class_name; |
262 | 262 | } |
263 | 263 | |
— | — | @@ -299,7 +299,7 @@ |
300 | 300 | |
301 | 301 | // find all empty fields and create message |
302 | 302 | foreach ( $data as $key => $value ) { |
303 | | - if ( $value == '' || $data['state'] == 'YY' ) { |
| 303 | + if ( $value == '' || ($key == 'state' && $value == 'YY' )) { |
304 | 304 | // ignore fields that are not required |
305 | 305 | if ( isset( $msg[$key] ) ) { |
306 | 306 | $error[$key] = "**" . wfMsg( 'payflowpro_gateway-error-msg', $msg[$key] ) . "**<br />"; |
— | — | @@ -376,7 +376,6 @@ |
377 | 377 | |
378 | 378 | |
379 | 379 | } // end switch |
380 | | - |
381 | 380 | return $error_result; |
382 | 381 | } |
383 | 382 | |
— | — | @@ -471,9 +470,9 @@ |
472 | 471 | if ( $headers['http_code'] != 200 ) { |
473 | 472 | $wgOut->addHTML( '<h3>No response from credit card processor. Please try again later!</h3><p>' ); |
474 | 473 | $when = time(); |
475 | | - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . ' No response from credit card processor ' . $when ); |
| 474 | + wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . ' No response from credit card processor: ' . curl_error( $ch )); |
476 | 475 | curl_close( $ch ); |
477 | | - exit; |
| 476 | + return; |
478 | 477 | } |
479 | 478 | |
480 | 479 | curl_close( $ch ); |
— | — | @@ -943,6 +942,9 @@ |
944 | 943 | * @return int The id for the reference URL - 0 if not found |
945 | 944 | */ |
946 | 945 | function get_owa_ref_id( $ref ) { |
| 946 | + if ( !defined( 'OWA' ) ) { |
| 947 | + return 0; |
| 948 | + } |
947 | 949 | // Replication lag means sometimes a new event will not exist in the table yet |
948 | 950 | $dbw = payflowGatewayConnection(); |
949 | 951 | $id_num = $dbw->selectField( |
— | — | @@ -979,7 +981,7 @@ |
980 | 982 | } |
981 | 983 | |
982 | 984 | // if we're in testing mode and an action hasn't yet be specified, prepopulate the form |
983 | | - if ( !$wgRequest->getText( 'action', false ) && !$numAttempt && $wgPayflowGatewayTest ) { |
| 985 | + if ( !$wgRequest->getText( 'action', false ) && !$wgRequest->getText( 'process', 0 ) && $wgPayflowGatewayTest ) { |
984 | 986 | // define arrays of cc's and cc #s for random selection |
985 | 987 | $cards = array( 'american' ); |
986 | 988 | $card_nums = array( |
— | — | @@ -1006,8 +1008,8 @@ |
1007 | 1009 | 'state' => 'CA', |
1008 | 1010 | 'zip' => '94104', |
1009 | 1011 | 'country' => 840, |
| 1012 | + 'card_num' => $card_nums[ $cards[ $card_index ]][ $card_num_index ], |
1010 | 1013 | 'card' => $cards[ $card_index ], |
1011 | | - 'card_num' => $card_nums[ $cards[ $card_index ]][ $card_num_index ], |
1012 | 1014 | 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
1013 | 1015 | 'cvv' => '001', |
1014 | 1016 | 'currency' => 'USD', |
— | — | @@ -1019,8 +1021,8 @@ |
1020 | 1022 | 'utm_medium' => $wgRequest->getText( 'utm_medium' ), |
1021 | 1023 | 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ), |
1022 | 1024 | 'language' => 'en', |
| 1025 | + 'comment-option' => $wgRequest->getText( 'comment-option' ), |
1023 | 1026 | 'comment' => $wgRequest->getText( 'comment' ), |
1024 | | - 'comment-option' => $wgRequest->getText( 'comment-option' ), |
1025 | 1027 | 'email-opt' => $wgRequest->getText( 'email-opt' ), |
1026 | 1028 | 'test_string' => $wgRequest->getText( 'process' ), |
1027 | 1029 | 'token' => $token, |
— | — | @@ -1043,9 +1045,9 @@ |
1044 | 1046 | 'city' => $wgRequest->getText( 'city' ), |
1045 | 1047 | 'state' => $wgRequest->getText( 'state' ), |
1046 | 1048 | 'zip' => $wgRequest->getText( 'zip' ), |
1047 | | - 'country' => $wgRequest->getText( 'country' ), |
| 1049 | + 'country' => $wgRequest->getText( 'country', "840" ), |
| 1050 | + 'card_num' => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ), |
1048 | 1051 | 'card' => $wgRequest->getText( 'card' ), |
1049 | | - 'card_num' => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ), |
1050 | 1052 | 'expiration' => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ), |
1051 | 1053 | 'cvv' => $wgRequest->getText( 'cvv' ), |
1052 | 1054 | 'currency' => $wgRequest->getText( 'currency_code' ), |
— | — | @@ -1058,8 +1060,8 @@ |
1059 | 1061 | 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ), |
1060 | 1062 | // try to honr the user-set language (uselang), otherwise the language set in the URL (language) |
1061 | 1063 | 'language' => $wgRequest->getText( 'uselang', $wgRequest->getText( 'language' ) ), |
| 1064 | + 'comment-option' => $wgRequest->getText( 'comment-option' ), |
1062 | 1065 | 'comment' => $wgRequest->getText( 'comment' ), |
1063 | | - 'comment-option' => $wgRequest->getText( 'comment-option' ), |
1064 | 1066 | 'email-opt' => $wgRequest->getText( 'email-opt' ), |
1065 | 1067 | 'test_string' => $wgRequest->getText( 'process' ), // for showing payflow string during testing |
1066 | 1068 | 'token' => $token, |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/html/demo.html |
— | — | @@ -0,0 +1,161 @@ |
| 2 | +<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td id="appeal" valign="top"><h2 id="appeal-head"> <span class="mw-headline" id="An_appeal_from_Wikipedia_founder_Jimmy_Wales">An appeal from Wikipedia founder Jimmy Wales</span></h2> |
| 3 | +<div class="plainlinks" id="appeal-body">I got a lot of funny looks ten years ago when I started talking to people about Wikipedia. |
| 4 | +<p>Let’s just say some people were skeptical of the notion that volunteers from all across the world could come together to create a remarkable pool of human knowledge – all for the simple purpose of sharing.</p> |
| 5 | +<p>No ads. No agenda. No strings attached.</p> |
| 6 | +<p>A decade after its founding, nearly 400 million people use Wikipedia and its sister sites every month - almost a third of the Internet-connected world.</p> |
| 7 | +<p>It is the 5th most popular website in the world but Wikipedia isn’t anything like a commercial website. It is a community creation, written by volunteers making one entry at a time. You are part of our community. And I’m writing today to ask you to protect and sustain Wikipedia.</p> |
| 8 | +<p>Together, we can keep it free of charge and free of advertising. We can keep it open – you can use the information in Wikipedia any way you want. We can keep it growing – spreading knowledge everywhere, and inviting participation from everyone.</p> |
| 9 | + |
| 10 | +<p>Each year at this time, we reach out to ask you and others all across the Wikimedia community to help sustain our joint enterprise with a modest donation of $20, $35, $50 or more.</p> |
| 11 | +<p>If you value Wikipedia as a source of information – and a source of inspiration – I hope you’ll choose to act right now.</p> |
| 12 | +<p>All the best,</p> |
| 13 | +<p><b>Jimmy Wales</b></p> |
| 14 | +<p>Founder, Wikipedia</p> |
| 15 | +<p>P.S. Wikipedia is about the power of people like us to do extraordinary things. People like us write Wikipedia, one word at a time. People like us fund it, one donation at a time. It's proof of our collective potential to change the world.</p> |
| 16 | +<p><br /> |
| 17 | +</p> |
| 18 | +</div> |
| 19 | +</td><td id="donate" valign="top"> |
| 20 | +<noscript><div id="noscript"><p id="noscript-msg">It appears that you do not have JavaScript enabled, or your browser does not support it. |
| 21 | +In order to provide a safe, secure and pleasant experience, our donation form requires JavaScript.</p><p id="noscript-redirect-msg">If you cannot or do not wish to enable JavaScript, you may still contribute by visiting:</p><p id="noscript-redirect-link"><a href="http://wikimediafoundation.org/wiki/DonateNonJS/en">http://wikimediafoundation.org/wiki/DonateNonJS/en</a></p></div></noscript> |
| 22 | + |
| 23 | +<h2 id="donate-head">Make your donation now</h2> |
| 24 | +<p class='creditcard-error-msg'>#general</p> |
| 25 | +<form name="payment" method="post" action="/index.php/Special:PayflowProGateway?form_name=RapidHtml&ffname=demo" autocomplete="off"> |
| 26 | + <div id="payflowpro_gateway-personal-info"><table id="payflow-table-donor"> |
| 27 | + <tr> |
| 28 | + <td colspan=2><span class="creditcard-error-msg">#fname</span></td> |
| 29 | + </tr> |
| 30 | + <tr> |
| 31 | + <td colspan=2><span class="creditcard-error-msg">#lname</span></td> |
| 32 | + </tr> |
| 33 | + <tr> |
| 34 | + <td class="label"><label for="fname">Name</label></td> |
| 35 | + <td> |
| 36 | + <input name="fname" size="30" value="@fname" type="text" onfocus="clearField( this, 'First' )" maxlength="25" class="required" id="fname" /> |
| 37 | + <input name="lname" size="30" value="@lname" type="text" onfocus="clearField( this, 'Last' )" maxlength="25" id="lname" /> |
| 38 | + </td> |
| 39 | + </tr> |
| 40 | + <tr> |
| 41 | + <td colspan=2><span class="creditcard-error-msg">#emailAdd</span></td> |
| 42 | + </tr> |
| 43 | + <tr> |
| 44 | + <td class="label"><label for="emailAdd">Email address</label></td> |
| 45 | + <td><input name="emailAdd" size="30" value="@emailAdd" type="text" maxlength="64" id="emailAdd" class="fullwidth" /></td> |
| 46 | + </tr> |
| 47 | + <tr> |
| 48 | + <td colspan="2"><span class="creditcard-error-msg">#amount</span></td> |
| 49 | + </tr> |
| 50 | + <tr> |
| 51 | + <td class="label"><label for="amount">Amount</label></td> |
| 52 | + <td> |
| 53 | + <input name="amount" size="7" value="@amount" type="text" maxlength="10" id="amount" /> |
| 54 | + <select name="currency_code" id="input_currency_code"> |
| 55 | + <option value="USD">USD: U.S. Dollar</option><option value="GBP">GBP: British Pound</option><option value="EUR">EUR: Euro</option><option value="AUD">AUD: Australian Dollar</option><option value="CAD">CAD: Canadian Dollar</option><option value="JPY">JPY: Japanese Yen</option> |
| 56 | + </select> |
| 57 | + </td> |
| 58 | + </tr> |
| 59 | + <tr> |
| 60 | + <td /> |
| 61 | + <td><img src="/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" /></td> |
| 62 | + </tr> |
| 63 | + <tr> |
| 64 | + <td class="label"><label for="card_num">Card number</label></td> |
| 65 | + <td><input name="card_num" size="30" value="@card_num" type="text" maxlength="100" id="card_num" class="fullwidth" autocomplete="off" /></td> |
| 66 | + </tr> |
| 67 | + <tr> |
| 68 | + <td colspan=2><span class="creditcard-error-msg">#cvv</span></td> |
| 69 | + <tr> |
| 70 | + <td class="label"><label for="cvv">Security code</label></td> |
| 71 | + <td><input name="cvv" size="5" value="@cvv" type="text" maxlength="10" id="cvv" autocomplete="off" /> <a href="javascript:PopupCVV();">Where is this?</a></td> |
| 72 | + </tr> |
| 73 | + <tr> |
| 74 | + <td class="label"><label for="expiration">Expiration date</label></td> |
| 75 | + <td> |
| 76 | + <select name="mos" id="expiration"> |
| 77 | + <option value="01">1 (January)</option><option value="02">2 (February)</option><option value="03">3 (March)</option><option value="04">4 (April)</option><option value="05">5 (May)</option><option value="06">6 (June)</option><option value="07">7 (July)</option><option value="08">8 (August)</option><option value="09">9 (September)</option><option value="10">10 (October)</option><option value="11">11 (November)</option><option value="12">12 (December)</option> |
| 78 | + </select> |
| 79 | + <select name="year" id="year"> |
| 80 | + <option value="2010">2010</option><option value="2011">2011</option><option value="2012">2012</option><option value="2013">2013</option><option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option><option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option><option value="2020">2020</option> |
| 81 | + </select> |
| 82 | + </td> |
| 83 | + </tr> |
| 84 | + <tr> |
| 85 | + <td colspan=2><span class="creditcard-error-msg">#street</span></td> |
| 86 | + </tr> |
| 87 | + <tr> |
| 88 | + <td class="label"><label for="street">Street</label></td> |
| 89 | + <td><input name="street" size="30" value="@street" type="text" maxlength="100" id="street" class="fullwidth" /></td> |
| 90 | + </tr> |
| 91 | + <tr> |
| 92 | + <td colspan=2><span class="creditcard-error-msg">#city</span></td> |
| 93 | + </tr> |
| 94 | + <tr> |
| 95 | + <td class="label"><label for="city">City</label></td> |
| 96 | + <td><input name="city" size="30" value="@city" type="text" maxlength="40" id="city" class="fullwidth" /></td> |
| 97 | + </tr> |
| 98 | + <tr> |
| 99 | + <td colspan=2><span class="creditcard-error-msg">#state</span></td> |
| 100 | + </tr> |
| 101 | + <tr> |
| 102 | + <td class="label"><label for="state">State</label></td> |
| 103 | + <td> |
| 104 | + <select name="state" id="state"> |
| 105 | + <option value="YY">Select a State</option><option value="XX">Outside the U.S.</option><option value="AK">Alaska</option><option value="AL">Alabama</option><option value="AR">Arkansas</option><option value="AZ">Arizona</option><option value="CA">California</option><option value="CO">Colorado</option><option value="CT">Connecticut</option><option value="DC">Washington D.C.</option><option value="DE">Delaware</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="HI">Hawaii</option><option value="IA">Iowa</option><option value="ID">Idaho</option><option value="IL">Illinois</option><option value="IN">Indiana</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="MA">Massachusetts</option><option value="MD">Maryland</option><option value="ME">Maine</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MO">Missouri</option><option value="MS">Mississippi</option><option value="MT">Montana</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="NE">Nebraska</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NV">Nevada</option><option value="NY">New York</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PA">Pennsylvania</option><option value="PR">Puerto Rico</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option><option value="SD">South Dakota</option><option value="TN">Tennessee</option><option value="TX">Texas</option><option value="UT">Utah</option><option value="VA">Virginia</option><option value="VT">Vermont</option><option value="WA">Washington</option><option value="WI">Wisconsin</option><option value="WV">West Virginia</option><option value="WY">Wyoming</option><option value="AA">AA</option><option value="AE">AE</option><option value="AP">AP</option> |
| 106 | + </select> |
| 107 | + </td> |
| 108 | + </tr> |
| 109 | + <tr> |
| 110 | + <td colspan=2><span class="creditcard-error-msg">#zip</span></td> |
| 111 | + </tr> |
| 112 | + <tr> |
| 113 | + <td class="label"><label for="zip">Postal code</label></td> |
| 114 | + <td><input name="zip" size="30" value="@zip" type="text" maxlength="9" id="zip" class="fullwidth" /></td> |
| 115 | + </tr> |
| 116 | + <tr> |
| 117 | + <td colspan=2><span class="creditcard-error-msg">#country</span></td> |
| 118 | + </tr> |
| 119 | + <tr> |
| 120 | + <td class="label"><label for="country">Country/Region</label></td> |
| 121 | + <td> |
| 122 | + <select name="country" id="country" onchange="return disableStates( this )"> |
| 123 | + <option value="004">Afghanistan</option><option value="008">Albania</option><option value="012">Algeria</option><option value="016">American Samoa</option><option value="020">Andorra</option><option value="024">Angola</option><option value="660">Anguilla</option><option value="010">Antarctica</option><option value="028">Antigua and Barbuda</option><option value="032">Argentina</option><option value="051">Armenia</option><option value="533">Aruba</option><option value="036">Australia</option><option value="040">Austria</option><option value="031">Azerbaijan</option><option value="044">Bahamas</option><option value="048">Bahrain</option><option value="050">Bangladesh</option><option value="052">Barbados</option><option value="112">Belarus</option><option value="056">Belgium</option><option value="084">Belize</option><option value="204">Benin</option><option value="060">Bermuda</option><option value="064">Bhutan</option><option value="068">Bolivia, Plurinational State of</option><option value="070">Bosnia and Herzegovina</option><option value="072">Botswana</option><option value="074">Bouvet Island</option><option value="076">Brazil</option><option value="086">British Indian Ocean Territory</option><option value="096">Brunei Darussalam</option><option value="100">Bulgaria</option><option value="854">Burkina Faso</option><option value="108">Burundi</option><option value="116">Cambodia</option><option value="120">Cameroon</option><option value="124">Canada</option><option value="132">Cape Verde</option><option value="136">Cayman Islands</option><option value="140">Central African Republic</option><option value="148">Chad</option><option value="152">Chile</option><option value="156">China</option><option value="162">Christmas Island</option><option value="166">Cocos (Keeling) Islands</option><option value="017">Colombia</option><option value="174">Comoros</option><option value="178">Congo</option><option value="180">Congo, the Democratic Republic of the</option><option value="184">Cook Islands</option><option value="188">Costa Rica</option><option value="384">Cote D'Ivoire</option><option value="191">Croatia</option><option value="192">Cuba</option><option value="196">Cyprus</option><option value="203">Czech Republic</option><option value="208">Denmark</option><option value="262">Djibouti</option><option value="212">Dominica</option><option value="214">Dominican Republic</option><option value="626">East Timor</option><option value="218">Ecuador</option><option value="818">Egypt</option><option value="222">El Salvador</option><option value="226">Equatorial Guinea</option><option value="232">Eritrea</option><option value="233">Estonia</option><option value="231">Ethiopia</option><option value="238">Falkland Islands (Malvinas)</option><option value="234">Faroe Islands</option><option value="242">Fiji</option><option value="246">Finland</option><option value="250">France</option><option value="254">French Guiana</option><option value="258">French Polynesia</option><option value="260">French Southern Territories</option><option value="266">Gabon</option><option value="270">Gambia</option><option value="268">Georgia</option><option value="276">Germany</option><option value="288">Ghana</option><option value="292">Gibraltar</option><option value="300">Greece</option><option value="304">Greenland</option><option value="308">Grenada</option><option value="312">Guadeloupe</option><option value="316">Guam</option><option value="320">Guatemala</option><option value="324">Guinea</option><option value="624">Guinea-Bissau</option><option value="328">Guyana</option><option value="332">Haiti</option><option value="334">Heard Island and McDonald Islands</option><option value="340">Honduras</option><option value="344">Hong Kong</option><option value="348">Hungary</option><option value="352">Iceland</option><option value="356">India</option><option value="360">Indonesia</option><option value="364">Iran, Islamic Republic of</option><option value="368">Iraq</option><option value="372">Ireland</option><option value="376">Israel</option><option value="380">Italy</option><option value="388">Jamaica</option><option value="392">Japan</option><option value="400">Jordan</option><option value="398">Kazakhstan</option><option value="404">Kenya</option><option value="296">Kiribati</option><option value="408">Korea, Democratic People's Republic of</option><option value="410">Korea, Republic of</option><option value="414">Kuwait</option><option value="417">Kyrgyzstan</option><option value="418">Laos</option><option value="428">Latvia</option><option value="422">Lebanon</option><option value="426">Lesotho</option><option value="430">Liberia</option><option value="434">Libyan Arab Jamahiriya</option><option value="438">Liechtenstein</option><option value="440">Lithuania</option><option value="442">Luxembourg</option><option value="446">Macao</option><option value="807">Macedonia</option><option value="450">Madagascar</option><option value="454">Malawi</option><option value="458">Malaysia</option><option value="462">Maldives</option><option value="466">Mali</option><option value="470">Malta</option><option value="584">Marshall Islands</option><option value="474">Martinique</option><option value="478">Mauritania</option><option value="480">Mauritius</option><option value="175">Mayotte</option><option value="484">Mexico</option><option value="583">Micronesia, Federated States of</option><option value="498">Moldova, Republic of</option><option value="492">Monaco</option><option value="496">Mongolia</option><option value="499">Montenegro</option><option value="500">Montserrat</option><option value="504">Morocco</option><option value="508">Mozambique</option><option value="104">Myanmar</option><option value="516">Namibia</option><option value="520">Nauru</option><option value="524">Nepal</option><option value="528">Netherlands</option><option value="530">Netherlands Antilles</option><option value="540">New Caledonia</option><option value="554">New Zealand</option><option value="558">Nicaragua</option><option value="562">Niger</option><option value="566">Nigeria</option><option value="570">Niue</option><option value="574">Norfolk Island</option><option value="580">Northern Mariana Islands</option><option value="578">Norway</option><option value="512">Oman</option><option value="586">Pakistan</option><option value="585">Palau</option><option value="591">Panama</option><option value="598">Papua New Guinea</option><option value="600">Paraguay</option><option value="604">Peru</option><option value="608">Philippines</option><option value="612">Pitcairn</option><option value="616">Poland</option><option value="620">Portugal</option><option value="630">Puerto Rico</option><option value="634">Qatar</option><option value="642">Romania</option><option value="643">Russian Federation</option><option value="646">Rwanda</option><option value="654">Saint Helena</option><option value="659">Saint Kitts and Nevis</option><option value="662">Saint Lucia</option><option value="666">Saint Pierre and Miquelon</option><option value="670">Saint Vincent and the Grenadines</option><option value="674">San Marino</option><option value="678">Sao Tome and Principe</option><option value="682">Saudi Arabia</option><option value="686">Senegal</option><option value="688">Serbia</option><option value="690">Seychelles</option><option value="694">Sierra Leone</option><option value="702">Singapore</option><option value="703">Slovakia</option><option value="705">Slovenia</option><option value="090">Solomon Islands</option><option value="706">Somalia</option><option value="710">South Africa</option><option value="724">Spain</option><option value="144">Sri Lanka</option><option value="736">Sudan</option><option value="740">Suriname</option><option value="744">Svalbard and Jan Mayen</option><option value="748">Swaziland</option><option value="752">Sweden</option><option value="756">Switzerland</option><option value="760">Syrian Arab Republic</option><option value="158">Taiwan</option><option value="762">Tajikistan</option><option value="834">Tanzania, United Republic of</option><option value="764">Thailand</option><option value="768">Togo</option><option value="772">Tokelau</option><option value="776">Tonga</option><option value="780">Trinidad and Tobago</option><option value="788">Tunisia</option><option value="792">Turkey</option><option value="795">Turkmenistan</option><option value="796">Turks and Caicos Islands</option><option value="798">Tuvalu</option><option value="800">Uganda</option><option value="804">Ukraine</option><option value="784">United Arab Emirates</option><option value="826">United Kingdom</option><option value="840">United States</option><option value="581">United States Minor Outlying Islands</option><option value="858">Uruguay</option><option value="860">Uzbekistan</option><option value="548">Vanuatu</option><option value="336">Vatican City State</option><option value="862">Venezuela, Bolivarian Republic of</option><option value="704">Viet Nam</option><option value="092">Virgin Islands, British</option><option value="850">Virgin Islands, U.S.</option><option value="876">Wallis and Futuna</option><option value="732">Western Sahara</option><option value="882">Western Samoa</option><option value="887">Yemen</option><option value="894">Zambia</option><option value="716">Zimbabwe</option> |
| 124 | + </select> |
| 125 | + </td> |
| 126 | + </tr> |
| 127 | + </table> |
| 128 | + </div> |
| 129 | + <!-- captcha --> |
| 130 | + @captcha |
| 131 | + <!-- end captcha --> |
| 132 | + <div id="payflowpro_gateway-form-submit"> |
| 133 | + <div id="mw-donate-submit-button"> |
| 134 | + <input class="button-plain" value="Donate by Credit Card" type="submit" /> |
| 135 | + </div> |
| 136 | + <div class="mw-donate-submessage" id="payflowpro_gateway-donate-submessage"> |
| 137 | + Your credit card will be securely processed. |
| 138 | + </div> |
| 139 | + </div> |
| 140 | + <input type="hidden" value="@utm_source" name="utm_source" /> |
| 141 | + <input type="hidden" value="@utm_medium" name="utm_medium" /> |
| 142 | + <input type="hidden" value="@utm_campaign" name="utm_campaign" /> |
| 143 | + <input type="hidden" value="@language" name="language" /> |
| 144 | + <input type="hidden" value="@referrer" name="referrer" /> |
| 145 | + <input type="hidden" value="@comment" name="comment" /> |
| 146 | + <input type="hidden" value="@comment-option" name="comment-option" /> |
| 147 | + <input type="hidden" value="@email-opt" name="email-opt" /> |
| 148 | + <input type="hidden" value="CreditCard" name="process" /> |
| 149 | + <input type="hidden" value="processed" name="payment_method" /> |
| 150 | + <input type="hidden" value="@token" name="token" /> |
| 151 | + <input type="hidden" value="@orderid" name="orderid" /> |
| 152 | + <input type="hidden" value="@numAttempt" name="numAttempt" /> |
| 153 | + <input type="hidden" value="@contribution_tracking_id" name="contribution_tracking_id" /> |
| 154 | + <input type="hidden" value="@data_hash" name="data_hash" /> |
| 155 | + <input type="hidden" value="@action" name="action" /> |
| 156 | + <input type="hidden" value="@owa_session" name="owa_session" /> |
| 157 | + <input type="hidden" value="@owa_ref" name="owa_ref" /> |
| 158 | +</form> |
| 159 | +<div class="payflow-cc-form-section" id="payflowpro_gateway-donate-addl-info"><div id="payflowpro_gateway-donate-addl-info-secure-logos"><p class=""><img src="/extensions/DonationInterface/payflowpro_gateway/includes/rapidssl_ssl_certificate-nonanimated.png"></p></div><div id="payflowpro_gateway-donate-addl-info-text"><p class=""><a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">Other ways to give</a></p><p class="">We do not store your credit card information, and your personal data is subject to our <a href="http://wikimediafoundation.org/wiki/Donor_Privacy_Policy">privacy policy</a>.</p><p class="">Questions or comments? Contact: <a href="mailto:donate@wikimedia.org">donate@wikimedia.org</a></p></div></div></td></tr></table><div class="printfooter"> |
| 160 | + |
| 161 | +Retrieved from "<a href="https://payments.wikimedia.org/index.php/Special:PayflowProGateway">https://payments.wikimedia.org/index.php/Special:PayflowProGateway</a>"</div> |
| 162 | + |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/RapidHtml.php |
— | — | @@ -0,0 +1,227 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class PayflowProGateway_Form_RapidHtml extends PayflowProGateway_Form { |
| 5 | + |
| 6 | + /** |
| 7 | + * Full path of HTML form to load |
| 8 | + * @var string |
| 9 | + */ |
| 10 | + protected $html_file_path = ''; |
| 11 | + |
| 12 | + /** |
| 13 | + * Tokens used in HTML form for data replacement |
| 14 | + * |
| 15 | + * Note that these NEED to be in the same order as the variables in $data in |
| 16 | + * order for str_replace to work as expected |
| 17 | + * @var array |
| 18 | + */ |
| 19 | + protected $data_tokens = array( |
| 20 | + '@amount', // => $amount, |
| 21 | + '@amountOther', // => $wgRequest->getText( 'amountOther' ), |
| 22 | + '@emailAdd', //'email' => $wgRequest->getText( 'emailAdd' ), |
| 23 | + '@fname', // => $wgRequest->getText( 'fname' ), |
| 24 | + '@mname', // => $wgRequest->getText( 'mname' ), |
| 25 | + '@lname', // => $wgRequest->getText( 'lname' ), |
| 26 | + '@street', // => $wgRequest->getText( 'street' ), |
| 27 | + '@city', // => $wgRequest->getText( 'city' ), |
| 28 | + '@state', // => $wgRequest->getText( 'state' ), |
| 29 | + '@zip', // => $wgRequest->getText( 'zip' ), |
| 30 | + '@country', // => $wgRequest->getText( 'country' ), |
| 31 | + '@card_num', // => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ), |
| 32 | + '@card', // => $wgRequest->getText( 'card' ), |
| 33 | + '@expiration', // => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ), |
| 34 | + '@cvv', // => $wgRequest->getText( 'cvv' ), |
| 35 | + '@currency_code', //'currency' => $wgRequest->getText( 'currency_code' ), |
| 36 | + '@payment_method', // => $wgRequest->getText( 'payment_method' ), |
| 37 | + '@orderid', // => $order_id, |
| 38 | + '@numAttempt', // => $numAttempt, |
| 39 | + '@referrer', // => ( $wgRequest->getVal( 'referrer' ) ) ? $wgRequest->getVal( 'referrer' ) : $wgRequest->getHeader( 'referer' ), |
| 40 | + '@utm_source', // => self::getUtmSource(), |
| 41 | + '@utm_medium', // => $wgRequest->getText( 'utm_medium' ), |
| 42 | + '@utm_campaign', // => $wgRequest->getText( 'utm_campaign' ), |
| 43 | + // try to honr the user-set language (uselang), otherwise the language set in the URL (language) |
| 44 | + '@language', // => $wgRequest->getText( 'uselang', $wgRequest->getText( 'language' ) ), |
| 45 | + '@comment-option', // => $wgRequest->getText( 'comment-option' ), |
| 46 | + '@comment', // => $wgRequest->getText( 'comment' ), |
| 47 | + '@email-opt', // => $wgRequest->getText( 'email-opt' ), |
| 48 | + '@test_string', // => $wgRequest->getText( 'process' ), // for showing payflow string during testing |
| 49 | + '@token', // => $token, |
| 50 | + '@contribution_tracking_id', // => $wgRequest->getText( 'contribution_tracking_id' ), |
| 51 | + '@data_hash', // => $wgRequest->getText( 'data_hash' ), |
| 52 | + '@action', // => $wgRequest->getText( 'action' ), |
| 53 | + '@gateway', // => 'payflowpro', // this may need to become dynamic in the future |
| 54 | + '@owa_session', // => $wgRequest->getText( 'owa_session', null ), |
| 55 | + '@owa_ref', // => $owa_ref, |
| 56 | + ); |
| 57 | + |
| 58 | + /** |
| 59 | + * Error field names used as tokens |
| 60 | + * @var array |
| 61 | + * @FIXME |
| 62 | + * THERE IS A PROBLEM WITH 'general' - this is an array in the gateway body!!! |
| 63 | + */ |
| 64 | + protected $error_tokens = array( |
| 65 | + '#general', |
| 66 | + '#retryMsg', |
| 67 | + '#amount', |
| 68 | + '#card_num', |
| 69 | + '#card', |
| 70 | + '#cvv', |
| 71 | + '#fname', |
| 72 | + '#lname', |
| 73 | + '#city', |
| 74 | + '#country', |
| 75 | + '#street', |
| 76 | + '#state', |
| 77 | + '#zip', |
| 78 | + '#emailAdd', |
| 79 | + ); |
| 80 | + |
| 81 | + public function __construct( &$form_data, &$form_errors ) { |
| 82 | + global $wgRequest; |
| 83 | + |
| 84 | + parent::__construct( $form_data, $form_errors ); |
| 85 | + |
| 86 | + $this->loadValidateJs(); |
| 87 | + |
| 88 | + $this->set_html_file_path( $wgRequest->getText( 'ffname', 'default' ) ); |
| 89 | + |
| 90 | + // fix general form error messages so it's not an array of msgs |
| 91 | + if ( count( $form_errors[ 'general' ] )) { |
| 92 | + $general_errors = ""; |
| 93 | + foreach ( $form_errors[ 'general' ] as $general_error ) { |
| 94 | + $general_errors .= "<p class='creditcard'>$general_error</p>"; |
| 95 | + } |
| 96 | + $form_errors[ 'general' ] = $general_errors; |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Return the HTML form with data added |
| 102 | + */ |
| 103 | + public function getForm() { |
| 104 | + $html = $this->load_html(); |
| 105 | + return $this->add_data( $html ); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Load the HTML form from a file into a string |
| 110 | + * @return string |
| 111 | + */ |
| 112 | + public function load_html() { |
| 113 | + return file_get_contents( $this->html_file_path ); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Add data into the HTML form |
| 118 | + * |
| 119 | + * @param string $html Form with tokens as placehodlers for data |
| 120 | + * @return string The HTML form with real data in it |
| 121 | + */ |
| 122 | + public function add_data( $html ) { |
| 123 | + // replace data |
| 124 | + $form = str_replace( $this->data_tokens, $this->form_data, $html ); |
| 125 | + |
| 126 | + // replace errors |
| 127 | + $form = str_replace( $this->error_tokens, $this->form_errors, $form ); |
| 128 | + |
| 129 | + // handle captcha |
| 130 | + $form = str_replace( "@captcha", $this->getCaptchaHtml(), $form ); |
| 131 | + |
| 132 | + $form = $this->fix_dropdowns( $form ); |
| 133 | + |
| 134 | + return $form; |
| 135 | + } |
| 136 | + |
| 137 | + /** |
| 138 | + * Set dropdowns to 'selected' where appropriate |
| 139 | + * |
| 140 | + * This is basically a hackish fix to make sure that dropdowns stay |
| 141 | + * 'sticky' on form submit. This could no doubt be better. |
| 142 | + * @param $html |
| 143 | + * @return string |
| 144 | + */ |
| 145 | + public function fix_dropdowns( $html ) { |
| 146 | + // currency code |
| 147 | + $start = strpos( $html, 'name="currency_code"' ); |
| 148 | + if ( $start ) { |
| 149 | + $currency_code = $this->form_data[ 'currency' ]; |
| 150 | + $end = strpos( $html, '</select>', $start ); |
| 151 | + $str = substr( $html, $start, ( $end - $start )); |
| 152 | + $str = str_replace( 'value="' . $currency_code . '"', 'value="' . $currency_code . '" selected="selected"', $str ); |
| 153 | + $html = substr_replace( $html, $str, $start, $end-$start ); |
| 154 | + } |
| 155 | + |
| 156 | + // mos |
| 157 | + $month = substr( $this->form_data[ 'expiration' ], 0, 2 ); |
| 158 | + $start = strpos( $html, 'name="mos"' ); |
| 159 | + if ( $start ) { |
| 160 | + $end = strpos( $html, '</select>', $start ); |
| 161 | + $str = substr( $html, $start, ( $end - $start )); |
| 162 | + $str = str_replace( 'value="' . $month . '"', 'value="' . $month . '" selected="selected"', $str ); |
| 163 | + $html = substr_replace( $html, $str, $start, $end-$start ); |
| 164 | + } |
| 165 | + |
| 166 | + // year |
| 167 | + $year = substr( $this->form_data[ 'expiration' ], 2, 2 ); |
| 168 | + $start = strpos( $html, 'name="year"' ); |
| 169 | + if ( $start ) { |
| 170 | + $end = strpos( $html, '</select>', $start ); |
| 171 | + $str = substr( $html, $start, ( $end - $start )); |
| 172 | + // dbl extra huge hack alert! note the '20' prefix... |
| 173 | + $str = str_replace( 'value="20' . $year . '"', 'value="20' . $year . '" selected="selected"', $str ); |
| 174 | + $html = substr_replace( $html, $str, $start, $end-$start ); |
| 175 | + } |
| 176 | + |
| 177 | + // state |
| 178 | + $state = $this->form_data[ 'state' ]; |
| 179 | + $start = strpos( $html, 'name="state"' ); |
| 180 | + if ( $start ) { |
| 181 | + $end = strpos( $html, '</select>', $start ); |
| 182 | + $str = substr( $html, $start, ( $end - $start )); |
| 183 | + $str = str_replace( 'value="' . $state . '"', 'value="' . $state . '" selected="selected"', $str ); |
| 184 | + $html = substr_replace( $html, $str, $start, $end-$start ); |
| 185 | + } |
| 186 | + |
| 187 | + //country |
| 188 | + $country = $this->form_data[ 'country' ]; |
| 189 | + $start = strpos( $html, 'name="country"' ); |
| 190 | + if ( $start ) { |
| 191 | + $end = strpos( $html, '</select>', $start ); |
| 192 | + $str = substr( $html, $start, ( $end - $start )); |
| 193 | + $str = str_replace( 'value="' . $country . '"', 'value="' . $country . '" selected="selected"', $str ); |
| 194 | + $html = substr_replace( $html, $str, $start, $end-$start ); |
| 195 | + } |
| 196 | + |
| 197 | + return $html; |
| 198 | + } |
| 199 | + |
| 200 | + /** |
| 201 | + * Validate and set the path to the HTML file |
| 202 | + * |
| 203 | + * @param string $file_name |
| 204 | + */ |
| 205 | + public function set_html_file_path( $file_name ) { |
| 206 | + global $wgPayflowHtmlFormDir; |
| 207 | + |
| 208 | + // Get the dirname - the "/." helps ensure we get a consistent path name with no trailing slash |
| 209 | + $html_dir = dirname( $wgPayflowHtmlFormDir . "/." ); |
| 210 | + |
| 211 | + if ( !is_dir( $html_dir )) { |
| 212 | + // throw some error |
| 213 | + } |
| 214 | + |
| 215 | + // make sure our file name is clean - strip extension and any other cruft like relpaths, dirs, etc |
| 216 | + $file_info = pathinfo( $file_name ); |
| 217 | + $file_name = $file_info[ 'filename' ]; |
| 218 | + |
| 219 | + $full_path = $html_dir . '/' . $file_name . '.html'; |
| 220 | + |
| 221 | + if ( !file_exists( $full_path )) { |
| 222 | + // throw some error or use default or both? |
| 223 | + } |
| 224 | + |
| 225 | + $this->html_file_path = $full_path; |
| 226 | + } |
| 227 | + |
| 228 | +} |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetterCA' ] = $dir . 'forms/TwoStepTwoColumnLetterCA.php'; |
37 | 37 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetter2' ] = $dir . 'forms/TwoStepTwoColumnLetter2.php'; |
38 | 38 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetter3' ] = $dir . 'forms/TwoStepTwoColumnLetter3.php'; |
| 39 | +$wgAutoloadClasses[ 'PayflowProGateway_Form_RapidHtml' ] = $dir . 'forms/RapidHtml.php'; |
39 | 40 | $wgAutoloadClasses[ 'PayflowProGateway_Form_SingleColumn' ] = $dir . 'forms/SingleColumn.php'; |
40 | 41 | $wgExtensionMessagesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.i18n.php'; |
41 | 42 | $wgExtensionMessagesFiles['PayflowProGatewayCountries'] = $dir . 'payflowpro_gateway.countries.i18n.php'; |
— | — | @@ -122,6 +123,12 @@ |
123 | 124 | $wgPayflowSMaxAge = 6000; |
124 | 125 | |
125 | 126 | /** |
| 127 | + * Directory for HTML forms (used by RapidHtml form class) |
| 128 | + * @var string |
| 129 | + */ |
| 130 | +$wgPayflowHtmlFormDir = dirname( __FILE__ ) . "/forms/html"; |
| 131 | + |
| 132 | +/** |
126 | 133 | * Hooks required to interface with the donation extension (include <donate> on page) |
127 | 134 | * |
128 | 135 | * gwValue supplies the value of the form option, the name that appears on the form |