def build_xml( id, price, options )
      xml = ::Builder::XmlMarkup.new
      xml.GenerateRequest do
        xml.PxPayUserId       ::Pxpay::Base.pxpay_user_id
        xml.PxPayKey          ::Pxpay::Base.pxpay_key
        xml.AmountInput       sprintf("%.2f", price)
        xml.TxnId             id
        xml.TxnType           options[:txn_type]            ? options[:txn_type].to_s.capitalize : "Purchase"
        xml.CurrencyInput     options[:currency_input]      || "NZD"
        xml.MerchantReference options[:merchant_reference]  || options[:reference]       || id.to_s ## Backwards compatibility
        xml.UrlSuccess        options[:url_success]         || ::Pxpay::Base.url_success 
        xml.UrlFail           options[:url_failure]         || ::Pxpay::Base.url_failure
        xml.EmailAddress      options[:email_address]       if options[:email_address]
        xml.TxnData1          options[:txn_data1]           if options[:txn_data1]
        xml.TxnData2          options[:txn_data2]           if options[:txn_data2]
        xml.TxnData3          options[:txn_data3]           if options[:txn_data3]
        xml.TxnData4          options[:txn_data4]           if options[:txn_data4]
        xml.Opt               options[:opt]                 if options[:opt]
        xml.EnableAddBillCard 1                             if options[:token_billing]
        xml.BillingId         options[:billing_id]          if options[:token_billing]
      end
    end
def build_xml( id, price, options )
      xml = ::Builder::XmlMarkup.new
      xml.GenerateRequest do
        xml.PxPayUserId       ::Pxpay::Base.pxpay_user_id
        xml.PxPayKey          ::Pxpay::Base.pxpay_key
        xml.AmountInput       sprintf("%.2f", price)
        xml.TxnId             id
        xml.TxnType           options[:txn_type]            ? options[:txn_type].to_s.capitalize : "Purchase"
        xml.CurrencyInput     options[:currency_input]      || "NZD"
        xml.MerchantReference options[:merchant_reference]  || options[:reference]       || id.to_s ## Backwards compatibility
        xml.UrlSuccess        options[:url_success]         || ::Pxpay::Base.url_success 
        xml.UrlFail           options[:url_failure]         || ::Pxpay::Base.url_failure
        xml.EmailAddress      options[:email_address]       if options[:email_address]
        xml.TxnData1          options[:txn_data1]           if options[:txn_data1]
        xml.TxnData2          options[:txn_data2]           if options[:txn_data2]
        xml.TxnData3          options[:txn_data3]           if options[:txn_data3]
        xml.TxnData4          options[:txn_data4]           if options[:txn_data4]
        xml.Opt               options[:opt]                 if options[:opt]
        xml.EnableAddBillCard 1                             if options[:token_billing]
        xml.BillingId         options[:billing_id]          if options[:token_billing]
      end
    end
Internal method to build the xml to send to Payment Express