Chapter 31 Building a Shopping Cart



Download 1,54 Mb.
Pdf ko'rish
bet20/24
Sana28.03.2022
Hajmi1,54 Mb.
#514907
1   ...   16   17   18   19   20   21   22   23   24
Bog'liq
9780321833891 ch31 WebEdition unsecured

Implementing Payment 
When the user clicks the Purchase button, you process her payment details using the 
process.php
script. You 
can see the results of a successful payment in Figure 31.10. 
Figure 31.10
This transaction was successful, and the items will now be shipped. 


Chapter 31 Building a Shopping Cart
31-27
The code for 
process.php
can be found in Listing 31.16
Listing 31.16
 
process.php
— Script That Processes the Customer’s Payment and Tells Her the Result 
include ('book_sc_fns.php'); 
// The shopping cart needs sessions, so start one 
session_start(); 
do_html_header('Checkout'); 
$card_type = $_POST['card_type']; 
$card_number = $_POST['card_number']; 
$card_month = $_POST['card_month']; 
$card_year = $_POST['card_year']; 
$card_name = $_POST['card_name']; 
if(($_SESSION['cart']) && ($card_type) && ($card_number) && 
($card_month) && ($card_year) && ($card_name)) { 
//display cart, not allowing changes and without pictures 
display_cart($_SESSION['cart'], false, 0); 
display_shipping(calculate_shipping_cost()); 
if(process_card($_POST)) { 
//empty shopping cart 
session_destroy(); 
echo "
Thank you for shopping with us. Your order has been placed.
"; 
display_button("index.php", "continue-shopping", "Continue Shopping"); 
} else { 
echo "
Could not process your card. Please contact the card
issuer or try again.
"; 
display_button("purchase.php", "back", "Back"); 

} else { 
echo "
You did not fill in all the fields, please try again.

"; 
display_button("purchase.php", "back", "Back"); 

do_html_footer(); 
?> 
You process the user’s card and, if all is successful, destroy her session. 
The card processing function as it is written simply returns 
true
. If you were actually implementing it, you 
would need to perform some validation (checking that the expiry date was valid and the card number well 
formed) and then process the actual payment. 

Download 1,54 Mb.

Do'stlaringiz bilan baham:
1   ...   16   17   18   19   20   21   22   23   24




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish