2012-09-05 5 views
0

좋아, 내가 개발중인 앱에서 지불을 설정하려고하는데, 대화 상자가 작동하고 아이템 구매를 확인했다. 나는 여기에 무슨 일이 일어 났는지 모르지만 기사 후에 기사를 읽었지만 기쁨은 없다. 구매시 mysql 데이터베이스를 업데이트 할 수있는 방법에 대한 정보가 필요합니다. 나는 그 질문이 모호하다는 것을 압니다. 그러나 어떤 지침도 인정 될 것입니다!개발자 응답 - 지불 콜백. PHP - 나를 미치게 만들기

코드가 아래에 있습니다.

if ($request_type == 'payments_get_items') { 
    // Get order info from Pay Dialog's order_info. 
    // Assumes order_info is a JSON encoded string. 
    $order_info = json_decode($request['credits']['order_info'], true); 

    // Get item id. 
    $item_id = $order_info['item_id']; 

    // Simulutates item lookup based on Pay Dialog's order_info. 
    if ($item_id == '10Kremeggs') { 
    $item = array(
     'title' => '10 Kremeggs', 
     'description' => 'Spend Kremeggs in Alien Abduction.', 
     // Price must be denominated in credits. 
     'price' => 5, 
     'image_url' => 'https://afternoon-snow-5267.herokuapp.com/images/bung.png', 
     'product_url' => 'https://afternoon-snow-5267.herokuapp.com/Purchase/10xKremeggs.php' 
    ); 

    // Construct response. 
    $response = array(
        'content' => array(
           0 => $item, 
           ), 
        'method' => $request_type, 
       ); 
    // Response must be JSON encoded. 
    $response = json_encode($response); 
    } 

} else if ($request_type == "payments_status_update") { 
    // Get order details. 
    $order_details = json_decode($request['credits']['order_details'], true); 

    // Determine if this is an earned currency order. 
    $item_data = json_decode($order_details['items'][0]['data'], true); 
    $earned_currency_order = (isset($item_data['modified'])) ? 
          $item_data['modified'] : null; 

    // Get order status. 
    $current_order_status = $order_details['status']; 

    if ($current_order_status == 'placed') { 
    // Fulfill order based on $order_details unless... 

    if ($earned_currency_order) { 
     // Fulfill order based on the information below... 
     // URL to the application's currency webpage. 
     $product = $earned_currency_order['product']; 
     // Title of the application currency webpage. 
     $product_title = $earned_currency_order['product_title']; 
     // Amount of application currency to deposit. 
     $product_amount = $earned_currency_order['product_amount']; 
     // If the order is settled, the developer will receive this 
     // amount of credits as payment. 
     $credits_amount = $earned_currency_order['credits_amount']; 
    } 

    $next_order_status = 'settled'; 

    // Construct response. 
    $response = array(
        'content' => array(
           'status' => $next_order_status, 
           'order_id' => $order_details['order_id'], 
           ), 
        'method' => $request_type, 
       ); 
    // Response must be JSON encoded. 
    $response = json_encode($response); 

    } else if ($current_order_status == 'disputed') { 
    // 1. Track disputed item orders. 
    // 2. Investigate user's dispute and resolve by settling or refunding the order. 
    // 3. Update the order status asychronously using Graph API. 

    } else if ($current_order_status == 'refunded') { 
    // Track refunded item orders initiated by Facebook. No need to respond. 

    } else { 
    // Track other order statuses. 

    } 
} 

은 위 이상 내가 할 수있는 지불을해야 할 것입니다 지불 콜백

<? mysql_query("UPDATE users SET Kremeggs = Kremeggs+10 WHERE Facebook_id = '$PurchaseUpdate'"); 
header ("Location: http://apps.facebook.com/alien_abduction/purchaseComplete.php"); 
?> 
</body> 
</html> 

의 일부입니다.

답변

2

한 파일 (두 번째 코드 샘플)에서 동시에 두 개의 매우 다른 부분을 처리하려고하는 것처럼 들립니다. 게시 한 첫 번째 코드 샘플 (샘플 코드와 비슷 함)은 사용자에게 적절한 장소입니다. mysql 쿼리는 43 행에서 시작하는 블록 (if ($current_order_status == 'placed') {)에 속합니다. 나는 당신이 운동하기 위해 그 세부 사항을 남겨 둘 것이다.

당신이 원하는 (사용자를 확인 페이지로 리디렉션) 후반부에 이 아니라 해당 콜백에 속하지만, 지불 대화 상자가있는 페이지에 속해 있습니다. 거기에서도 샘플 코드를 사용하고 있다면 js_callback 함수에 속합니다. window.location.href='purchase_complete.php'을 시도하십시오 (성공적인 주문 인 ofc에서만 발생합니다).

올바른 방향으로 향하게하는 희망!

+0

나는이 전에 제 1 부분을 밖으로 sussed했지만 당분간 두 번째 비트를 남겨 뒀지 만 이것은 훌륭하고 완벽하게 작동합니다. D – Wibberley1991

0
else if ($request_type == "payments_status_update") {mysql_query("update users_table set payment_column='isok' where kulid like 'getFacebookUserId'");}