Skip to content
Snippets Groups Projects
Forked from project / drupal
Source project has a limited visibility.
Razorpay module will depend on razorpay PHP API.

(Possible) next steps email from Drupalize.me:

  Amber (Osio Labs) Dec 12, 5:51 PM EST

  Hi Krishan,

  I'll try again. To use a PHP library in your module, the process overall is:

  . In your module's composer.json, add the library namespace from Packagist to the "require" key.
    . Example from Geofield project, requiring the phayes/geophp library: https://git.drupalcode.org/project/geofield/blob/8.x-1.x/composer.json
    . Tutorial: Anatomy of a Composer Project
  . There's probably one or more classes in your dependency that you'll want to define as a services in your MODULE.services.yml.
    . Example from Geofield project, adding 4 classes to the services container: https://git.drupalcode.org/project/geofield/blob/8.x-1.x/geofield.services.yml
    . Tutorial: Configure a New Service
  . Using the __constructor/create pattern, inject the service from the container into whichever class you want to use it in and use methods from the service as needed.
    . Example from Geofield project: https://git.drupalcode.org/project/geofield/blob/8.x-1.x/src/Plugin/Field/FieldFormatter/GeofieldDefaultFormatter.php
    . Tutorial: Inject Services into a Form Controller

  Hope this helps,
  Amber

Razorpay work-flow:

1. CreateOrder: Customer creates an order on the website or app
   . Server get request and sends CREATE_ORDER request to RazorPay. TODO: params for CREATE_ORDER request
     . OrderID returned from RazorPay
2. Checkout form: Customer enters payment details. TODO: payment details params
   . Sucessful payment on the checkout, send following to server:
      . razorpay_payment_id
      . razorpay_order_id
      . razorpay_signature
   . Server verifies request
   . After successful confirmation, capture payment. TODO: how/where to capture payment?

RazorPay checkout options:

https://razorpay.com/docs/payment-gateway/web-integration/standard/
1. Standard Automatic checkout. Used for standard payment, on a single product
2. Standard Manual checkout. integrate with the 'custom button' on the site. "Opt
    for this when you have multiple products, or a complex way to pre-calculate
    amount for a payment (in javascript). It provides a greater control in the
    payment process." Reference:
    https://razorpay.com/docs/payment-gateway/web-integration/standard/checkout-form/