Payment Pay to the merchant there have a custoemr there have a merchant I logged as I pay for the merchant I can see “Aotoki” “FamilyMart” “Aotoki” “FamilyMart” “Pay for FamilyMart successful”
render text: “Pay for #{merchant} successful” end merchant = Merchant.find_by!(id: params[:merchant_id]) current_customer.withdraw(payment_amount) ActiveRecord::Base.transaction do merchant.save! current_customer.save! end
payment_amount = params.require(:amount) current_customer.withdraw(payment_amount) merchant.deposit(payment_amount) ActiveRecord::Base.transaction do merchant.save! current_customer.save! end render text: “Pay for #{merchant} successful” end rescue ActiveRecord::RecordInvalid render text: “Pay for #{merchant} failed”