Google Checkoutに関するいくつかの質問
-
10-07-2019 - |
質問
Google Checkoutの支払いシステムをソーシャルネットワーキングWebサイトに統合する予定です。アイデアは、メンバーが「トークン」を購入できるということです。リアルマネー(ウェブサイトの通貨のようなもの)で、ウェブサイトなどの追加コンテンツへのアクセスを購入できます。
やりたいことは、メンバーをクレジットカードまたはデビットカードで支払うチェックアウトページに移動するGoogle Checkoutボタンを作成することです。私が欲しいのは、トークンの購入が成功したかどうかをクレジットカードまたはデビットカードに請求した場合にサーバーに通知するGoogle Checkoutで、ローカルデータベースを更新できるようにします。
ウェブサイトは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
しかし、公式ドキュメントのどこにも言及されていません。
ありがとう。
解決
6か月以上前にこれをサイトに統合しました。音量は非常に小さいですが、これまでのところうまく機能しています。
最初に心配する必要があるのは「充電可能」です。これは、取引に対してクレジットカードが承認されていることを意味しますが、実際にアクションを実行するまで資金は請求されません。請求リクエストを送信するには、CHARGEABLEの下の2行のコメントを外します。 「設定」でカードに自動的に請求するように設定を変更することができます&gt; 「プリファレンス」ですが、2行のコメントを外してオプションを開いたままにしておくこともできます。
「リスク情報通知」を待って、請求を承認する前にリスクチェックに合格したかどうかを判断する必要がある場合があることに注意してください($ data [$ root] ['risk-information'] ['eligible-for-保護 '] [' VALUE '])。あなたはデジタル商品について話しているようですが、チャージバックの可能性はあなたにとって重要ではないかもしれません。
ある時点で、請求前に資金を何らかのアカウントにリンクするのに十分な情報がリクエストに含まれていることも確認する必要があると確信していますが、これは単なる私の妄想です。
私が使用しているもう1つの状態は「charge-amount-notification」です。 「CHARGED」を使用する方法があることは完全に可能ですが、「CHARGED」が実際に請求された金額を提供するわけではありません。 ($ amount_charged = $ data [$ root] ['total-charge-amount'] ['VALUE'];)
SSLについては、コールバックURLを入力する場所を確認すると、次のように表示されます。 &quot; GoogleのURLを指定して、新しい注文と注文状態の変更を通知します。 128ビットSSLv3またはTLSを実行しているサーバーのURLを指定する必要があります
コメントへの回答: これは「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 }
他のヒント
はい、&quot;充電可能&quot; Google Checkoutの注文で最初に確認する必要があるものです。 [充電可能]をクリックすると、注文を実際に請求するためのウィンドウがポップアップ表示されますしかし、&quot;保護対象&quot;実際に注文を請求する前の。これにより、支払いがGoogleの支払い保証の対象になります。実際には、「購入者のクレジットの確認」で確認できます。 Google Checkoutのセクション。