dinesh124
Joined
50 Experience
0 Lessons Completed
0 Questions Solved
Activity
Posted in How do I combine these two buttons
im trying to combine the paypal button and the f.submit button but have no idea How to get there Is there any better suggestion `
<!-- Set up a container element for the button -->
<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=sb¤cy=USD"></script>
<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
// Set up the transaction
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
<%= form.submit %>
my orders controller :::
` def purchases
@orders = Order.all.where(buyer: current_user).order("created_at DESC")
end
def new
@order = Order.new
@listing = Listing.find(params[:listing_id])
end
def create
@order = Order.new(order_params)
@listing = Listing.find(params[:listing_id])
@seller = @listing.user
@order.listing_id = @listing.id
@order.buyer_id = current_user.id
@order.seller_id = @seller.id
respond_to do |format|
if @order.save
format.html { redirect_to root_url, notice: 'Order was successfully created.' }
format.json { render :show, status: :created, location: @order }
else
format.html { render :new }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end
private
def set_order
@order = Order.find(params[:id])
end
def order_params
params.require(:order).permit(:address, :city, :state, :name ,:mobile ,:PinCode , :size)
end
def total
total=order.listing.price.sum
end
end
`