문제

소셜 네트워킹 웹 사이트에서 Google Checkout 결제 시스템을 통합 할 계획입니다. 아이디어는 회원들이 실제 돈을 위해 "토큰"을 구입할 수 있다는 것입니다 (웹 사이트 통화의 일종). 그런 다음 웹 사이트에서 추가 컨텐츠에 액세스 할 수 있습니다.

내가 원하는 것은 멤버를 신용 카드 또는 직불 카드로 지불하는 결제 페이지로 멤버를 데려가는 Google Checkout 버튼을 만드는 것입니다. 내가 원하는 것은 Google 체크 아웃이 서버에 알림에 알림을 알리는 것입니다. 토큰 구매가 성공했는지 (신용/직불 카드가 청구 된 경우) 로컬 데이터베이스를 업데이트 할 수 있습니다.

웹 사이트는 PHP/MySQL로 코딩됩니다.

여기에서 샘플 php 코드를 다운로드했습니다 : code.google.com/p/google-checkout-php-sample-code/wiki/documentation

Google Checkout 버튼을 만드는 방법을 알고 있으며 서버에 ResponseHandlerDemo.php 파일도 배치했습니다. 이것은 Google Checkout이 응답을 보내야하는 파일입니다 (물론 Google 판매자 계정에서 파일로의 경로를 설정 함).

이제 응답 핸들러 파일에는 몇 가지 사례 문의 스위치 블록이 있습니다. 결제가 성공적이었고 로컬 데이터베이스의 회원 계정에 토큰을 추가 할 수 있다는 것을 의미합니까?

  switch ($root) {
case "request-received": {
  break;
}
case "error": {
  break;
}
case "diagnosis": {
  break;
}
case "checkout-redirect": {
  break;
}
case "merchant-calculation-callback": {
  // Create the results and send it
  $merchant_calc = new GoogleMerchantCalculations($currency);

  // Loop through the list of address ids from the callback
  $addresses = get_arr_result($data[$root]['calculate']['addresses']['anonymous-address']);
  foreach($addresses as $curr_address) {
    $curr_id = $curr_address['id'];
    $country = $curr_address['country-code']['VALUE'];
    $city = $curr_address['city']['VALUE'];
    $region = $curr_address['region']['VALUE'];
    $postal_code = $curr_address['postal-code']['VALUE'];

    // Loop through each shipping method if merchant-calculated shipping
    // support is to be provided
    if(isset($data[$root]['calculate']['shipping'])) {
      $shipping = get_arr_result($data[$root]['calculate']['shipping']['method']);
      foreach($shipping as $curr_ship) {
        $name = $curr_ship['name'];
        //Compute the price for this shipping method and address id
        $price = 12; // Modify this to get the actual price
        $shippable = "true"; // Modify this as required
        $merchant_result = new GoogleResult($curr_id);
        $merchant_result->SetShippingDetails($name, $price, $shippable);

        if($data[$root]['calculate']['tax']['VALUE'] == "true") {
          //Compute tax for this address id and shipping type
          $amount = 15; // Modify this to the actual tax value
          $merchant_result->SetTaxDetails($amount);
        }

        if(isset($data[$root]['calculate']['merchant-code-strings']
            ['merchant-code-string'])) {
          $codes = get_arr_result($data[$root]['calculate']['merchant-code-strings']
              ['merchant-code-string']);
          foreach($codes as $curr_code) {
            //Update this data as required to set whether the coupon is valid, the code and the amount
            $coupons = new GoogleCoupons("true", $curr_code['code'], 5, "test2");
            $merchant_result->AddCoupons($coupons);
          }
         }
         $merchant_calc->AddResult($merchant_result);
      }
    } else {
      $merchant_result = new GoogleResult($curr_id);
      if($data[$root]['calculate']['tax']['VALUE'] == "true") {
        //Compute tax for this address id and shipping type
        $amount = 15; // Modify this to the actual tax value
        $merchant_result->SetTaxDetails($amount);
      }
      $codes = get_arr_result($data[$root]['calculate']['merchant-code-strings']
          ['merchant-code-string']);
      foreach($codes as $curr_code) {
        //Update this data as required to set whether the coupon is valid, the code and the amount
        $coupons = new GoogleCoupons("true", $curr_code['code'], 5, "test2");
        $merchant_result->AddCoupons($coupons);
      }
      $merchant_calc->AddResult($merchant_result);
    }
  }
  $Gresponse->ProcessMerchantCalculations($merchant_calc);
  break;
}
case "new-order-notification": {
  $Gresponse->SendAck();
  break;
}
case "order-state-change-notification": {
  $Gresponse->SendAck();
  $new_financial_state = $data[$root]['new-financial-order-state']['VALUE'];
  $new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE'];

  switch($new_financial_state) {
    case 'REVIEWING': {
      break;
    }
    case 'CHARGEABLE': {
      //$Grequest->SendProcessOrder($data[$root]['google-order-number']['VALUE']);
      //$Grequest->SendChargeOrder($data[$root]['google-order-number']['VALUE'],'');
      break;
    }
    case 'CHARGING': {
      break;
    }
    case 'CHARGED': {
      break;
    }
    case 'PAYMENT_DECLINED': {
      break;
    }
    case 'CANCELLED': {
      break;
    }
    case 'CANCELLED_BY_GOOGLE': {
      //$Grequest->SendBuyerMessage($data[$root]['google-order-number']['VALUE'],
      //    "Sorry, your order is cancelled by Google", true);
      break;
    }
    default:
      break;
  }

  switch($new_fulfillment_order) {
    case 'NEW': {
      break;
    }
    case 'PROCESSING': {
      break;
    }
    case 'DELIVERED': {
      break;
    }
    case 'WILL_NOT_DELIVER': {
      break;
    }
    default:
      break;
  }
  break;
}
case "charge-amount-notification": {
  //$Grequest->SendDeliverOrder($data[$root]['google-order-number']['VALUE'],
  //    <carrier>, <tracking-number>, <send-email>);
  //$Grequest->SendArchiveOrder($data[$root]['google-order-number']['VALUE'] );
  $Gresponse->SendAck();
  break;
}
case "chargeback-amount-notification": {
  $Gresponse->SendAck();
  break;
}
case "refund-amount-notification": {
  $Gresponse->SendAck();
  break;
}
case "risk-information-notification": {
  $Gresponse->SendAck();
  break;
}
default:
  $Gresponse->SendBadRequestStatus("Invalid or not supported Message");
  break;

}

나는 그 사건이 '충전 된'것이 하나라고 생각합니다. 맞습니까?

두 번째 질문, Google Checkout으로부터 응답을 받으려면 SSL 인증서가 필요합니까? 이에 따르면 : groups.google.com/group/google-checkout-api-php/browse_thread/thread/10ce55177281c2b0

그러나 나는 공식 문서의 어느 곳에서나 언급 된 것을 보지 못한다.

고맙습니다.

도움이 되었습니까?

해결책

6 개월 전에 이것을 내 사이트에 통합했습니다. 볼륨이 매우 적지 만 지금까지 잘 작동합니다.


가장 먼저 걱정해야 할 것은 '청구 가능'입니다. 이는 신용 카드가 거래에 대한 승인을 받았음을 의미하지만 실제로 조치를 취할 때까지 자금을 청구하지는 않습니다. 청구 요청을 보내려면 청구 가능한 두 줄을 사용하지 않도록하십시오. 설정을 변경하여 '설정'> '환경 설정'에서 카드를 자동으로 충전 할 수 있지만 2 줄을 제외하고 옵션을 열어 두는 것뿐만 아니라 옵션을 열 수 있습니다.

'RESP-Information-Notification'을 기다릴 수 있고 청구를 승인하기 전에 위험 점검이 통과되었는지 확인할 수 있습니다 ($ data [$ root] [ 'Risk-Information'] [ ''eligibable-for-protection '] ['값']). 비록 당신이 디지털 상품에 대해 이야기하고있는 것 같습니다. 충전 백의 가능성은 당신에게 중요하지 않을 수 있습니다.

어느 시점에서, 나는 당신이 요청에 자금을 청구하기 전에 자금을 일부 계정에 연결하기에 충분한 정보를 가지고 있는지 확인해야한다고 확신합니다. 그러나 이것은 내 편집증 일 것입니다.


내가 사용하는 다른 상태는 'Charge-Amount-Notification'입니다. '충전'을 사용할 수있는 방법이있을 가능성이 있지만 '충전 된'은 실제로 청구 된 금액을 제공하지 않습니다. ($ aveS_CHARGED = $ data [$ root] [ 'Total-Charge-Amount'] [ 'value'];)


SSL의 경우 콜백 URL을 입력하는 위치를 확인하면 다음이 표시됩니다. "Google의 URL을 지정하여 주문 상태의 새로운 주문 및 변경 사항을 알리십시오. 128-를 실행하는 서버의 URL을 제공해야합니다. 비트 SSLV3 또는 TLS "


귀하의 의견에 대한 답변 : 나는 'New_order_Notification'에 따라이 작업을 수행합니다. 다른 곳에서 할 수 있는지 확실하지 않습니다.

$items = get_arr_result( $data[$root]['shopping-cart']['items']['item'] ); 
foreach( $items as $item ) { 
   if( !isset ( $item['merchant-item-id']['VALUE'] ) ) { 
     //error 
     return; 
   } 
   $request_item_id = $item['merchant-item-id']['VALUE']; 
   //save your item id with corresponding google order id for further processing
}

다른 팁

예, "청구 가능"은 Google 체크 아웃 주문에서 가장 먼저 살펴볼 필요성입니다. "충전 가능"을 클릭하면 실제로 주문을 청구 할 수 있도록 창이 팝업됩니다. 하지만 확인하십시오 "보호 자격 자격"은 사실입니다 실제로 주문을 청구하기 전에. 이를 통해 결제는 Google 지불 보증으로 보장됩니다. 실제로 Google Checkout의 "Buyer Credit Verification"섹션에서 볼 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top