=== SutraPay for Razorpay ===
Contributors: fresheradvice
Tags: woocommerce, razorpay, upi, subscriptions, payment gateway
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept UPI, cards, netbanking and wallets on WooCommerce with your own Razorpay account, including Razorpay-run subscriptions.

== Description ==

SutraPay for Razorpay connects WooCommerce to your own Razorpay account.

**Payments**

* Razorpay Standard Checkout as a popup on the order "Pay" page, or on its own page that returns to your store (redirect mode).
* UPI, cards, netbanking, wallets, EMI and Pay Later: choose which ones are offered.
* Works with the classic checkout and the WooCommerce Cart and Checkout blocks.
* Every payment is checked on the server: Razorpay's signature, the order it belongs to, and its amount and currency, before the order is marked paid.
* Optional manual capture: authorized payments put the order on hold until you capture them from the order screen.
* Full and partial refunds from WooCommerce. Refunds made in the Razorpay Dashboard are recorded on the order.
* Payment links (email and SMS) for any unpaid order, from the order screen.

**Subscriptions**

* Works with MemberSutra (free and Pro) and with WooCommerce Subscriptions.
* A subscription runs as a Razorpay Subscription whenever every renewal costs the same. The first payment can differ (sign-up fee, trial, coupon, tax, other items in the cart): it is collected when the customer authorizes the subscription, and Razorpay starts charging the plan price on the first renewal date.
* Each subscription is linked to the shopper's Razorpay customer (created once and reused for later purchases).
* When renewal prices change over time (for example, a discount for the first few renewals), the first payment is taken with Razorpay and each renewal is invoiced by your store, payable with Razorpay. The order notes say why.
* Cancelling, pausing and resuming on your store is applied in Razorpay. Razorpay renewals, failed charges and cancellations made in the Razorpay Dashboard are recorded on your store.
* Razorpay plans are created automatically (one per distinct price and interval), or you can set a Plan ID on a WooCommerce Subscriptions product.

**Webhooks**

* Verified with your webhook secret (HMAC-SHA256), and each event is handled once.

== External services ==

This plugin connects to Razorpay, a payment service provided by Razorpay Software Private Limited, to take payments.

* **Razorpay API** (https://api.razorpay.com): when an order is placed, paid, refunded or checked, and when subscriptions are created or changed, the plugin sends the order amount, currency, order number and the customer's name, email and phone number (for payment links and Checkout prefill) to Razorpay. For a subscription it also creates (or looks up) a Razorpay customer with that name, email and phone, so the subscription shows who it belongs to in the Razorpay Dashboard.
* **Razorpay Checkout** (https://checkout.razorpay.com/v1/checkout.js): loaded on the order "Pay" page so the customer can enter their payment details directly with Razorpay.

Razorpay terms of use: https://razorpay.com/terms/ — Privacy policy: https://razorpay.com/privacy/

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. Go to **WooCommerce > SutraPay for Razorpay** and open **Settings**. Enter your Razorpay Test and Live API keys (Razorpay Dashboard > Account & Settings > API Keys), save, and use **Test connection**.
3. In the Razorpay Dashboard, add a webhook with the URL shown under **Webhooks**, set a secret, select the listed events, and paste the same secret into **Webhook Secret** in Settings.
4. For subscriptions: Razorpay Subscriptions must be enabled on your Razorpay account.

== Frequently Asked Questions ==

= Do I need my own Razorpay account? =
Yes. The plugin connects your Razorpay account to your store.

= Which currencies are supported? =
INR, and USD, EUR, GBP, SGD, AED, CAD, AUD and MYR when International Payments are enabled on your Razorpay account. Subscriptions use the currencies your account supports for Razorpay Subscriptions; when Razorpay refuses one, the subscription is billed by your store instead.

= Why is a subscription billed by my store instead of Razorpay? =
A Razorpay plan charges one price for every renewal. If a renewal costs a different amount (a limited-time renewal discount, a scheduled sale, a coupon that ends), or the order has several subscriptions, Razorpay cannot bill it, so the store invoices each renewal and the customer pays it with Razorpay. The purchase order's notes give the exact reason.

= Which Razorpay SDK does it use? =
The official razorpay-php SDK 2.9.3, bundled under its own namespace so it never conflicts with another copy, and sending its requests through the WordPress HTTP API.

== Changelog ==

= 1.2.0 =
* Changed: every internal name (code, settings, gateway id, webhook address, styles, scripts) is now sutrapay_razorpay; earlier builds used flex_razorpay.

= 1.1.0 =
* Changed: the plugin is now called SutraPay for Razorpay and lives in the sutrapay-for-razorpay folder. Settings, webhooks and saved payment methods are kept; a copy in the previous folder (flex-razorpay-payments) is switched off and can be removed with one button.
* Changed: updates come through WordPress's Updates screen when MemberSutra (website download) or MemberSutra Pro for WooCommerce is active.

= 1.0.4 =
* Changed: renamed to Flex Razorpay Payments (formerly MemberSutra). The folder and text domain stay flex-razorpay-payments, so updating replaces the installed copy and keeps all settings and data.

= 1.0.3 =
* Maintenance: released with MemberSutra 1.43.3; no code changes since 1.0.2.

= 1.0.2 =
* Changed: the plugin's home page and author links point to https://sutraplugins.com.
* Changed: the "API keys missing", "Webhook Secret" and currency warnings show only on this plugin's page, WooCommerce > Settings > Payments, the Dashboard and the Plugins screen.

= 1.0.1 =
* Added: subscriptions are created for a Razorpay customer (name, email and phone from the order), so the Customer column of Razorpay's Subscriptions dashboard is filled and the order screen links to the customer.
* Fixed: a subscription that has not started billing (Razorpay status "authenticated") is no longer paused, because Razorpay cancels it instead. Pause is refused with the reason and WooCommerce Subscriptions' Suspend button is hidden until billing starts; a cancel at the end of the term cancels it right away.
* Fixed: the confirmation check scheduled after checkout is removed once the payment is confirmed.
* Security: the Key Secret and Webhook Secret fields no longer write the secrets into the page; they show a mask with the last 4 characters (leave it to keep the saved secret). Webhook requests over 1 MB are refused.
* Uninstall also removes the recent-webhook list and the saved Razorpay customer ids.

= 1.0.0 =
* Razorpay payments, refunds, payment links and webhooks for WooCommerce.
* Razorpay-run subscriptions for MemberSutra and WooCommerce Subscriptions, with store-billed renewals when Razorpay cannot bill them.
* Bundles razorpay-php 2.9.3 (MIT).
* Admin screens laid out like the other MemberSutra payment plugins: a main page under WooCommerce, and Dashboard, Settings, Subscriptions, Webhooks and Logs.

== Upgrade Notice ==

= 1.2.0 =
First build under the SutraPay code names. Not an update from older builds: settings, orders and webhooks made with an earlier version are not carried over. Install on a new site (or start fresh) and connect the payment provider again.

= 1.1.0 =
Renamed to SutraPay for Razorpay (new folder; settings are kept). No functional change.

= 1.0.4 =
Renamed to Flex Razorpay Payments. Same folder and settings; updating replaces the installed copy.

= 1.0.3 =
Maintenance release, no code changes.

= 1.0.2 =
Setup warnings limited to the payment screens. No functional changes.

= 1.0.1 =
Links subscriptions to a Razorpay customer, stops pauses that Razorpay would turn into cancellations, and masks the secrets on the settings page. Update together with MemberSutra 1.42.0.
