1

ソーシャル ネットワーキング Web サイトに Google Checkout 支払いシステムを統合することを計画しています。アイデアは、メンバーが実際のお金 (ウェブサイトの通貨のようなもの) で「トークン」を購入し、ウェブサイト上の追加コンテンツへのアクセスなどを購入できるというものです。

私がやりたいことは、メンバーがクレジット カードまたはデビット カードで支払うチェックアウト ページに移動する Google チェックアウト ボタンを作成することです。私が望むのは、ローカルデータベースを更新できるように、トークンの購入が成功したかどうか (クレジット/デビットカードが請求された場合) をサーバーに通知する Google Checkout です。

Web サイトは PHP/MySQL でコーディングされています。

ここからサンプル PHP コードをダウンロードしました: code.google.com/p/google-checkout-php-sample-code/wiki/Documentation

Google チェックアウト ボタンの作成方法を知っており、サーバーに responsehandlerdemo.php ファイルを配置しました。これは、Google Checkout が応答を送信することになっているファイルです (もちろん、Google マーチャント アカウントでファイルへのパスを設定しています)。

応答ハンドラ ファイルには、いくつかの case ステートメントを含む switch ブロックがあります。支払いが成功し、ローカル データベースのメンバー アカウントにトークンを追加できることを意味するのはどれですか?

  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;

}

その場合は「CHARGED」だと思いますよね?

2 つ目の質問ですが、Google Checkout からの応答を受け取るには SSL 証明書が必要ですか? これによると私は: groups.google.com/group/google-checkout-api-php/browse_thread/thread/10ce55177281c2b0

しかし、公式ドキュメントのどこにも言及されていません。

ありがとうございました。

4

2 に答える 2

5

これを 6 か月以上前に自分のサイトに統合しました。音量は小さいですが、今のところ問題なく動作しています。


まず気になるのは「CHARGEABLE」。これは、クレジット カードがトランザクションに対して承認されたことを意味しますが、アクションを実行するまで実際に資金が請求されることはありません。請求リクエストを送信するには、CHARGEABLE の下にある 2 行のコメントを外します。「設定」>「設定」でカードを自動的に充電するように設定を変更できますが、2行のコメントを外してオプションを開いたままにしておくこともできます.

「リスク情報通知」を待ち、請求を承認する前にリスクチェックに合格したかどうかを判断したい場合があることに注意してください ($data[$root]['risk-information']['eligible-for-protection'] ['価値'])。ただし、デジタル商品について話しているようですが、チャージバックの可能性は問題にならないかもしれません.

ある時点で、請求する前に、資金を何らかのアカウントにリンクするのに十分な情報がリクエストに含まれていることも確認する必要があると思いますが、これは私の偏執狂かもしれません.


私が使用するもう 1 つの状態は、'charge- amount-notification' です。「CHARGED」を使用する方法がある可能性は十分にありますが、「CHARGED」が実際に請求された金額を提供することはありません。($amount_charged = $data[$root]['総請求額']['VALUE'];)


SSL に関しては、コールバック URL を入力する場所を確認すると、次のように記載されています。ビット SSLv3 または TLS"


あなたのコメントへの回答: 私はこれを「new_order_notification」の下で行いますが、他の場所でできるかどうかはわかりません.

$items = get_arr_result( $data[$root]['shopping-cart']['items']['item'] );
foreach( $item as $item ) {
   if( !isset ( $item['merchant-item-id']['VALUE'] ) ) {
     //エラー
     戻る;
   }
   $request_item_id = $item['merchant-item-id']['VALUE'];
   //さらに処理するために、アイテム ID を対応する Google 注文 ID とともに保存します
}
于 2009-08-03T02:36:40.697 に答える
1

はい、Google Checkout の注文で最初に確認する必要があるのは「Chargeable」です。[ Chargeable ] をクリックすると、注文に実際に請求するためのウィンドウがポップアップしますが、実際に注文に請求する前に、[ Eligible for Protection] が True であることを確認してください。これにより、お支払いが Google の支払い保証の対象となります。実際には、Google Checkout の [Buyer Credit Verification] セクションで確認できます。

于 2010-11-19T06:36:24.630 に答える