Hallo,
Ich versuche einen Script zu modifizieren um monatliche Spenden über PayPal abzuwickeln. Leider kriege ich es nicht hin den Script über den Sandbox testen zu können.
Nach Rücksprache mit PayPal, liegt das Problem daran, dass meinem Script nicht auf den Sandbox sondern auf den normal PayPal-Portal weiterleitet. Beim PP Tech-Support habe ich die geniale Antwort bekommen "Leider weiss ich auch nicht, warum die Weiterleitung auf die Sandbox Testumgebung nicht erfolgt. Ihrem Code zu entnehmen, scheint alles richtig zu sein $paypal["url"] = "https://www.sandbox.paypal.com/cgi-bin/webscr";"
Und hier nun der Script (verkürzt - ich hoffe ich habe nichts wichtiges gelöscht):
Millionen Dank!
Ich versuche einen Script zu modifizieren um monatliche Spenden über PayPal abzuwickeln. Leider kriege ich es nicht hin den Script über den Sandbox testen zu können.
Nach Rücksprache mit PayPal, liegt das Problem daran, dass meinem Script nicht auf den Sandbox sondern auf den normal PayPal-Portal weiterleitet. Beim PP Tech-Support habe ich die geniale Antwort bekommen "Leider weiss ich auch nicht, warum die Weiterleitung auf die Sandbox Testumgebung nicht erfolgt. Ihrem Code zu entnehmen, scheint alles richtig zu sein $paypal["url"] = "https://www.sandbox.paypal.com/cgi-bin/webscr";"
Und hier nun der Script (verkürzt - ich hoffe ich habe nichts wichtiges gelöscht):
PHP-Code:
<?php
require_once('class.paypal.php');
$p = new paypal_class();
$cmd = "xclick-subscriptions";
$paypal["url"] = "https://www.sandbox.paypal.com/cgi-bin/webscr";
$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$p->add_field('business','seller_1317109593_biz@variation-design.de');
if (!empty($_REQUEST['formSubmit'])) $_GET['action'] = 'process';
if(!empty($_GET['payment_status'])) $_GET['action'] = 'success';
switch ($_GET['action']) {
case 'process':
$p->add_field('item_name', 'TeachBeyond Online Donation');
$p->add_field('amount', str_replace('$','',$_REQUEST['value']));
$p->add_field('first_name',$_REQUEST['name']);
$p->add_field('last_name','');
$p->add_field('address1',$_REQUEST['address']);
$p->add_field('address2',$_REQUEST['address2']);
$p->add_field('city',$_REQUEST['city']);
$p->add_field('state',$_REQUEST['state']);
$p->add_field('zip',$_REQUEST['zip_code']);
$p->add_field('email',$_REQUEST['email']);
$p->add_field('telephone',$_REQUEST['telephone']);
$p->add_field('return', $this_script.'?action=success');
$p->add_field('cancel_return', $this_script.'?action=cancel');
$p->add_field('notify_url', $this_script.'?action=ipn');
$p->add_field('cpp_headerback_color','FFFFFF');
$p->add_field('cpp_headerborder_color','FFFFFF');
$p->add_field('cpp_payflow_color','FFFFFF');
$p-
/*
===============================================
! Do not change/delete these variables ===============================================
*/
$p->add_field('on0',$_REQUEST['on0']);
$p->add_field('os0',$_REQUEST['os0']);
$p->add_field('cs','1');
$p->add_field('address_override','1');
$send_email_to = 'seller_1317109593_biz@variation-design.de';
$send_email_from = 'seller_1317109593_biz@variation-design.de';
$email_subject_line = 'TeachBeyond Online Monthly Donation Form';
$message = 'The online monthly donation form has been submitted
for a US donation. Please verify that payment has been completed by
checking your paypal account.'."\r\n\r\n"
."Their information is listed below.\r\n\r\n";
$headers = 'From: TeachBeyond<'.$send_email_from.'>' . "\r\n" .
'Reply-To: '.$send_email_from.'' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// ! Nothing else should need to be adjusted to send a successful email.
$used = 0;
foreach($_REQUEST as $k=>$v):
if(in_array($k,array('on0','os0','value','formSubmit')) || $v == ''){
continue;
}
if($k == 'designated' || $k == 'designated_other'){
$val .= "\r\nI would like my donation to go towards: ".stripslashes($v)."\r\n";
}elseif(in_array($k,array('other_1','other_2','other_3','other_4','other_5','other_6'))){
$val .= "\r\nSaid Yes To: ".stripslashes($v)."\r\n";
}elseif(!strstr($k, 'memory')){
$val .= ucwords(str_replace('_',' ',$k)).": ".stripslashes($v)."\r\n";
}
endforeach;
$message = $message.$val;
mail($send_email_to,$email_subject_line,$message,$headers);
echo $p->submit_paypal_post();
exit;
break;
case 'success':
exit;
break;
case 'cancel':
header('location: http://www.teachbeyond.org/index.php?option=com_content&view=article&id=77');
exit;
break;
case 'ipn':
if ($p->validate_ipn()) {
var $send_email_to, $email_subject_line, $message, $headers
$send_email_to = 'seller_1317109593_biz@variation-design.de';
$send_email_from = 'seller_1317109593_biz@variation-design.de';
$email_subject_line = 'TeachBeyond Online Donation - PayPal Notification - Received Payment';
$message = "An instant payment notification was successfully received\n"
."from ".$p->ipn_data['payer_email']." on ".date('r')
." at ".date('g:i A')."\n\nDetails:\n";
$headers = 'From: TeachBeyond<'.$send_email_from.'>' . "\r\n" .
'Reply-To: '.$send_email_from.'' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$overlook_keys = array('on0','os0','value','formSubmit');
foreach($p->ipn_data as $k=>$v):
if(in_array($k,$overlook_keys) || $v == ''){
continue;
}
if($k == 'designated' || $k == 'designated_other'){
$val .= "\r\nI would like my donation to go towards: ".stripslashes($v)."\r\n";
}elseif(in_array($k,array('other_1','other_2','other_3','other_4','other_5','other_6'))){
$val .= "\r\nSaid Yes To: ".stripslashes($v)."\r\n";
}elseif(!strstr($k, 'memory')){
$val .= ucwords(str_replace('_',' ',$k)).": ".stripslashes($v)."\r\n";
}
endforeach;
$message = $message.$val;
mail($send_email_to, $email_subject_line,$message,$headers);
}
exit;
break;
}
?>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js" type="text/javascript"></script>
<script src="js/validation/validation.js" type="text/javascript"></script>
<link href="js/validation/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="blog" style="width:95%">
<form action="http://<?php echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?action=process';?>" method="get" id="donateForm">
<fieldset><legend>Address</legend>
<p><label for="name">Name: </label><input type="text" name="name" id="name" value="" class="required" /></p>
<fieldset><legend>Monthly Donation Amount</legend>
<p class="no_p_bot">I would like to begin a monthly donation of:</p>
<p><label for="amount_20" class="auto">$20: </label>
<input type="radio" name="amount" id="amount_20" value="20"
onBlur="changeAmount('amount_20'); empty('amount_other');" />
<label for="amount_25" class="auto">$25: </label>
<input type="radio" name="amount" id="amount_25" value="25"
onBlur="changeAmount('amount_25'); empty('amount_other');" />
<p> </p>
<p class="no_p_bot">I would like my donation to go towards: </p><br/>
<p>
<label for="designated_missionary" style="width:190px;">TeachBeyond Missionary: </label>
<input type="text" name="designated_missionary"
id="designated_missionary" value="Missionary Name"
onBlur="changeOption('designated_missionary',true);"
onFocus="setTrue('designated_missionary');" /><br/><br/>
</p>
</fieldset>
<!--
==============================================
! These are overriden using javascript. They do not need to be
changed or deleted.
===============================================
-->
<input type="hidden" name="on0" id="option_name_0" value="I would like my donation to go towards" />
<input type="hidden" name="os0" id="option_value_0" value="" />
<input type="hidden" name="value" id="paypal_amount" value="" />
<input type="hidden" name="action" id="form_action" value="process" />
<input type="submit" name="formSubmit" value="Begin monthly donations" />
<br/>
Thank you for your monthly donation!
</form>
<script type="text/javascript">
/**
====================================================================
! Javascript for the form elements above
====================================================================
**/
function changeOption(ID,other){
if(other){
var a = document.getElementsByName('designated');
for(x = 0;x<a.length;x++){
a[x].checked = false;
}
}else{
document.getElementById('designated_other').value = '';
}
document.getElementById('option_value_0').value = document.getElementById(ID).value;
}
function changeShow(on,ID){
if(on){
document.getElementById(ID).style.display = 'block';
}else{
document.getElementById(ID).style.display = 'none';
}
}
function changeAmount(ID,other){
//console.log('check');
if(other){
var a = document.getElementsByName('amount');
for(x = 0;x<a.length;x++){
a[x].checked = false;
}
}else{
document.getElementById('amount_other').value = '';
}
document.getElementById('paypal_amount').value = document.getElementById(ID).value;
}
function empty(ID){
document.getElementById(ID).value = '';
}
function setTrue(ID){
document.getElementById(ID).checked = true;
}
var valid3 = new Validation('donateForm');
</script>
</div>
</body>
</html>
Kommentar