Integrate easy payment function with active_merchant gem

Tram Ho

Preamble

In the era of technological development like now, online shopping is extremely developed. We can confirm that even further when the covid-19 pandemic swept, the amazone boss’s fortune has increased by 70 billion dollars. The reason is that people shop more online when isolated, but online shopping needs a reliable trading port instead of ship COD can be flipped orders can cause time and money for business people. Here I would like to introduce about gem active_merchant will help us pay a simple way. Gem is supported by shopify, an extremely large ecommerce platform, and the large developer of ecommerce CMS is Spreedly.

1. Install

Open cmd and create the project.

  • Create project

  • Install gem

  • Then you remember to add the gem file offline

  • Create a model

  • Config development

  • Config test

  • Config production

  • We add the action to create in the controller

  • Create model cart.rb

  • Because each cart will correspond to an order, we add relation

  • Edit model order

  • Transaction for order

  • Edit the form to display the payment

  • Add the corresponding action and view to the order processing state

Mirgate database then rails s to see the results.

  • create order view
Share the news now

Source : Viblo