lib/stripe/customer.rb in stripe-1.44.0 vs lib/stripe/customer.rb in stripe-1.45.0
- old
+ new
@@ -3,9 +3,26 @@
extend Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
include Stripe::APIOperations::Save
extend Stripe::APIOperations::List
+ # Set or replace a customer's default source.
+ def source=(value)
+ super
+
+ # The parent setter will perform certain useful operations like
+ # converting to an APIResource if appropriate.
+ value = self.source
+
+ # Note that source may be a card, but could also be a tokenized card's ID
+ # (which is a string), and so we check its type here.
+ if value.is_a?(APIResource)
+ value.save_with_parent = true
+ end
+
+ value
+ end
+
def add_invoice_item(params, opts={})
opts = @opts.merge(Util.normalize_opts(opts))
InvoiceItem.create(params.merge(:customer => id), opts)
end