Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orderのようなモデルを引数に取れるようにする #4

Closed
kenchan opened this issue Sep 30, 2014 · 2 comments
Closed

Orderのようなモデルを引数に取れるようにする #4

kenchan opened this issue Sep 30, 2014 · 2 comments

Comments

@kenchan
Copy link
Contributor

kenchan commented Sep 30, 2014

No description provided.

@kenchan
Copy link
Contributor Author

kenchan commented Sep 30, 2014

一つのアイデアとして。

class MyOrder
  attr_reader :amount, :user_id, :user_email, :item_code, :item_name, :order_number
end

class ActiveRecordOrder < AR::Base
  include ActiveMerchant::Epsilon::Transaction

  epsilon_transaction do |order|
    amount order.amount
    user_id order.user.id
    user_email order.user.email
    item_code order.line_items.first.id
    item_name order.line_items.first.name
    order_number order.id
  end
end

gateway.purchase(my_order_instance, creadit_card)
gateway.purchase(active_record_order_instance, creadit_card)

@kenchan
Copy link
Contributor Author

kenchan commented Sep 30, 2014

class ActiveRecordOrder < AR::Base
  include ActiveMerchant::Epsilon::Transaction

  epsilon_transaction_amount :amount
  epsilon_transaction_user_id -> {|o| o.user.id }
  ...
end

gateway.purchase(active_record_order_instance, creadit_card)

@kenchan kenchan closed this as completed Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant