Class: PayPal::OrdersResource
- Defined in:
- lib/pay_pal/resources/orders.rb
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #authorize(id:) ⇒ Object
- #capture(id:) ⇒ Object
- #create(intent:, units:, **params) ⇒ Object
- #create_payment(intent:, description:, currency:, value:, **params) ⇒ Object
- #create_single(intent:, title:, description:, currency:, value:, **params) ⇒ Object
- #retrieve(id:) ⇒ Object
Methods inherited from Resource
Constructor Details
This class inherits a constructor from PayPal::Resource
Instance Method Details
#authorize(id:) ⇒ Object
54 55 56 57 |
# File 'lib/pay_pal/resources/orders.rb', line 54 def (id:) response = post_request("v2/checkout/orders/#{id}/authorize", body: {}) Order.new(response.body) end |
#capture(id:) ⇒ Object
59 60 61 62 |
# File 'lib/pay_pal/resources/orders.rb', line 59 def capture(id:) response = post_request("v2/checkout/orders/#{id}/capture", body: {}) Order.new(response.body) end |
#create(intent:, units:, **params) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/pay_pal/resources/orders.rb', line 9 def create(intent:, units:, **params) attributes = {intent: intent.upcase, purchase_units: units} Order.new post_request("v2/checkout/orders", body: attributes.merge(params), headers: {"Prefer" => "return=representation"} ).body end |
#create_payment(intent:, description:, currency:, value:, **params) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pay_pal/resources/orders.rb', line 17 def create_payment(intent:, description:, currency:, value:, **params) items = [{ description: description, amount: { currency_code: currency, value: value } }] attributes = {intent: intent.upcase, purchase_units: items} Order.new post_request("v2/checkout/orders", body: attributes.merge(params), headers: {"Prefer" => "return=representation"} ).body end |
#create_single(intent:, title:, description:, currency:, value:, **params) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pay_pal/resources/orders.rb', line 32 def create_single(intent:, title:, description:, currency:, value:, **params) items = [{ items: [ {name: title, description: description, quantity: 1, unit_amount: {currency_code: currency, value: value}} ], amount: { currency_code: currency, value: value, breakdown: { item_total: { currency_code: currency, value: value } } } }] attributes = {intent: intent.upcase, purchase_units: items} Order.new post_request("v2/checkout/orders", body: attributes.merge(params), headers: {"Prefer" => "return=representation"} ).body end |