Class: GoogleCheckout::SendBuyerMessage

Inherits:
OrderCommand show all
Defined in:
lib/google-checkout/command.rb

Overview

Send a message to the buyer associated with an order.

Google will actually send the message to their email address.

Constant Summary

Constants inherited from Command

Command::PRODUCTION_REQUEST_URL, Command::SANDBOX_REQUEST_URL

Instance Attribute Summary

Attributes inherited from OrderCommand

#amount, #google_order_number

Attributes inherited from Command

#currency, #merchant_id, #merchant_key

Instance Method Summary collapse

Methods inherited from Command

#post, #url, x509_store

Constructor Details

#initialize(merchant_id, merchant_key, google_order_number, message) ⇒ SendBuyerMessage

Make a new message to send.

The last argument is the actual message.

Call post on the resulting object to submit it to Google for sending.



242
243
244
245
246
247
# File 'lib/google-checkout/command.rb', line 242

def initialize(merchant_id, merchant_key, google_order_number, message)
  # TODO Raise meaninful error if message is longer than 255 characters
  raise "Google won't send anything longer than 255 characters! Sorry!" if message.length > 255
  @message = message
  super(merchant_id, merchant_key, google_order_number)
end

Instance Method Details

#to_xmlObject

:nodoc:



249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/google-checkout/command.rb', line 249

def to_xml # :nodoc:
  xml = Builder::XmlMarkup.new
  xml.instruct!
  @xml = xml.tag!('send-buyer-message', {
    :xmlns => "http://checkout.google.com/schema/2",
    "google-order-number" => @google_order_number
  }) do
    xml.tag!("message", @message)
    xml.tag!("send-email", true)
  end
  @xml
end