3 * Copyright (C) 2010 Google Inc.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 /** This class handles the notification history requests it's instantiated to
21 * create notification history requests.
23 * refer to /demo/basicapiresponsehandlerdemo.php for a API V2.5 example.
25 class GoogleNotificationHistoryRequest
{
34 * @param string $id merchant Id
35 * @param string $key merchant Key
36 * @param string $server_type server environment production or sandbox
38 function GoogleNotificationHistoryRequest($id=null, $key=null, $server_type="sandbox"){
39 require_once('googlerequest.php');
40 $this->merchant_id
= $id;
41 $this->merchant_key
= $key;
42 $this->server_type
= $server_type;
43 $this->schema_url
= "http://checkout.google.com/schema/2";
47 * Send a <notification-history-request> request to Google Checkout
49 * info: {@link http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API_Notification_History_API.html}
51 * @param string $sn serial number
52 * @param string $npt next page token
53 * @param array $orders array of string google order numbers
54 * @param array $nt array of string notification types
55 * @param array $st array of tracking data where tracking code => carrier
56 * @param string @st string of start time in format YYYY-MM-DD[T]HH:MM:SS[Timezone] ie
57 * 2010-05-01T05:00:00Z
58 * @param string @et string of end time in format YYYY-MM-DD[T]HH:MM:SS[Timezone] ie
59 * 2010-05-02T05:00:00Z
61 function SendNotificationHistoryRequest($sn = null, $npt = null, $orders = array(), $nt = array(), $st = null, $et = null){
62 $postargs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
63 $postargs .= "<notification-history-request xmlns=\"".$this->schema_url
."\">";
65 $postargs .= "<serial-number>".$sn."</serial-number>";
66 } elseif(isset($npt)) {
67 $postargs .= "<next-page-token>".$npt."</next-page-token>";
70 if(isset($orders) && count($orders) > 0){
71 $postargs .= "<order-numbers>";
72 foreach ($orders as $order){
73 $postargs .= "<google-order-number>".$order."</google-order-number>";
75 $postargs .= "</order-numbers>";
77 if(isset($nt) && count($nt) > 0){
78 $postargs .= "<notification-types>";
79 foreach ($nt as $notification_type){
80 $postargs .= "<notification-type>".$notification_type."</notification-type";
82 $postargs .= "</notification-types>";
84 if(isset($st) && isset($et)){
85 $postargs .= "<start-time>".$st."</start-time>";
86 $postargs .= "<end-time".$et."</end-time>";
89 $postargs .= "</notification-history-request>";
91 $Grequest = new GoogleRequest($this->merchant_id
, $this->merchant_key
, $this->server_type
);
92 return $Grequest->SendReq($Grequest->GetReportUrl(), $Grequest->GetAuthenticationHeaders(), $postargs);