Class: Twocheckout::LineItem
- Inherits:
-
HashObject
- Object
- HashObject
- Twocheckout::LineItem
- Defined in:
- lib/twocheckout/lineitem.rb
Instance Method Summary collapse
- #active? ⇒ Boolean
- #refund!(opts) ⇒ Object
- #stop_recurring! ⇒ Object
-
#update_recurring!(opts) ⇒ Object
Provide access to update existing recurring lineitems by allowing to lower the lineitem price and push the recurring billing date forward.
Methods inherited from HashObject
#initialize, #inspect, #method_missing
Constructor Details
This class inherits a constructor from Twocheckout::HashObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Twocheckout::HashObject
Instance Method Details
#active? ⇒ Boolean
9 10 11 |
# File 'lib/twocheckout/lineitem.rb', line 9 def active? self.billing.recurring_status == 'active' end |
#refund!(opts) ⇒ Object
4 5 6 7 |
# File 'lib/twocheckout/lineitem.rb', line 4 def refund!(opts) opts = opts.merge(:lineitem_id => self.lineitem_id) Twocheckout::API.request(:post, 'sales/refund_lineitem', opts) end |
#stop_recurring! ⇒ Object
13 14 15 |
# File 'lib/twocheckout/lineitem.rb', line 13 def stop_recurring! Twocheckout::API.request(:post, 'sales/stop_lineitem_recurring', lineitem_id: self.lineitem_id) end |
#update_recurring!(opts) ⇒ Object
Provide access to update existing recurring lineitems by allowing to lower the lineitem price and push the recurring billing date forward. This call is not currently documented in the 2Checkout API documentation.
POST www.2checkout.com/api/sales/update_lineitem_recurring
Parameters:
-
(required) lineitem_id: lineitem_id
-
(optional) comment: Optional comment added to sale
-
(optional) shift: days to shift next recurring payment forward
-
(optional) price: new recurring price (must be lower than previous price or else call will fail)
The shift and price parameters are optional, but at least one of them must be provided for the call to be valid.
Example Shift Date Next curl -X POST www.2checkout.com/api/sales/update_lineitem_recurring -u \ ‘username:password’ -d ‘lineitem_id=1234567890’ -d ‘shift=7’ -H ‘Accept: application/json’
Example Update Price curl -X POST www.2checkout.com/api/sales/update_lineitem_recurring -u \ ‘username:password’ -d ‘lineitem_id=1234567890’ -d ‘price=1.00’ -H ‘Accept: application/json’
Please note that this method cannot be used on PayPal sales as 2Checkout cannot alter the customer’s billing agreement so this call can only update a recurring lineitem on credit card sales.
45 46 47 48 |
# File 'lib/twocheckout/lineitem.rb', line 45 def update_recurring!(opts) opts = opts.merge(:lineitem_id => self.lineitem_id) Twocheckout::API.request(:post, 'sales/update_lineitem_recurring', opts) end |