לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #1  
ישן 03-12-2009, 23:44
  HaMashiah HaMashiah אינו מחובר  
 
חבר מתאריך: 19.02.05
הודעות: 67
עזרה עם קוד של סליקה באמצעות paypal

היי שלום לכולם
מצאתי קוד מענין לסליקה דרך PAYPAL
יש לי כמה שאלות על קוד זה
1. האם זה מעביר כסף לחשבון שלי ב-PAYPAL ומודיע לאחר מען חזרה לשרת שלי?
2. מה קורה אם המשתמש יוצא מהדפדפן ולא העביר כסף?
3. אם הקוד מבצע סליקה ולאחר מכן שולח תשובה חיובית לשרת שלי איפה אני מציב קוד שישלח קובץ למייל של מי שהעביר לי כסף?
הינה הקוד:
קוד:
001.# Set the Env mode 002.define('DEV', true); 003. 004.# Define your email address here for paypal 005.define('PAYPAL_EMAIL_ADDRESS', 'youremailaddress@here.com'); 006. 007.# Load Paypal class 008.require_once('paypal.class.php'); 009.$paypal = new paypal_class; 010. 011.# Assign the url, Basd on the 'DEV' value set above for development or for production 012.# We use the sandbox for dev and the real IPN url for production 013.$paypal->paypal_url = DEV ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr'; 014. 015.# Assign the current script URL 016.$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; 017. 018.# If no action set , set it to the default process 019.$_GET['action'] = $_GET['action'] ? $_GET['action'] : 'process'; 020. 021.# What do we want to do? 022.switch ($_GET['action']) 023.{ 024. 025.case 'process': 026. 027.// There should be no output at this point. To process the POST data, 028.// the submit_paypal_post() function will output all the HTML tags which 029.// contains a FORM which is submited instantaneously using the BODY onload 030.// attribute. In other words, don't echo or printf anything when you're 031.// going to be calling the submit_paypal_post() function. 032. 033.// This is where you would have your form validation and all that jazz. 034.// You would take your POST vars and load them into the class like below, 035.// only using the POST values instead of constant string expressions. 036. 037.// For example, after ensureing all the POST variables from your custom 038.// order form are valid, you might have: 039.// 040.// $p->add_field('first_name', $_POST['first_name']); 041.// $p->add_field('last_name', $_POST['last_name']); 042. 043.$paypal->add_field('business', PAYPAL_EMAIL_ADDRESS); 044.$paypal->add_field('return', $this_script.'?action=success'); 045.$paypal->add_field('cancel_return', $this_script.'?action=cancel'); 046.$paypal->add_field('notify_url', $this_script.'?action=ipn'); 047.$paypal->add_field('item_name', 'Paypal Test Transaction'); 048.$paypal->add_field('amount', '1.99'); 049. 050.$paypal->submit_paypal_post(); // submit the fields to paypal 051.if(DEV) 052.{ 053.$paypal->dump_fields(); // for debugging, output a table of all the fields 054.} 055.break; 056. 057.case 'success': // Order was successful... 058. 059.// This is where you would probably want to thank the user for their order 060.// or what have you. The order information at this point is in POST 061.// variables. However, you don't want to "process" the order until you 062.// get validation from the IPN. That's where you would have the code to 063.// email an admin, update the database with payment status, activate a 064.// membership, etc. 065. 066.echo "Success 067.<h3>Thank you for your order.</h3> 068."; 069.foreach ($_POST as $key => $value) { echo "$key: $value 070."; } 071.echo ""; 072. 073.// You could also simply re-direct them to another page, or your own 074.// order status page which presents the user with the status of their 075.// order based on a database (which can be modified with the IPN code 076.// below). 077. 078.break; 079. 080.case 'cancel': // Order was canceled... 081. 082.// The order was canceled before being completed. 083. 084.echo "Canceled 085.<h3>The order was canceled.</h3> 086."; 087.echo ""; 088. 089.break; 090. 091.case 'ipn': // Paypal is calling page for IPN validation... 092. 093.// It's important to remember that paypal calling this script. There 094.// is no output here. This is where you validate the IPN data and if it's 095.// valid, update your database to signify that the user has payed. If 096.// you try and use an echo or printf function here it's not going to do you 097.// a bit of good. This is on the "backend". That is why, by default, the 098.// class logs all IPN data to a text file. 099. 100.if ($paypal->validate_ipn()) { 101. 102.// Payment has been recieved and IPN is verified. This is where you 103.// update your database to activate or process the order, or setup 104.// the database with the user's order details, email an administrator, 105.// etc. You can access a slew of information via the ipn_data() array. 106. 107.// Check the paypal documentation for specifics on what information 108.// is available in the IPN POST variables. Basically, all the POST vars 109.// which paypal sends, which we send back for validation, are now stored 110.// in the ipn_data() array. 111. 112.// For this example, we'll just email ourselves ALL the data. 113.$subject = 'Instant Payment Notification - Recieved Payment'; 114.$to = 'YOUR EMAIL ADDRESS HERE'; // your email 115.$body = "An instant payment notification was successfully recieved\n"; 116.$body .= "from ".$paypal->ipn_data['payer_email']." on ".date('m/d/Y'); 117.$body .= " at ".date('g:i A')."\n\nDetails:\n"; 118. 119.foreach ($paypal->ipn_data as $key => $value) { $body .= "\n$key: $value"; } 120.mail($to, $subject, $body); 121.} 122.break; 123.}

תודה לעוזרים
_____________________________________
חתימתכם הוסרה כיוון שלא עמדה בחוקי האתר. לפרטים נוספים לחצו כאן. תוכלו לקבל עזרה להתאמת החתימה לחוקים בפורום חתימות וצלמיות.


נערך לאחרונה ע"י HaMashiah בתאריך 03-12-2009 בשעה 23:47.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #3  
ישן 06-12-2009, 15:09
  vadimg88 vadimg88 אינו מחובר  
 
חבר מתאריך: 29.02.08
הודעות: 24
בתגובה להודעה מספר 1 שנכתבה על ידי HaMashiah שמתחילה ב "עזרה עם קוד של סליקה באמצעות paypal"

1. אתה צריך לשנות את כתובת האימייל אשר מוגדרת בתחילת הקוד (youremailaddress@here.com) וכל התשלום שיחוייב יועבר לחשבון אימייל הזה. במידה והלקוח ביצע את התשלום והכל עבר בהצלחה הוא יועבר לעמוד שאתה מגדיר בפרמטר return שים לב לשורה הזו בקוד:

קוד PHP:
 $paypal->add_field('return'$this_script.'?action=success'); 


2. אם המשתמש יוצא מהדפדפן לא קורה כלום, אם הוא בוחר וללחוץ על כפתור הביטול באתר החיוב של PAYPAL ולא רוצה לחייב את עצמו בכך אז הוא חוזר לעמוד שאתה מגדיר בפרמטר cancel_return שים לב לשורה הבאה בקוד למעלה:

קוד PHP:
 $paypal->add_field('cancel_return'$this_script.'?action=cancel'); 


3. במידה והלקוח חוייב PAYPAL שולחת בקשה לשרת שלך לכתובת שהגדרת שים לב לפרמטר notify_url בקוד ולשורה:

קוד PHP:
 $paypal->add_field('notify_url'$this_script.'?action=ipn'); 


במידה ועקבת אחר ההוראות בקוד למעלה, תוכל לגשת למשתנה $paypal->ipn_data['payer_email'] שהוא בעצם הכתובת אימייל של הלקוח ולשלוח לו אימייל. בעצם זה מה שרואים גם בדוגמא.

נערך לאחרונה ע"י vadimg88 בתאריך 06-12-2009 בשעה 15:12.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 23:23

הדף נוצר ב 0.04 שניות עם 12 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2025 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר