Skip to content

Instantly share code, notes, and snippets.

View braintreeps's full-sized avatar

Braintree Open Source braintreeps

View GitHub Profile
@braintreeps
braintreeps / gist:1054689
Created June 29, 2011 19:27
Billing Address on Transaction Create
<h1>Payment: $<%= h @amount %></h1>
<%= form_for :transaction,
:params => @result && @result.params[:transaction],
:builder => ApplicationHelper::BraintreeFormBuilder,
:url => Braintree::TransparentRedirect.url,
:html => {:autocomplete => "off"} do |f| -%>
<% if @result && @result.errors -%>
<div style="color: red;">
@braintreeps
braintreeps / tr_javascript.aspx
Created March 1, 2011 17:21
Using javascript to change the field names for transparent redirect
<script type="text/javascript">
// we want to run this code once the browser is ready and has rendered the DOM.
// If you are using a javascript framework like jquery or prototype, you should
// change this to use the framework-specific event callback.
window.onload = function() {
// customerID, ddlCardType, etc are the names of the controls on your page
// the ClientId property will give you the id on the page, name spaced with
// the master page.
document.getElementById("<%= customerID.ClientId %>").setAttribute("name", "credit_card[number]");
document.getElementById("<%= ddlCardType.ClientId %>").setAttribute("name", "credit_card[card_type]");
@braintreeps
braintreeps / BraintreeDropDownList.vb
Created March 1, 2011 15:55
How to subclass a ASP.NET web control to render correctly for transparent redirect.
Public Partial Class WebUserControl1
Inherits System.Web.UI.WebControls.DropDownList
Public Overrides ReadOnly Property UniqueId() As String
Get
Return "credit_card__expiration_month"
End Get
End Property
End Class
#
# Finding active subscriptions from a set of transactions returned from a search.
#
found_transactions = Braintree::Transaction.search do |search|
search.type.is "sale"
search.source.is Braintree::Transaction::Source::Recurring
search.status.is "settled"
search.created_at.between 2.days.ago.utc.beginning_of_day, 2.days.ago.utc.end_of_day
end