2016-06-25 2 views
0

나는 반복 지불을하고있다. 지불이 완료되고 돌아 오는 URL로 돌아온 후, 나는 ipn 응답을 얻지 못하고 있습니다. 반복 지불을위한 코드 :Paypal 샌드 박스 반복 지불 ipn

$query = array(); 
    $query['cmd'] = '_xclick-subscriptions'; 
    $query['upload'] = '1'; 

    $query['business'] = $select_paypal_detail[0]->business_mail; 

    $product = $_POST['package']; 
    //$product_price = $_POST['price']; 
    $product_quantity = $_POST['quantity']; 

    $query['a3'] = $_POST['price']; 
    $query['p3'] = 1; 
    $query['t3'] = 'D'; 
    $query['no_note'] = 1; 

    //$query['amount'] = $_POST['price']; 

    $query['discount_rate'] = $_POST['discount']; 
    $query['item_name'] = $_POST['package']; 

    $query['quantity'] = $_POST['quantity']; 

    $query['currency'] = 'CAD'; 
    $query['instId'] = '211616'; 
    $query['testMode'] = 100; 
    $_SESSION['order_number'] = $order_number; 
    $query['cartId'] = 'Order Number '.$_POST['order_number']; 
    $query['return'] = $select_paypal_detail[0]->return_url; 
    $query['notify_url'] = "http://theelitecoachingacademy.com/?AngellEYE_Paypal_Ipn_For_Wordpress&action=ipn_handler"; 

    // Prepare query string 
    $query_string = http_build_query($query); 

    if($select_paypal_detail[0]->payment_type == 'live'){ 
    ?> 

    <!--/header('Location: https://www.paypal.com/cgi-bin/webscr?' . $query_string); 
    header('Location: https://www.sandbox.paypal.com/cgi-bin/webscr?' . $query_string);--> 

    <script type="text/javascript"> 
       window.location="https://www.paypal.com/cgi-bin/webscr?<? echo $query_string ?>"; 
    </script> 
    <?php } else { ?> 
    <script type="text/javascript"> 
       window.location="https://www.sandbox.paypal.com/cgi-bin/webscr?<? echo $query_string ?>"; 
    </script> 
    <?php 
}?> 
+0

오류를 받으셨습니까? – Sachith

+0

[auth]와 [form_charset]의 응답으로 두 개의 변수 만 표시됩니다. 거래 ID 및 지불 상태를 원합니다. – Rakesh

답변

0

PHP로 리디렉션 할 때 먼저 자바 스크립트를 사용할 필요는 없습니다. 실제 문제의 관점에서

$paypalHost = $select_paypal_detail[0]->payment_type == 'live' ? 'paypal.com' : 'sandbox.paypal.com'; 

$query = array(); 
$query['cmd'] = '_xclick-subscriptions'; 
$query['upload'] = '1'; 

$query['business'] = $select_paypal_detail[0]->business_mail; 

$product = $_POST['package']; 
//$product_price = $_POST['price']; 
$product_quantity = $_POST['quantity']; 

$query['a3'] = $_POST['price']; 
$query['p3'] = 1; 
$query['t3'] = 'D'; 
$query['no_note'] = 1; 

//$query['amount'] = $_POST['price']; 

$query['discount_rate'] = $_POST['discount']; 
$query['item_name'] = $_POST['package']; 

$query['quantity'] = $_POST['quantity']; 

$query['currency'] = 'CAD'; 
$query['instId'] = '211616'; 
$query['testMode'] = 100; 
$_SESSION['order_number'] = $order_number; 
$query['cartId'] = 'Order Number '.$_POST['order_number']; 
$query['return'] = $select_paypal_detail[0]->return_url; 
$query['notify_url'] = "http://theelitecoachingacademy.com/?AngellEYE_Paypal_Ipn_For_Wordpress&action=ipn_handler"; 

header('Location: https://www.' . $paypalHost . '/cgi-bin/webscr?' . http_build_query($query)); 
// usually, it's a good idea to exit after redirecting... in this case, it doesn't matter as the redirect is the last thing 
exit; 

, 나는 business 변수가 실제로 내가 그들을 다른 것으로 기대 때문에 샌드 박스 모드 또는 라이브 모드에 있는지에 따라 올바른 계정을 가리키는되어 있는지 확인합니다. documentation에 언급 된대로 business 변수는 PayPal ID 또는 계정과 연결된 이메일 주소입니다.

모든 것이 정확하다고 확신하는 경우 Paypal의 IPN 시뮬레이터를 사용하여 IPN 처리기를 확인합니다.