I am trying to implement a variable price in the Stripe Checkout UI that will be updated by Pusher.
I begin by assigning the Pusher message to a global variable called price.
<script type="text/javascript">
var pusher = new Pusher('7a5433c6fc39502a4a02');
var channel = pusher.subscribe('the_channel');
var price
channel.bind('the_event', function(data) {
price = data.message
});
</script>
If I assign price to data-amount, I am then confronted with two problems:
1- process-wise, the field would be empty by default, populating only when Pusher sends a message.
2- syntax-wise, the variable currently does not even render the message when pushed
<%= form_tag charges_path, class: 'stripeform' do %>
<script src="http://ift.tt/1doUtf9" class="stripe-button"
data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
data-amount= <%= @price %>
<% end %>
What to do?
Aucun commentaire:
Enregistrer un commentaire