checkout.rb 575 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. module ShopifyAPI
  3. class Checkout < Base
  4. self.primary_key = :token
  5. def self.headers
  6. super.merge('X-Shopify-Checkout-Version' => '2016-09-06')
  7. end
  8. def complete
  9. post(:complete)
  10. end
  11. def ready?
  12. return false unless persisted?
  13. reload
  14. [200, 201].include?(ShopifyAPI::Base.connection.response.code.to_i)
  15. end
  16. def payments
  17. Payment.find(:all, params: { checkout_id: id })
  18. end
  19. def shipping_rates
  20. ShippingRate.find(:all, params: { checkout_id: id })
  21. end
  22. end
  23. end