Jump to Page:   1 · 2  |  Next Page
PayPal Country Codes - helper function (PHP)
Options    Options  
zermattchris
Regular Contributor
Posts: 31
Registered: 01-11-2007


zermattchris

Message 1 of 13

Viewed 16,488 times


Hi list!

Just thought I'd post this function here, in case it saves anyone who wants to access the PayPal country codes the pain of typing it all in (as I did :smileysurprised: ). Its in PHP, but should be easy enough to change to whatever flavour language you're using...

---------------------------------------------------


   //------------- Function ----------------
   // @Description:    Find out a country's name from the 2 char ISO country code.
   //                    This is what PayPal requires.
   //-------------------------------------
   function getCountryCodeArray() {
   
      $countriesArray = array();
      
      // A
      $countriesArray['AL'] = 'ALBANIA';
      $countriesArray['DZ'] = 'ALGERIA';
      $countriesArray['AS'] = 'AMERICAN SAMOA';
      $countriesArray['AD'] = 'ANDORRA';
      $countriesArray['AI'] = 'ANGUILLA';
      $countriesArray['AG'] = 'ANTIGUA AND BARBUDA';
      $countriesArray['AR'] = 'ARGENTINA';
      $countriesArray['AM'] = 'ARMENIA';
      $countriesArray['AW'] = 'ARUBA';
      $countriesArray['AU'] = 'AUSTRALIA';
      $countriesArray['AT'] = 'AUSTRIA';
      $countriesArray['AZ'] = 'AZERBAIJAN';
      
      // B
      $countriesArray['BS'] = 'BAHAMAS';
      $countriesArray['BH'] = 'BAHRAIN';
      $countriesArray['BD'] = 'BANGLADESH';
      $countriesArray['BB'] = 'BARBADOS';
      $countriesArray['BY'] = 'BELARUS';
      $countriesArray['BE'] = 'BELGIUM';
      $countriesArray['BZ'] = 'BELIZE';
      $countriesArray['BJ'] = 'BENIN';
      $countriesArray['BM'] = 'BERMUDA';
      $countriesArray['BO'] = 'BOLIVIA';
      $countriesArray['BA'] = 'BOSNIA AND HERZEGOVINA';
      $countriesArray['BW'] = 'BOTSWANA';
      $countriesArray['BR'] = 'BRAZIL';
      $countriesArray['VG'] = 'BRITISH VIRGIN ISLANDS';
      $countriesArray['BN'] = 'BRUNEI';
      $countriesArray['BG'] = 'BULGARIA';
      $countriesArray['BF'] = 'BURKINA FASO';
      
      // C
      $countriesArray['KH'] = 'CAMBODIA';
      $countriesArray['CM'] = 'CAMEROON';
      $countriesArray['CA'] = 'CANADA';
      $countriesArray['CV'] = 'CAPE VERDE';
      $countriesArray['KY'] = 'CAYMAN ISLANDS';
      $countriesArray['CL'] = 'CHILE';
      $countriesArray['CN'] = 'CHINA';
      $countriesArray['CO'] = 'COLOMBIA';
      $countriesArray['CK'] = 'COOK ISLANDS';
      $countriesArray['HR'] = 'CROATIA';
      $countriesArray['CY'] = 'CYPRUS';
      $countriesArray['CZ'] = 'CZECH REPUBLIC';
      
      // D
      $countriesArray['DK'] = 'DENMARK';
      $countriesArray['DJ'] = 'DJIBOUTI';
      $countriesArray['DM'] = 'DOMINICA';
      $countriesArray['DO'] = 'DOMINICAN REPUBLIC';
      
      // E
      $countriesArray['TP'] = 'EAST TIMOR';
      $countriesArray['EG'] = 'EGYPT';
      $countriesArray['SV'] = 'EL SALVADOR';
      $countriesArray['EE'] = 'ESTONIA';
      
      // F
      $countriesArray['FJ'] = 'FIJI';
      $countriesArray['FI'] = 'FINLAND';
      $countriesArray['FR'] = 'FRANCE';
      $countriesArray['GF'] = 'FRENCH GUIANA';
      $countriesArray['PF'] = 'FRENCH POLYNESIA';
      
      // G
      $countriesArray['GA'] = 'GABON';
      $countriesArray['GE'] = 'GEORGIA';
      $countriesArray['DE'] = 'GERMANY';
      $countriesArray['GH'] = 'GHANA';
      $countriesArray['GI'] = 'GIBRALTAR';
      $countriesArray['GR'] = 'GREECE';
      $countriesArray['GD'] = 'GRENADA';
      $countriesArray['GP'] = 'GUADELOUPE';
      $countriesArray['GU'] = 'GUAM';
      $countriesArray['GT'] = 'GUATEMALA';
      $countriesArray['GN'] = 'GUINEA';
      $countriesArray['GY'] = 'GUYANA';
      
      // H
      $countriesArray['HT'] = 'HAITI';
      $countriesArray['HN'] = 'HONDURAS';
      $countriesArray['HK'] = 'HONG KONG';
      $countriesArray['HU'] = 'HUNGARY';
      
      // I
      $countriesArray['IS'] = 'ICELAND';
      $countriesArray['IN'] = 'INDIA';
      $countriesArray['ID'] = 'INDONESIA';
      $countriesArray['IE'] = 'IRELAND';
      $countriesArray['IL'] = 'ISRAEL';
      $countriesArray['IT'] = 'ITALY';
      $countriesArray['CI'] = 'IVORY COAST';
      
      // J
      $countriesArray['JM'] = 'JAMAICA';
      $countriesArray['JP'] = 'JAPAN';
      $countriesArray['JO'] = 'JORDAN';
      
      // K
      $countriesArray['KZ'] = 'KAZAKHSTAN';
      $countriesArray['KE'] = 'KENYA';
      $countriesArray['KW'] = 'KUWAIT';
      
      // L
      $countriesArray['LA'] = 'LAO PEOPLE\'S DEMOCRATIC REPUBLIC';
      $countriesArray['LV'] = 'LATVIA';
      $countriesArray['LB'] = 'LEBANON';
      $countriesArray['LS'] = 'LESOTHO';
      $countriesArray['LT'] = 'LITHUANIA';
      $countriesArray['LU'] = 'LUXEMBOURG';
      
      // M
      $countriesArray['MO'] = 'MACAO';
      $countriesArray['MK'] = 'MACEDONIA';
      $countriesArray['MG'] = 'MADAGASCAR';
      $countriesArray['MY'] = 'MALAYSIA';
      $countriesArray['MV'] = 'MALDIVES';
      $countriesArray['ML'] = 'MALI';
      $countriesArray['MT'] = 'MALTA';
      $countriesArray['MH'] = 'MARSHALL ISLANDS';
      $countriesArray['MQ'] = 'MARTINIQUE';
      $countriesArray['MU'] = 'MAURITIUS';
      $countriesArray['MX'] = 'MEXICO';
      $countriesArray['FM'] = 'MICRONESIA, FEDERATED STATES OF';
      $countriesArray['MD'] = 'MOLDOVA';
      $countriesArray['MN'] = 'MONGOLIA';
      $countriesArray['MS'] = 'MONTSERRAT';
      $countriesArray['MA'] = 'MOROCCO';
      $countriesArray['MZ'] = 'MOZAMBIQUE';
      
      // N
      $countriesArray['NA'] = 'NAMIBIA';
      $countriesArray['NP'] = 'NEPAL';
      $countriesArray['NL'] = 'NETHERLANDS';
      $countriesArray['AN'] = 'NETHERLANDS ANTILLES';
      $countriesArray['NZ'] = 'NEW ZEALAND';
      $countriesArray['NI'] = 'NICARAGUA';
      $countriesArray['MP'] = 'NORTHERN MARIANA ISLANDS';
      $countriesArray['NO'] = 'NORWAY';
      
      // O
      $countriesArray['OM'] = 'OMAN';
      
      // P
      $countriesArray['PK'] = 'PAKISTAN';
      $countriesArray['PW'] = 'PALAU';
      $countriesArray['PS'] = 'PALESTINE';
      $countriesArray['PA'] = 'PANAMA';
      $countriesArray['PG'] = 'PAPUA NEW GUINEA';
      $countriesArray['PY'] = 'PARAGUAY';
      $countriesArray['PE'] = 'PERU';
      $countriesArray['PH'] = 'PHILIPPINES, REPUBLIC OF';
      $countriesArray['PL'] = 'POLAND';
      $countriesArray['PT'] = 'PORTUGAL';
      $countriesArray['PR'] = 'PUERTO RICO';
      
      // Q
      $countriesArray['QA'] = 'QATAR';
      
      // R
      $countriesArray['RO'] = 'ROMANIA';
      $countriesArray['RU'] = 'RUSSIAN FEDERATION';
      $countriesArray['RW'] = 'RWANDA';
      
      // S
      $countriesArray['KN'] = 'SAINT KITTS AND NEVIS';
      $countriesArray['LC'] = 'SAINT LUCIA';
      $countriesArray['VC'] = 'SAINT VINCENT AND THE GRENDINES';
      $countriesArray['WS'] = 'SAMOA';
      $countriesArray['SA'] = 'SAUDI ARABIA';
      $countriesArray['CS'] = 'SERBIA AND MONTENEGRO';
      $countriesArray['SC'] = 'SEYCHELLES';
      $countriesArray['SG'] = 'SINGAPORE';
      $countriesArray['SK'] = 'SLOVAKIA';
      $countriesArray['SI'] = 'SLOVENIA';
      $countriesArray['SB'] = 'SOLOMON ISLANDS';
      $countriesArray['ZA'] = 'SOUTH AFRICA';
      $countriesArray['KR'] = 'SOUTH KOREA';
      $countriesArray['ES'] = 'SPAIN';
      $countriesArray['LK'] = 'SRI LANKA';
      $countriesArray['SZ'] = 'SWAZILAND';
      $countriesArray['SE'] = 'SWEDEN';

      $countriesArray['CH'] = 'SWITZERLAND';
      
      // T
      $countriesArray['TW'] = 'TAIWAN';
      $countriesArray['TZ'] = 'TANZANIA, UNITED REPUBLIC OF';
      $countriesArray['TH'] = 'THAILAND';
      $countriesArray['TG'] = 'TOGO';
      $countriesArray['TO'] = 'TONGA';
      $countriesArray['TT'] = 'TRINIDAD AND TOBAGO';
      $countriesArray['TN'] = 'TUNISIA';
      $countriesArray['TR'] = 'TURKEY';
      $countriesArray['TM'] = 'TURKMENISTAN';
      $countriesArray['TC'] = 'TURKS AND CAICOS ISLANDS';
      
      // U
      $countriesArray['UG'] = 'UGANDA';
      $countriesArray['UA'] = 'UKRAINE';
      $countriesArray['AE'] = 'UNITED ARAB EMIRATES';
      $countriesArray['GB'] = 'UNITED KINGDOM';
      $countriesArray['US'] = 'UNITED STATES OF AMERICA';
      $countriesArray['UY'] = 'URUGUAY';
      $countriesArray['UZ'] = 'UZBEKISTAN';
      
      // V
      $countriesArray['VU'] = 'VANUATU';
      $countriesArray['VE'] = 'VENEZUELA';
      $countriesArray['VN'] = 'VIETNAM';
      $countriesArray['VI'] = 'VIRGIN ISLANDS, U.S.';
      
      // W, X, Y, Z
      $countriesArray['YE'] = 'YEMEN ARAB REPUBLIC';
      $countriesArray['ZM'] = 'ZAMBIA';
      
      return $countriesArray;
   }
      
1
Kudos!
06-15-2007 03:23 AM  
Re: PayPal Country Codes - helper function (PHP)
Options    Options  
zermattchris
Regular Contributor
Posts: 31
Registered: 01-11-2007


zermattchris

Message 2 of 13

Viewed 16,484 times


FYI:
I've taken these country codes from the PayPal documentation.
-Chris

(PP_WebsitePaymentsPro_IntegrationGuide.pdf).
Kudos!
06-15-2007 03:50 AM  
Re: PayPal Country Codes - helper function (PHP)   [ Edited ]
Options    Options  
prat
Visitor
Posts: 1
Registered: 06-25-2007


prat

Message 3 of 13

Viewed 16,425 times


Actually, I've been looking all over the documentation for this list, and it's not in the Website Payment Pro Integration guide... although it is referenced (I see a 'See Appendix F, "Country Codes."' on page 69, but the link is broken, and there are no appendices in the document). Very frustrating.

Thank you very much for your table, it's quite helpful!

Message Edited by prat on 06-25-200711:01 AM

Kudos!
06-25-2007 08:41 AM  
Re: PayPal Country Codes - helper function (PHP)
Options    Options  
Barrikor
Contributor
Posts: 16
Registered: 04-23-2008


Barrikor

Message 4 of 13

Viewed 14,445 times


Thanks :smileyhappy:

I just tried using your function on a dropdown country list :smileyhappy:

Here's my code, in case anyone finds it useful:
----------------------------------------------------------------

/*
Your function is somewhere up here, or included
*/




// Make dropdown
$CC = getCountryCodeArray();
echo "<label for=\"CountryDropdown\"> Country: </label>";
echo "<select name=\"CountryDropdown\" id=\"CountryDropdown\">";
echo "<option value=\"\" selected=\"selected\"> &nbsp; </option>";
reset($CC);
while ($Country = current($CC)) // (single "=" sign is on purpose)
    {
    echo "<option value=\"" . key($CC) . "\">" . $Country . "</option>";
    next($CC);
    }
echo "</select>";


--------------------------------------------------------------------------

Ex: if they select the country "ALBANIA" the form will submit the countrycode "AL"

The dropdown is all in caps though :smileyhappy:

 

_______________________________
- Barrikor
Kudos!
05-31-2008 09:41 PM  
Re: PayPal Country Codes - helper function (PHP)
Options    Options  
neona
Regular Visitor
Posts: 11
Registered: 09-01-2008


neona

Message 5 of 13

Viewed 12,174 times


This is really useful :smileyhappy: Just one question if i may, for a php numpty like myself how do you combine them together in the existing payflow_EC.php file form?

 

I did what i though was right but just get the code outputting to the browser where i want the dropdown to be :s 

 

Cheers in advance :smileyhappy:

David 

Kudos!
10-02-2008 11:56 AM  
Re: PayPal Country Codes - helper function (PHP)
Options    Options  
zermattchris
Regular Contributor
Posts: 31
Registered: 01-11-2007


zermattchris

Message 6 of 13

Viewed 12,168 times


Hi David,

 

Below is a quick and dirty full example (ie it works, but you shouldn't use it directly in your projects) of using a couple of php functions to display a Countries drop menu.

 

This is only meant to be a starting point for you -- if you're going to be using php, you really need to look very carefully into things like input/output filtering (important!) and moving your php code off of the public path...

 

Best of luck! :smileywink:

-Chris

 

PS. I've included a screenshot of what the html page looks like, to give you a better idea of what's going on here.

 

<?php

// Better to put this all into a sep. file and
// include it in your html pages that need to
// display country drop down menus, but this
// should get you started...

//------------- Function ----------------
// @Description: Generates a simple option html
// list of countries.
//-------------------------------------
function displayCountryOptions() {

$html = '';

$countriesList = getCountryCodeArray();
foreach ( $countriesList as $aCountryCode => $aCountryName ) {
$html .= " <option value=\"$aCountryCode\">$aCountryName</option> \n";
}

return $html;

}


//------------- Function ----------------
// @Description: Find out a country's name from the
// 2 char ISO country code. This is what PayPal requires.
//-------------------------------------
function getCountryCodeArray() {

$countriesArray = array();

// A
$countriesArray['AL'] = 'ALBANIA';
$countriesArray['DZ'] = 'ALGERIA';
$countriesArray['AS'] = 'AMERICAN SAMOA';
$countriesArray['AD'] = 'ANDORRA';
$countriesArray['AI'] = 'ANGUILLA';
$countriesArray['AG'] = 'ANTIGUA AND BARBUDA';
$countriesArray['AR'] = 'ARGENTINA';
$countriesArray['AM'] = 'ARMENIA';
$countriesArray['AW'] = 'ARUBA';
$countriesArray['AU'] = 'AUSTRALIA';
$countriesArray['AT'] = 'AUSTRIA';
$countriesArray['AZ'] = 'AZERBAIJAN';

// B
$countriesArray['BS'] = 'BAHAMAS';
$countriesArray['BH'] = 'BAHRAIN';
$countriesArray['BD'] = 'BANGLADESH';
$countriesArray['BB'] = 'BARBADOS';
$countriesArray['BY'] = 'BELARUS';
$countriesArray['BE'] = 'BELGIUM';
$countriesArray['BZ'] = 'BELIZE';
$countriesArray['BJ'] = 'BENIN';
$countriesArray['BM'] = 'BERMUDA';
$countriesArray['BO'] = 'BOLIVIA';
$countriesArray['BA'] = 'BOSNIA AND HERZEGOVINA';
$countriesArray['BW'] = 'BOTSWANA';
$countriesArray['BR'] = 'BRAZIL';
$countriesArray['VG'] = 'BRITISH VIRGIN ISLANDS';
$countriesArray['BN'] = 'BRUNEI';
$countriesArray['BG'] = 'BULGARIA';
$countriesArray['BF'] = 'BURKINA FASO';

// C
$countriesArray['KH'] = 'CAMBODIA';
$countriesArray['CM'] = 'CAMEROON';
$countriesArray['CA'] = 'CANADA';
$countriesArray['CV'] = 'CAPE VERDE';
$countriesArray['KY'] = 'CAYMAN ISLANDS';
$countriesArray['CL'] = 'CHILE';
$countriesArray['CN'] = 'CHINA';
$countriesArray['CO'] = 'COLOMBIA';
$countriesArray['CK'] = 'COOK ISLANDS';
$countriesArray['HR'] = 'CROATIA';
$countriesArray['CY'] = 'CYPRUS';
$countriesArray['CZ'] = 'CZECH REPUBLIC';

// D
$countriesArray['DK'] = 'DENMARK';
$countriesArray['DJ'] = 'DJIBOUTI';
$countriesArray['DM'] = 'DOMINICA';
$countriesArray['DO'] = 'DOMINICAN REPUBLIC';

// E
$countriesArray['TP'] = 'EAST TIMOR';
$countriesArray['EG'] = 'EGYPT';
$countriesArray['SV'] = 'EL SALVADOR';
$countriesArray['EE'] = 'ESTONIA';

// F
$countriesArray['FJ'] = 'FIJI';
$countriesArray['FI'] = 'FINLAND';
$countriesArray['FR'] = 'FRANCE';
$countriesArray['GF'] = 'FRENCH GUIANA';
$countriesArray['PF'] = 'FRENCH POLYNESIA';

// G
$countriesArray['GA'] = 'GABON';
$countriesArray['GE'] = 'GEORGIA';
$countriesArray['DE'] = 'GERMANY';
$countriesArray['GH'] = 'GHANA';
$countriesArray['GI'] = 'GIBRALTAR';
$countriesArray['GR'] = 'GREECE';
$countriesArray['GD'] = 'GRENADA';
$countriesArray['GP'] = 'GUADELOUPE';
$countriesArray['GU'] = 'GUAM';
$countriesArray['GT'] = 'GUATEMALA';
$countriesArray['GN'] = 'GUINEA';
$countriesArray['GY'] = 'GUYANA';

// H
$countriesArray['HT'] = 'HAITI';
$countriesArray['HN'] = 'HONDURAS';
$countriesArray['HK'] = 'HONG KONG';
$countriesArray['HU'] = 'HUNGARY';

// I
$countriesArray['IS'] = 'ICELAND';
$countriesArray['IN'] = 'INDIA';
$countriesArray['ID'] = 'INDONESIA';
$countriesArray['IE'] = 'IRELAND';
$countriesArray['IL'] = 'ISRAEL';
$countriesArray['IT'] = 'ITALY';
$countriesArray['CI'] = 'IVORY COAST';

// J
$countriesArray['JM'] = 'JAMAICA';
$countriesArray['JP'] = 'JAPAN';
$countriesArray['JO'] = 'JORDAN';

// K
$countriesArray['KZ'] = 'KAZAKHSTAN';
$countriesArray['KE'] = 'KENYA';
$countriesArray['KW'] = 'KUWAIT';

// L
$countriesArray['LA'] = 'LAO PEOPLE\'S DEMOCRATIC REPUBLIC';
$countriesArray['LV'] = 'LATVIA';
$countriesArray['LB'] = 'LEBANON';
$countriesArray['LS'] = 'LESOTHO';
$countriesArray['LT'] = 'LITHUANIA';
$countriesArray['LU'] = 'LUXEMBOURG';

// M
$countriesArray['MO'] = 'MACAO';
$countriesArray['MK'] = 'MACEDONIA';
$countriesArray['MG'] = 'MADAGASCAR';
$countriesArray['MY'] = 'MALAYSIA';
$countriesArray['MV'] = 'MALDIVES';
$countriesArray['ML'] = 'MALI';
$countriesArray['MT'] = 'MALTA';
$countriesArray['MH'] = 'MARSHALL ISLANDS';
$countriesArray['MQ'] = 'MARTINIQUE';
$countriesArray['MU'] = 'MAURITIUS';
$countriesArray['MX'] = 'MEXICO';
$countriesArray['FM'] = 'MICRONESIA, FEDERATED STATES OF';
$countriesArray['MD'] = 'MOLDOVA';
$countriesArray['MN'] = 'MONGOLIA';
$countriesArray['MS'] = 'MONTSERRAT';
$countriesArray['MA'] = 'MOROCCO';
$countriesArray['MZ'] = 'MOZAMBIQUE';

// N
$countriesArray['NA'] = 'NAMIBIA';
$countriesArray['NP'] = 'NEPAL';
$countriesArray['NL'] = 'NETHERLANDS';
$countriesArray['AN'] = 'NETHERLANDS ANTILLES';
$countriesArray['NZ'] = 'NEW ZEALAND';
$countriesArray['NI'] = 'NICARAGUA';
$countriesArray['MP'] = 'NORTHERN MARIANA ISLANDS';
$countriesArray['NO'] = 'NORWAY';

// O
$countriesArray['OM'] = 'OMAN';

// P
$countriesArray['PK'] = 'PAKISTAN';
$countriesArray['PW'] = 'PALAU';
$countriesArray['PS'] = 'PALESTINE';
$countriesArray['PA'] = 'PANAMA';
$countriesArray['PG'] = 'PAPUA NEW GUINEA';
$countriesArray['PY'] = 'PARAGUAY';
$countriesArray['PE'] = 'PERU';
$countriesArray['PH'] = 'PHILIPPINES, REPUBLIC OF';
$countriesArray['PL'] = 'POLAND';
$countriesArray['PT'] = 'PORTUGAL';
$countriesArray['PR'] = 'PUERTO RICO';

// Q
$countriesArray['QA'] = 'QATAR';

// R
$countriesArray['RO'] = 'ROMANIA';
$countriesArray['RU'] = 'RUSSIAN FEDERATION';
$countriesArray['RW'] = 'RWANDA';

// S
$countriesArray['KN'] = 'SAINT KITTS AND NEVIS';
$countriesArray['LC'] = 'SAINT LUCIA';
$countriesArray['VC'] = 'SAINT VINCENT AND THE GRENDINES';
$countriesArray['WS'] = 'SAMOA';
$countriesArray['SA'] = 'SAUDI ARABIA';
$countriesArray['CS'] = 'SERBIA AND MONTENEGRO';
$countriesArray['SC'] = 'SEYCHELLES';
$countriesArray['SG'] = 'SINGAPORE';
$countriesArray['SK'] = 'SLOVAKIA';
$countriesArray['SI'] = 'SLOVENIA';
$countriesArray['SB'] = 'SOLOMON ISLANDS';
$countriesArray['ZA'] = 'SOUTH AFRICA';
$countriesArray['KR'] = 'SOUTH KOREA';
$countriesArray['ES'] = 'SPAIN';
$countriesArray['LK'] = 'SRI LANKA';
$countriesArray['SZ'] = 'SWAZILAND';
$countriesArray['SE'] = 'SWEDEN';

$countriesArray['CH'] = 'SWITZERLAND';

// T
$countriesArray['TW'] = 'TAIWAN';
$countriesArray['TZ'] = 'TANZANIA, UNITED REPUBLIC OF';
$countriesArray['TH'] = 'THAILAND';
$countriesArray['TG'] = 'TOGO';
$countriesArray['TO'] = 'TONGA';
$countriesArray['TT'] = 'TRINIDAD AND TOBAGO';
$countriesArray['TN'] = 'TUNISIA';
$countriesArray['TR'] = 'TURKEY';
$countriesArray['TM'] = 'TURKMENISTAN';
$countriesArray['TC'] = 'TURKS AND CAICOS ISLANDS';

// U
$countriesArray['UG'] = 'UGANDA';
$countriesArray['UA'] = 'UKRAINE';
$countriesArray['AE'] = 'UNITED ARAB EMIRATES';
$countriesArray['GB'] = 'UNITED KINGDOM';
$countriesArray['US'] = 'UNITED STATES OF AMERICA';
$countriesArray['UY'] = 'URUGUAY';
$countriesArray['UZ'] = 'UZBEKISTAN';

// V
$countriesArray['VU'] = 'VANUATU';
$countriesArray['VE'] = 'VENEZUELA';
$countriesArray['VN'] = 'VIETNAM';
$countriesArray['VI'] = 'VIRGIN ISLANDS, U.S.';

// W, X, Y, Z
$countriesArray['YE'] = 'YEMEN ARAB REPUBLIC';
$countriesArray['ZM'] = 'ZAMBIA';

return $countriesArray;
}



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Your Page's Title here</title>
</head>
<body>


your html stuff here...


<form method="post" action="temp.htm">
<div>

<label>Country
<select name="countrymenu" id="countrymenu">
<?php echo displayCountryOptions(); ?>
</select>
</label>

<input type="submit" value="Submit" />

</div>
</form>



<h3>You selected the following country:</h3>
<p>
<?php echo $_POST['countrymenu']; ?>
</p>
<p>
Note: *Never* output unfiltered user data like this! This
is only to give a simple example... YMMV
</p>

</body>
</html>





 

 

 


 

Attachment Countries.jpg (24 kb)

Kudos!
10-02-2008 02:07 PM  
Re: PayPal Country Codes - helper function (PHP)
Options    Options  
neona
Regular Visitor
Posts: 11
Registered: 09-01-2008


neona

Message 7 of 13

Viewed 12,066 times


Hi Chris,

Thank you for your reply, this helps me a great deal :smileyhappy:

 

David 

Kudos!
10-06-2008 04:02 AM  
Re: PayPal Country Codes - helper function (PHP)
Options    Options  
neona
Regular Visitor
Posts: 11
Registered: 09-01-2008


neona

Message 8 of 13

Viewed 12,050 times


This code is really useful, but how would I integrate it with the existing payflow_EC.php code? In the existing file there is quite a bit of php in the function GetDirectPaymentDetails, so my question is how do i include this extra code as either an include or a call on the function?

 

EXISTING CODE 

case 'GetDirectPaymentDetails':

    $amount = $_POST['price1']*$_POST['qty1']+$_POST['price2']*$_POST['qty2']+$_POST['price3']*$_POST['qty3']+$_POST['price4']*$_POST['qty4']+$_POST['price5']*$_POST['qty5']+$_POST['price6']*$_POST['qty6']+$_POST['price7']*$_POST['qty7']+$_POST['price8']*$_POST['qty8']+$_POST['price9']*$_POST['qty9']+$_POST['price10']*$_POST['qty10'];

    // checkout - enter card details and shipping

    echo '

    <form name="checkout" method="post" action="">

    <table width="100%" border="0" cellspacing="0" cellpadding="3">

    <tr><td width="25%">Total:</td><td width="75%"><input type="text" name="amount" value="'.number_format($amount,2).'"> '.$currency.'</td></tr>

    <tr><td>Order Number:</td><td><input type="text" name="order_num" value="'.$order_num.'" maxlength="12" readonly></td></tr>

    <tr><td>Credit Card:</td><td><select name="card">

    <option value="0">Visa</option><option selected="selected" value="1">MasterCard</option></select></td></tr>

    <tr><td>Card Number:</td><td><input type="text" name="card_num" value="0000000000000000" maxlength="100"></td></tr>

    <tr><td>Expiry Date:</td><td><select name="mm">

    <option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option>

    <option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option>

    <option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12" selected>12</option>

    </select><select name="yy">

    <option value="'.(date('Y')).'">'.(date('Y')).'</option><option value="'.(date('Y')+1).'">'.(date('Y')+1).'</option>

    <option value="'.(date('Y')+2).'" selected>'.(date('Y')+2).'</option><option value="'.(date('Y')+3).'">'.(date('Y')+3).'</option>

    <option value="'.(date('Y')+4).'">'.(date('Y')+4).'</option><option value="'.(date('Y')+5).'">'.(date('Y')+5).'</option>

    </select></td></tr>

    <tr><td>Card Verification Number:</td><td><input type="text" name="cvv2" value="000" maxlength="35"></td></tr>

    <tr><td>Card Start:</td><td><input type="text" name="cardstart" value="" maxlength="4"></td></tr>

    <tr><td>Card Issue:</td><td><input type="text" name="cardissue" value="" maxlength="2"></td></tr>

    <tr><td></td><td><strong>NOTE: For a Switch or Solo transaction to be approved,<br> either Card Start or Card Issue must be present.</strong></td></tr>

    <tr><td>First Name:</td><td><input type="text" name="fname" value="'.$fname.'" maxlength="35"></td></tr>

    <tr><td>Last Name:</td><td><input type="text" name="lname" value="'.$lname.'" maxlength="35"></td></tr>

    <tr><td>Street:</td><td><input type="text" name="street" value="'.$addr1.'" maxlength="100"></td></tr>

    <tr><td>City/Town:</td><td><input type="text"name="city" value="'.$addr2.'" maxlength="35"></td></tr>

    <><td>State/County:</td><td><input type="text" name="state" value="'.$addr3.'" maxlength="35"></td></tr>

    <tr><td>Postcode:</td><td><input type="text" name="zip" value="'.$addr4.'" maxlength="18"></td></tr>

************************************************************************************

<tr style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:0.8em;"><td>Country:</td><td><select name="country" value="'.$country.'">THIS IS WHERE I WOULD LIKE THE OPTION LIST TO OUTPUT</select></td></tr>

************************************************************************************

    <tr ><td>Notification E-mail:</td><td><input type="text" name="email" value="'.$email.'" maxlength="150"></td></tr>

    <tr><td><input type="hidden" name="currency" value="'.$currency.'"><input type="hidden" name="x" value="DoDirectPayment"></td>

    <td><input type="submit" value=" Pay "></td></tr>

    </table>

 

    </form>';

break;

 

 I would prefer to do this function as an include if possible by saving the Country list to a seperate php file.

 

Cheers in advance.

David 

Kudos!
10-06-2008 09:33 AM  
Re: PayPal Country Codes - helper function (PHP)
Options    Options  
zermattchris
Regular Contributor
Posts: 31
Registered: 01-11-2007


zermattchris

Message 9 of 13

Viewed 12,044 times


You should be able to just do this:

 

 

<tr style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:0.8em;">

    <td>Country:</td>

    <td>

        <select name="country" value="'.$country.'">

            THIS IS WHERE I WOULD LIKE THE OPTION LIST TO OUTPUT

            ' . echo displayCountryOptions() . '

         </select>

    </td>

</tr>

 

Assuming of course you have the other php code available somewhere.

 

-Chris

 

Kudos!
10-06-2008 09:45 AM  
Re: PayPal Country Codes - helper function (PHP)
Options    Options  
neona
Regular Visitor
Posts: 11
Registered: 09-01-2008


neona

Message 10 of 13

Viewed 12,041 times


Hi Chris, thank you for coming back so quickly :smileyhappy:. I added your previous function to the end of the existing code, but i can only believe i have done this incorrectly, my stupidity where it comes to php sometimes frustrates me!

 

Parse error: syntax error, unexpected T_ECHO in /homepages/42/d237180043/htdocs/secure/payflow_EC.php on line 463

 

Should i just close the existing <?php ?> then open a new set in the same file?

 

David 

 

Kudos!
10-06-2008 10:02 AM  
Jump to Page:   1 · 2  |  Next Page
Copyright © PayPal. All Rights Reserved. By using this site, you agree to be bound by PayPal's Legal Disclaimer, User Agreement, and Privacy Policy. This site is subject to change without notice. All other products and company names are trademarks of their respective corporations.