Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do I configure a webservice to receive and parse Notification Callbacks?


veryge.com

Recommended Posts

Question

How do I configure a webservice to receive and parse Notification Callbacks?

 

Answer

 

Setup your server to receive XML messages from Google Checkout

Respond to the notification

Access the raw POST data and parse the XML message

Update your system as needed

 

Discussion

1. Setup your server to receive XML messages from Google Checkout

Setup your server

To receive notifications and other callbacks from Google Checkout, you must do the following:

 

Specify a callback URL. For the sandbox testing server, you can specify either an HTTP or an HTTPS callback URL. For the production server you must specify an HTTPS callback URL secured by SSL v3 or TLS using a valid certificate from a major Certifying Authority.

Only accept messages that are authenticated by HTTP Basic Authentication, using your Merchant ID and Merchant Key as the username and password.

Validating with HTTP Basic Authentication will prevent just anyone from posting notification messages to your server. Additionally,we strongly recommend you validate (both syntactically and semantically) the messages that are sent to your callback URL before processing them.

 

Setup your Notification Callback URL

Google Checkout sends notifications to your notification callback URL, which you set on the Settings: Integration Center page of the Merchant Center. Google Checkout sends all notifications to you as raw POST data, not as name/value pairs.

 

If Google Checkout contacts your notification callback URL and receives a 200 OK status code, Google Checkout assumes the notification has been successfully sent. (As long as your callback URL is a valid web page, your server will return 200 OK, so you can safely ignore notifications you're not interested in.)

 

2. Respond to the notification

When you receive a notification from Google Checkout, you should reply via HTTP response with a notification-acknowledgment message. If the notification is not successfully sent, Google Checkout will try to send the message again multiple times. For more information, see Notification API Overview.

 

Example of notification acknowledgment message:

 

<?xml version="1.0" encoding="UTF-8"?>

<notification-acknowledgment xmlns="http://checkout.google.com/schema/2"/>

 

3. Access the raw POST data and parse the XML message

Once you or the buyer performs an act that initiates a notification message, the Google Checkout server will post the relevant notification message to your server. The technique for reading the notification as raw POST data varies depending on your server's platform; for example, if you're coding in PHP, use the $HTTP_RAW_POST_DATA variable to access the XML string. Other platforms may require that you convert the binary raw POST data into a string as in the case with ASP.

 

You can parse your XML response by loading the string obtained from your raw POST data into an object oriented (DOM) XML parser, or an event driven (SAX) XML parser.

 

The following is a sample DOM callback response script written in pseudocode, it handles both Notification and Merchant Calculation callbacks:

 

Obtain the XML STRING from your RAW POST DATA

If your RAW POST DATA is in binary

Then Convert the RAW POST DATA into a string

Load the RAW POST DATA into an XML OBJECT

Obtain the ROOT ELEMENT of the XML OBJECT

Obtain the TAG NAME of the ROOT ELEMENT

 

 

If the TAG NAME is "request-received"

Then Process Request Received with XML OBJECT

If the TAG NAME is "error"

Then Process Error with XML OBJECT

If the TAG NAME is "diagnosis"

Then Process Diagnosis with XML OBJECT

If the TAG NAME is "merchant-calculation-callback"

Then Process Merchant Calculation Callback with XML OBJECT

If the TAG NAME is "new-order-notification"

Then Process New Order Notification with XML OBJECT

If the TAG NAME is "order-state-change-notification"

Then Process Order State Change Notification with XML OBJECT

If the TAG NAME is "charge-amount-notification"

Then Process Charge Amount Notification with XML OBJECT

If the TAG NAME is "chargeback-amount-notification"

Then Process Chargeback Amount Notification with XML OBJECT

If the TAG NAME is "refund-amount-notification"

Then Process Refund Amount Notification with XML OBJECT

If the TAG NAME is "risk-information-notification"

Then Process Risk Information Notification with XML OBJECT

 

 

See the Google Checkout API sample code for specific examples in our supported languages

 

4. Update your system as needed

Having accessed and parsed the notification message, you can process the response and update your system as needed. For example, you may want to log new order notifications or evaluate a customer's credibility using the risk information notification.

 

veryge

Link to comment
Share on other sites

Question

How do I configure a webservice to receive and parse Notification Callbacks?

 

Answer

 

Setup your server to receive XML messages from Google Checkout

Respond to the notification

Access the raw POST data and parse the XML message

Update your system as needed

 

Discussion

1. Setup your server to receive XML messages from Google Checkout

Setup your server

To receive notifications and other callbacks from Google Checkout, you must do the following:

 

Specify a callback URL. For the sandbox testing server, you can specify either an HTTP or an HTTPS callback URL. For the production server you must specify an HTTPS callback URL secured by SSL v3 or TLS using a valid certificate from a major Certifying Authority.

Only accept messages that are authenticated by HTTP Basic Authentication, using your Merchant ID and Merchant Key as the username and password.

Validating with HTTP Basic Authentication will prevent just anyone from posting notification messages to your server. Additionally,we strongly recommend you validate (both syntactically and semantically) the messages that are sent to your callback URL before processing them.

 

Setup your Notification Callback URL

Google Checkout sends notifications to your notification callback URL, which you set on the Settings: Integration Center page of the Merchant Center. Google Checkout sends all notifications to you as raw POST data, not as name/value pairs.

 

If Google Checkout contacts your notification callback URL and receives a 200 OK status code, Google Checkout assumes the notification has been successfully sent. (As long as your callback URL is a valid web page, your server will return 200 OK, so you can safely ignore notifications you're not interested in.)

 

2. Respond to the notification

When you receive a notification from Google Checkout, you should reply via HTTP response with a notification-acknowledgment message. If the notification is not successfully sent, Google Checkout will try to send the message again multiple times. For more information, see Notification API Overview.

 

Example of notification acknowledgment message:

 

<?xml version="1.0" encoding="UTF-8"?>

<notification-acknowledgment xmlns="http://checkout.google.com/schema/2"/>

 

3. Access the raw POST data and parse the XML message

Once you or the buyer performs an act that initiates a notification message, the Google Checkout server will post the relevant notification message to your server. The technique for reading the notification as raw POST data varies depending on your server's platform; for example, if you're coding in PHP, use the $HTTP_RAW_POST_DATA variable to access the XML string. Other platforms may require that you convert the binary raw POST data into a string as in the case with ASP.

 

You can parse your XML response by loading the string obtained from your raw POST data into an object oriented (DOM) XML parser, or an event driven (SAX) XML parser.

 

The following is a sample DOM callback response script written in pseudocode, it handles both Notification and Merchant Calculation callbacks:

 

Obtain the XML STRING from your RAW POST DATA

If your RAW POST DATA is in binary

Then Convert the RAW POST DATA into a string

Load the RAW POST DATA into an XML OBJECT

Obtain the ROOT ELEMENT of the XML OBJECT

Obtain the TAG NAME of the ROOT ELEMENT

If the TAG NAME is "request-received"

Then Process Request Received with XML OBJECT

If the TAG NAME is "error"

Then Process Error with XML OBJECT

If the TAG NAME is "diagnosis"

Then Process Diagnosis with XML OBJECT

If the TAG NAME is "merchant-calculation-callback"

Then Process Merchant Calculation Callback with XML OBJECT

If the TAG NAME is "new-order-notification"

Then Process New Order Notification with XML OBJECT

If the TAG NAME is "order-state-change-notification"

Then Process Order State Change Notification with XML OBJECT

If the TAG NAME is "charge-amount-notification"

Then Process Charge Amount Notification with XML OBJECT

If the TAG NAME is "chargeback-amount-notification"

Then Process Chargeback Amount Notification with XML OBJECT

If the TAG NAME is "refund-amount-notification"

Then Process Refund Amount Notification with XML OBJECT

If the TAG NAME is "risk-information-notification"

Then Process Risk Information Notification with XML OBJECT

 

 

See the Google Checkout API sample code for specific examples in our supported languages

 

4. Update your system as needed

Having accessed and parsed the notification message, you can process the response and update your system as needed. For example, you may want to log new order notifications or evaluate a customer's credibility using the risk information notification.

 

veryge

 

 

It's from google checkout.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...