Class: Workarea::Paypal::ApproveOrder
- Inherits:
-
Object
- Object
- Workarea::Paypal::ApproveOrder
- Defined in:
- app/services/workarea/paypal/approve_order.rb
Instance Method Summary collapse
- #approved? ⇒ Boolean
-
#details ⇒ Object
As of this writing, PayPal only ever allows one purchase unit.
-
#initialize(checkout, paypal_id) ⇒ ApproveOrder
constructor
A new instance of ApproveOrder.
- #paypal_order ⇒ Object
- #perform ⇒ Object
Constructor Details
#initialize(checkout, paypal_id) ⇒ ApproveOrder
7 8 9 10 |
# File 'app/services/workarea/paypal/approve_order.rb', line 7 def initialize(checkout, paypal_id) @checkout = checkout @paypal_id = paypal_id end |
Instance Method Details
#approved? ⇒ Boolean
43 44 45 |
# File 'app/services/workarea/paypal/approve_order.rb', line 43 def approved? status == 'APPROVED' || direct_payment? end |
#details ⇒ Object
As of this writing, PayPal only ever allows one purchase unit.
18 19 20 |
# File 'app/services/workarea/paypal/approve_order.rb', line 18 def details purchase_units.first end |
#paypal_order ⇒ Object
12 13 14 |
# File 'app/services/workarea/paypal/approve_order.rb', line 12 def paypal_order @paypal_order ||= Workarea::Paypal.gateway.get_order(@paypal_id).result end |
#perform ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/workarea/paypal/approve_order.rb', line 22 def perform order.email ||= payer&.email_address set_shipping_address set_shipping_service set_billing_address payment.clear_credit_card payment.set_paypal( direct_payment_details.reverse_merge( paypal_id: @paypal_id, approved: true, #approved? payer_id: payer&.payer_id, details: Paypal.transform_values(paypal_order) ) ) Pricing.perform(order, shippings) payment.adjust_tender_amounts(order.total_price) end |