Error in Cordova integration with Razorpay [RazorPayCheckout not found]

I'm encountering an issue where I'm getting a "RazorPayCheckout is not defined" error. I've searched on StackOverflow but couldn't find any helpful answers. Can someone please assist me with this? Thank you in advance.

app.component.html

 <button (click)="payWithRazor()">Proceed to Pay</button>

app.component.ts

payWithRazor() {
    var options = {
      key: 'KEY', // Please insert your Razorpay key here
      name: 'Bunto Couriers Pvt. Ltd.',
      description: 'Delivery Fee',
      amount: this.price*100, // Razorpay requires the amount in paisa
      prefill: {
        name: '',
        email: '', // Please add your email address
      },
      image: 'link', 
      notes: {},
      theme: {
        color: '#00FF00'
      },
      modal: {
        ondismiss: (() => {
          this.zone.run(() => {
            // Add current page routing if payment fails
          })
        })
      }
    };

    var successCallback = function (payment_id) {
      alert('payment_id: ' + payment_id);
    };

    var cancelCallback = function (error) {
      alert(error.description + ' (Error ' + error.code + ')');
    };
    RazorpayCheckout.on('payment.success', successCallback);
    RazorpayCheckout.on('payment.cancel', cancelCallback);
    RazorpayCheckout.open(options);
  }

declaration.d.ts

declare module '*';

declare var RazorpayCheckout: any;

Answer №1

Integrate

Include Cordova platform browser into your project

This will create an environment similar to a native device for running Cordova apps in a web browser with enhanced features and functionalities Next, execute

Cordova build android

After building, run the app

Launch the app using Cordova run browser command

A new browser window will open showcasing the Cordova app. Razorpay integration will seamlessly function as expected in this setup

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encoding and Decoding Base64 in Nativescript Using Angular 2

I've searched high and low for a solution but I can't seem to find one. Even after attempting to utilize atob() and btoa(), my efforts were futile. It seems that despite what intellisense suggests, these methods cannot be used. Additionally, plug ...

Tips for showcasing information from an array in an object using Angular 2 or newer versions

My Information consists of 2 offices while another contains just one office "id": "1", "username": "sample", "groups": "Admin", "office": [ { "officeid": "2", "officename": "sky" }, { "officeid": "3", "off ...

Display Module within Component using Angular 5

In the application I'm working on, I want to incorporate a variety of progress-loader-animations such as spinners or bars. To achieve this, I've developed a module with a component. Now, I'm trying to figure out how to display the module&ap ...

Loading custom components dynamically in Angular with SVG: a how-to guide

Looking for a way to dynamically load SVG items with ease. The items needed are quite simple. Here's a basic template: <svg:rect [attr.x]="x" [attr.y]="y" width="10" height="10" /> Component Class Example: export class DraggableSvgItemCompon ...

A guide to adding a delay in the RxJS retry function

I am currently implementing the retry function with a delay in my code. My expectation is that the function will be called after a 1000ms delay, but for some reason it's not happening. Can anyone help me identify the error here? When I check the conso ...

Using JavaScript to assign function arguments based on arbitrary object values

I am facing a challenge with a collection of arbitrary functions and a method that takes a function name along with an object or array of parameters to call the respective function. The issue arises from the varying number of inputs in these functions, som ...

Discover the location of items within an array

Currently, I am working with a JSON object that has the following structure. My objective is to determine the index based on ID in order to retrieve the associated value. The indexOf function appears to be suitable for arrays containing single values, but ...

Displaying the input text directly is ineffective when the dropdownlist value changes due to the presence of another dropdownlist

How can I tackle the issue of dynamically populating dropdown lists with cascading categories and subcategories? I currently have two dropdown lists where the subcategory dropdown is filled based on the selected category. I also need to display an input fi ...

The index.html page on JHipster continues to display the message "You are logged in as user" even after successfully logging out

I have been struggling with this issue for quite some time now. Whenever I try to log out by clicking on 'settings' or 'entities' after logging in, the home page still shows me as logged in. The navbar also displays the 'entities& ...

The parameter label is being detected as having an any type, as specified in the Binding element 'label'

Currently, I am referencing an example code snippet from react-hook-form. However, upon implementation, I encounter the following error: (parameter) label: any Binding element 'label' implicitly has an 'any' type.ts(7031) The example c ...

Why do I keep getting errors in TypeScript when I manipulate DOM elements using getElementsByClassName(), even though my application still functions properly?

I am dealing with an Angular2 application. Unfortunately, I have had to resort to using the following code within a component method (I know it's not ideal, but...): let confirmWindowDOM = document.getElementsByClassName('modal')[0]; confir ...

Combine iron-page and bind them together

Recently, I've started learning about Polymer and I want to bind together paper-tabs and iron-pages so that when a tab is clicked, the content loads dynamically. After going through the documentation, this is what I have tried: <app-toolbar> ...

Angular nested router causing an infinite loop

I am currently working on creating a basic webpage layout consisting of a header, menu, and content div. My goal is to have the content div populate with the corresponding page when a user clicks on a link in the menu. Currently, I just want this common la ...

Bug in timezone calculation on Internet Explorer 11

I've spent hours researching the issue but haven't been able to find any effective workarounds or solutions. In our Angular 7+ application, we are using a timezone interceptor that is defined as follows: import { HttpInterceptor, HttpRequest, H ...

Encountering difficulties in starting a new Angular project using a Mac operating system

Attempting to set up a fresh Angular project named 'test' on a Mac. The command used in Terminal is as follows: xxxx$ ng new test Upon execution, the following error is displayed: -bash: /Users/xxxx/.npm-packages/lib/node_modules/@angular/cli ...

Tips for typing a subset of an array containing string literals in TypeScript

Is it possible to have a function called createFields that takes a generic Object type, such as User, and extracts a subset of keys that can be inferred with a string literal array, similar to the selectable property in Fields? If so, how can this be ach ...

In order to set a condition for the mat date picker to display a text box in Angular if the selected date is for someone under 18 years old

I need assistance with displaying a text field based on age validation. The requirement is to show the input field only if the age is less than 18. Below is the code snippet I am currently working with: <form [formGroup]="form"> ...

The absence of transpiled Typescript code "*.js" in imports

Here is an example of the code I am working with: User.ts ... import { UserFavoriteRoom } from "./UserFavoriteRoom.js"; import { Room } from "./Room.js"; import { Reservation } from "./Reservation.js"; import { Message } from ...

Issue with React useCallback not being triggered upon a change in its dependencies

useCallback seems to be capturing the wrong value of its dependency each time. const [state, setState] = React.useState(0); const callback = React.useCallback(() => { console.log(state); // always prints 0, why? }, [state]); React.useEffec ...

When using nodejs with sqlite3, the first callback parameter returns the class instance. How can this be resolved in order to prevent any issues?

Exploring a TypeScript class: class Log { public id: number; public text: string; construct(text: string){ this.text = text; } save(){ db.run( `insert into logs(text) values (?) `, this.text, ...