Recurring PayPage

Setup Guide


Setup Guide

Installation

Files & Directories in Download Package

In the downloaded Zip file, you will find below files & folders:

  • Source – a folder containing all the required files you need to paste in your application.
  • config.php - a file containing all payment gateways configuration, you need to update payment gateways API and secret key.
  • Setup-Guide.pdf – an Instruction manual for setup (This Document).
  • Quick-Start-Guide.pdf - Basic introduction.
  • Technical-Guide.pdf – Technical information may help for further customizations.

 

Configurations

config.php file contains all the payment gateway related configuration like enable payment gateway, on/off test or production mode, API and Secret keys, success / error URL etc. You need to update these key as per your requirement.

​​​So first of all, you need to set base URL in example/config.php file as per showing below.

 

Other files in example uses

 

  1. All is set, now to create new subscription open create-subscription.php file and follow the below steps

 

    1. Here you have to set payment method (Stripe or Razorpay) as per your requirement in paymentProcess() object as shown below.

 

 

You can also set payment method dynamically.

 

    1. For create new subscription call $paymentProcess->createSubscription($paymentData) method. Here you have to pass plan_id is required key in $paymentData array.

 

    1. If subscription is successful then you get response in subscription-response.php in paymentResponse() function. You get all the subscription related data in $paymentResponseData variable.

 

    1. You can also get webhook event data in webhook-payment-response.php in getWebhookResponse() function.

 

  1. To update existing subscription open update-subscription.php file and follow the below steps.

 

    1. Here you have to set payment method (Stripe or Razorpay) as per your requirement in paymentProcess() object as per show below.

 

 

You can also set payment method dynamically.

 

    1. For update existing subscription just call $paymentProcess->updateSubscription($paymentData) function with following required key
      1. subscription_id (both payment gateway)
      2. new_plan_id (both payment gateway)
      3. remaining_count (only for razorpay)

 

    1. You can also get webhook event data in webhook-payment-response.php in getWebhookResponse() function.

 

3. To cancel subscription open cancel-subscription.php file and follow the below steps.

 

    1. Here you have to set payment method (Stripe or Razorpay) as per your requirement in paymentProcess() object as per show below.

 

 

You can also set this payment method dynamically.

 

    1. To cancel existing subscription of customer you have to call “$cancelSubscription = $paymentProcess->processCancelStripeSubscription($subscriptionId, $cancelAtPeriodEnd);” method. Here subscription id is required parameter. If you want to cancel subscription at the end of the subscription period then set cancelAtPeriodEnd to true.

 

    1. You can also get webhook event data in webhook-payment-response.php in getWebhookResponse() function.

 

4. To update customer existing card (only for stripe) open update-customer-card.php and follow the below steps.

 

    1. Here you have to set payment method (Stripe or Razorpay) as per your requirement in paymentProcess() object as per show below.

 

 

You also set this payment method dynamically.

 

    1. To update customer card, you have to use “$customerCardUpdate = $paymentProcess->customerCardUpdateData($paymentData);” method. You have to pass customer_id and subscription_id in payment data variable.

 

That’s it, you can ready to get a payment from Razorpay or stripe subscription.

 

Stripe Payment Gateway Configuration


The steps given below will take you through the setup process for Stripe.

  1. To start a recurring payment through stripe you have to visit following site. Stripe and login. Then click on Developers >> API Keys, after that you found Standard keys section. grab your secret and publish keys from here.

 

 

  1. After getting your Public and Secret key you need to paste into config.php file and set enable option true as per shown below.

 

 

  1. Now you need to create Product and subscription plan. Please follow the below steps to create product and plans on Stripe Dashboard.

 

    1. Login to your Stripe account.
    2. Then click on Billing -> Products link from left sidebar.

 

 

    1. Now click on New button and fill all the required field and create product.​​​​​​

 

 

  1.     d. After creating product stripe will redirect you to Create Pricing Plan page, here you need to set your pricing plan like, monthly, quarterly, yearly etc. (only one plan can be added at a time).

 

 

  1.     e. After adding pricing plan, these plans show in product page in Pricing Plans section. If needed you can add more Pricing Plans from here.

 

 

           f. Now you need to grab pricing plan Id. Click on price plan and copy pricing plan id, this plan id is used for subscription.

 

 

  1.     g. Now you need to copy all pricing plan id and paste it into your config.php file as per show below. Also add price and title of your plan.

 

 

4. Now, set webhook URL, where stripe send all the information payment related activity. Here set your own website URL. Just follow the following steps

 

    1. Click on Developers >> Webhooks in sidebar of Stripe Dashboard.

 

         b. Now click on add endpoint button in top right side of the page.

         c. A dialog will be appeared then add your webhook URL in endpoint URL and set following events.

 

 

      1. ‘charge.succeeded’
      2. checkout.session.completed
      3. payment_intent.payment_failed
      4. payment_intent.succeeded.
      5. checkout.session.completed
      6. charge.failed
      7. customer.subscription.updated

and set your webhook URL as per below:

https://your-base-url/webhook-payment-response.php?request_from=stripe

 

 

Razorpay Payment Gateway Configuration

 

The steps given below will take you through the setup process for Stripe.

    1. Create an account in Razorpay, using this link as shown in below URL, https://dashboard.razorpay.com/

 

    1. Get your API keys to access test account in Razorpay. Razorpay provide two keys as Razorpay Key-id and Razorpay Secret Key as shown in below image.

 

 

    1. After getting your Public and Secret key you need to paste into config.php file and set enable option true as per shown below.

 

 

  1.   4. Now you need to create Product and subscription plan. Please follow the below steps to create product and plans on Razorpay Dashboard.

 

      1. Login to your Razorpay account and click on subscription in sidebar panel and click on plan tab as per shown below.

 

 

 

 

    1.     b. Now click on +New Plan button on top right corner. A drawer will be open from right hand side and fill the                    form and click on create plan button.

 

 

    1.     c. Create plan as per your requirement, all plans are shown in plans tab. Now copy plan id and paste it into your config.php in plans array as per shown below.

 

 

    1.     d. Now you have to set webhook URL for your upcoming webhook event on you server for create, update, cancel            subscription.
    2.  
    3.     e. Click on settings in your Razorpay sidebar menu and then click on webhook tab as per shown below.

 

 

 

    1.     f. Now click on create new webhook button a dialog will be open add your base URL and webhook.php URL in webhook URL text box, and just check following 4 check boxes

 

                           i) subscription.charged

                           ii) subscription.cancelled

                           iii) subscription.completed

                           iv) subscription.updated

                           and set your base URL as per below:

                           https://your-base-url/webhook-payment-response.php?request_from=razorpay

 

 

    1.     g. All you webhook event send to this webhook URL by Razorpay.