Sha256: e80333f9118ccac82eb81457e2f331b6c51df90c7544c0daff6f757d75ab9a84

Contents?: true

Size: 751 Bytes

Versions: 4

Compression:

Stored size: 751 Bytes

Contents

# frozen_string_literal: true

# Flow.io (2017)
# communicates with flow api to synchronize Spree order with PayPal

module Flow::PayPal
  extend self

  def get_id(order)
    raise 'PayPal only supported while using flow' unless order.flow_order

    # get PayPal ID using Flow api
    body = {
      # discriminator: 'merchant_of_record_payment_form',
      method: 'paypal',
      order_number: order.number,
      amount: order.flow_order.total.amount,
      currency: order.flow_order.total.currency
    }

    # FlowcommerceSpree::Api.run :post, '/:organization/payments', {}, body
    form = ::Io::Flow::V0::Models::MerchantOfRecordPaymentForm.new body
    FlowcommerceSpree.client.payments.post FlowcommerceSpree::ORGANIZATION, form
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flowcommerce_spree-0.0.4 lib/flow/pay_pal.rb
flowcommerce_spree-0.0.3 lib/flow/pay_pal.rb
flowcommerce_spree-0.0.2 lib/flow/pay_pal.rb
flowcommerce_spree-0.0.1 lib/flow/pay_pal.rb