Module: PurchaseKit::PaywallHelper
- Defined in:
- app/helpers/purchase_kit/paywall_helper.rb
Instance Method Summary collapse
-
#purchasekit_paywall(customer_id:, success_path: main_app.root_path, **options) {|PaywallBuilder| ... } ⇒ Object
Renders a paywall form that triggers native in-app purchases.
Instance Method Details
#purchasekit_paywall(customer_id:, success_path: main_app.root_path, **options) {|PaywallBuilder| ... } ⇒ Object
Renders a paywall form that triggers native in-app purchases
Example (with Pay):
<% pay_customer = current_user.set_payment_processor(:purchasekit) %>
<%= purchasekit_paywall customer_id: pay_customer.id, success_path: dashboard_path do |paywall| %>
<%= paywall.plan_option product: @annual, selected: true do %>
Annual - <%= paywall.price %>
<% end %>
<%= paywall.submit "Subscribe" %>
<% end %>
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/purchase_kit/paywall_helper.rb', line 20 def purchasekit_paywall(customer_id:, success_path: main_app.root_path, **) raise ArgumentError, "customer_id is required" if customer_id.blank? builder = PaywallBuilder.new(self) form_data = (.delete(:data) || {}).merge( controller: "purchasekit--paywall", purchasekit__paywall_customer_id_value: customer_id ) form_with(url: purchase_kit.purchases_path, id: "purchasekit_paywall", data: form_data, **) do |form| hidden = hidden_field_tag(:customer_id, customer_id) hidden += hidden_field_tag(:success_path, success_path) hidden += hidden_field_tag(:environment, "sandbox", data: {purchasekit__paywall_target: "environment"}) hidden + capture { yield builder } end end |