Class: Spree::PaypalPlatform::OrderPresenter
- Inherits:
-
Object
- Object
- Spree::PaypalPlatform::OrderPresenter
- Defined in:
- app/presenters/spree/paypal_platform/order_presenter.rb
Overview
Builds a PayPal Orders API create-order payload from a Spree order.
The storefront owns the address: we send purchase_units[].shipping
from order.ship_address and pin it with SET_PROVIDED_ADDRESS so
PayPal does not re-collect it. The amount breakdown sends only
additional_tax_total — sending full tax_total double-counts
included VAT and trips PayPal AMOUNT_MISMATCH.
Constant Summary collapse
- PAYPAL_ITEM_NAME_MAX_LENGTH =
127
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
-
#initialize(order) ⇒ OrderPresenter
constructor
A new instance of OrderPresenter.
-
#to_json(*_args) ⇒ Hash
Body ready for
client.orders.create_order.
Constructor Details
#initialize(order) ⇒ OrderPresenter
Returns a new instance of OrderPresenter.
22 23 24 |
# File 'app/presenters/spree/paypal_platform/order_presenter.rb', line 22 def initialize(order) @order = order end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
26 27 28 |
# File 'app/presenters/spree/paypal_platform/order_presenter.rb', line 26 def order @order end |
Instance Method Details
#to_json(*_args) ⇒ Hash
Returns body ready for client.orders.create_order.
31 32 33 34 35 36 37 38 39 |
# File 'app/presenters/spree/paypal_platform/order_presenter.rb', line 31 def to_json(*_args) { 'body' => PaypalServerSdk::OrderRequest.new( intent: PaypalServerSdk::CheckoutPaymentIntent::CAPTURE, purchase_units: [purchase_unit], payment_source: payment_source ) } end |