패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.4.7

razorpay_flutter

Razorpay SDK용 Flutter 플러그인입니다. Razorpay에 대해 자세히 알아보려면 http://razorpay.com을 방문하세요.

AndroidiOS
30일 다운로드
11.1만
좋아요
397
Pub 점수
150

패키지 설치

flutter pub add razorpay_flutter

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Razorpay Flutter는 Flutter 애플리케이션에 Razorpay 결제 게이트웨이를 통합하는 플러그인으로, 안드로이드 및 iOS용 원활한 앱 내 결제를 가능하게 합니다. 카드, UPI, 인터넷 뱅킹, 월렛 등 다양한 결제 수단을 지원하며, 네이티브와 유사한 체크아웃 경험을 제공합니다. 이 플러그인은 안전한 거래 처리와 사용자 정의 가능한 UI 컴포넌트를 통해 결제 프로세스를 간소화합니다. 개발자는 간단한 API를 사용해 최소한의 설정으로 결제 흐름을 쉽게 구현할 수 있습니다.

사용 사례

  • 앱 내 구매
  • 전자상거래 플랫폼
  • 구독 결제
  • 이벤트 티켓팅
  • 디지털 서비스 결제

주요 기능

  • 안전한 결제 처리
  • 사용자 지정 가능한 결제 UI
  • 다양한 결제 수단 지원
  • 실시간 거래 상태 업데이트
  • Flutter 앱과의 간편한 통합

적합한 대상

  • 모바일 전자상거래 앱
  • SaaS 플랫폼
  • 이벤트 관리 앱
  • 프리미엄 앱 수익화
  • 온라인 강의 플랫폼

고려 사항

  • 유효한 Razorpay API 키가 필요합니다
  • 실패한 거래에 대한 적절한 오류 처리가 필요합니다
  • 지역 결제 규정을 준수해야 합니다
  • 생산 전에 샌드박스 모드에서 테스트
  • 보안 패치를 위한 정기적인 SDK 업데이트

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Razorpay Flutter

Flutter plugin for Razorpay SDK.

pub package

Getting Started

This flutter plugin is a wrapper around our Android and iOS SDKs.

The following documentation is only focused on the wrapper around our native Android and iOS SDKs. To know more about our SDKs and how to link them within the projects, refer to the following documentation:

Android: https://razorpay.com/docs/checkout/android/

iOS: https://razorpay.com/docs/ios/

To know more about Razorpay payment flow and steps involved, read up here: https://razorpay.com/docs/

Prerequisites

  • Learn about the Razorpay Payment Flow.
  • Sign up for a Razorpay Account and generate the API Keys from the Razorpay Dashboard. Using the Test keys helps simulate a sandbox environment. No actual monetary transaction happens when using the Test keys. Use Live keys once you have thoroughly tested the application and are ready to go live.

Installation

This plugin is available on Pub: https://pub.dev/packages/razorpay_flutter

Add this to dependencies in your app's pubspec.yaml

razorpay_flutter: ^1.3.5

Note for Android: Make sure that the minimum API level for your app is 19 or higher.

Proguard rules

If you are using proguard for your builds, you need to add following lines to proguard files

-keepattributes *Annotation*
-dontwarn com.razorpay.**
-keep class com.razorpay.** {*;}
-optimizations !method/inlining/
-keepclasseswithmembers class * {
  public void onPayment*(...);
}

Follow this for more details.

Note for iOS: Make sure that the minimum deployment target for your app is iOS 10.0 or higher. Also, don't forget to enable bitcode for your project.

Run flutter packages get in the root directory of your app.

Usage

Sample code to integrate can be found in example/lib/main.dart.

Import package
import 'package:razorpay_flutter/razorpay_flutter.dart';
Create Razorpay instance
_razorpay = Razorpay();
Attach event listeners

The plugin uses event-based communication, and emits events when payment fails or succeeds.

The event names are exposed via the constants EVENT_PAYMENT_SUCCESS, EVENT_PAYMENT_ERROR and EVENT_EXTERNAL_WALLET from the Razorpay class.

Use the on(String event, Function handler) method on the Razorpay instance to attach event listeners.


_razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
_razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
_razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet);

The handlers would be defined somewhere as


void _handlePaymentSuccess(PaymentSuccessResponse response) {
  // Do something when payment succeeds
}

void _handlePaymentError(PaymentFailureResponse response) {
  // Do something when payment fails
}

void _handleExternalWallet(ExternalWalletResponse response) {
  // Do something when an external wallet was selected
}

To clear event listeners, use the clear method on the Razorpay instance.

_razorpay.clear(); // Removes all listeners
Setup options
var options = {
  'key': '<YOUR_KEY_HERE>',
  'amount': 100,
  'name': 'Acme Corp.',
  'description': 'Fine T-Shirt',
  'prefill': {
    'contact': '8888888888',
    'email': 'test@razorpay.com'
  }
};

A detailed list of options can be found here.

Open Checkout
_razorpay.open(options);

Troubleshooting

Enabling Bitcode

Open ios/Podfile and find this section:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

Set config.build_settings['ENABLE_BITCODE'] = 'YES'.

Setting Swift version

Add the following line below config.build_settings['ENABLE_BITCODE'] = 'YES':

config.build_settings['SWIFT_VERSION'] = '5.0'

CocoaPods could not find compatible versions for pod "razorpay_flutter" when running pod install
Specs satisfying the `razorpay_flutter (from
    `.symlinks/plugins/razorpay_flutter/ios`)` dependency were found, but they
    required a higher minimum deployment target.

This is due to your minimum deployment target being less than iOS 10.0. To change this, open ios/Podfile in your project and add/uncomment this line at the top:

# platform :ios, '9.0'

and change it to

platform :ios, '10.0'

and run pod install again in the ios directory.

iOS build fails with 'razorpay_flutter/razorpay_flutter-Swift.h' file not found

Add use_frameworks! in ios/Podfile and run pod install again in the ios directory.

Gradle build fails with Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:razorpay_flutter]

This is due to your Android minimum SDK version being less than 19. To change this, open android/app/build.gradle, find minSdkVersion in defaultConfig and set it to at least 19.

A lot of errors saying xxxx is not defined for the class 'Razorpay'

We export a class Razorpay from package:razorpay_flutter/razorpay_flutter.dart. Check if your code is redeclaring the Razorpay class.

Type 'xxxx' is not a subtype of type 'xxxx' of 'response' in Razorpay.on.<anonymous closure>
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: type 'PaymentFailureResponse' is not a subtype of type 'PaymentSuccessResponse' of 'response'
#0      Razorpay.on.<anonymous closure> (package:razorpay_flutter/razorpay_flutter.dart:87:14)
#1      EventEmitter.emit.<anonymous closure> (package:eventify/src/event_emitter.dart:94:14)
#2      List.forEach (dart:core-patch/growable_array.dart:278:8)
#3      EventEmitter.emit (package:eventify/src/event_emitter.dart:90:15)
#4      Razorpay._handleResult (package:razorpay_flutter/razorpay_flutter.dart:81:19)
#5      Razorpay.open (package:razorpay_flutter/razorpay_flutter.dart:49:5)
Class Registrar not found

Please update to version 1.4.0 to fix this issue.

Check the signatures of the callbacks for payment events. They should match the ones described here.

API

Razorpay
open(map<String, dynamic> options)

Open Razorpay Checkout.

The options map has key as a required property. All other properties are optional. For a complete list of options, please see the Checkout documentation.

on(String eventName, Function listener)

Register event listeners for payment events.

clear()

Clear all event listeners.

Error Codes

The error codes have been exposed as integers by the Razorpay class.

The error code is available as the code field of the PaymentFailureResponse instance passed to the callback.

Error Code Description
NETWORK_ERROR There was a network error, for example loss of internet connectivity
INVALID_OPTIONS An issue with options passed in Razorpay.open
PAYMENT_CANCELLED User cancelled the payment
TLS_ERROR Device does not support TLS v1.1 or TLS v1.2
UNKNOWN_ERROR An unknown error occurred.
Event names

The event names have also been exposed as Strings by the Razorpay class.

Event Name Description
EVENT_PAYMENT_SUCCESS The payment was successful.
EVENT_PAYMENT_ERROR The payment was not successful.
EVENT_EXTERNAL_WALLET An external wallet was selected.
PaymentSuccessResponse
Field Name Type Description
paymentId String The ID for the payment.
orderId String The order ID if the payment was for an order, null otherwise.
signature String The signature to be used for payment verification. (Only valid for orders, null otherwise)
PaymentFailureResponse
Field Name Type Description
code int The error code.
message String The error message.
ExternalWalletResponse
Field Name Type Description
walletName String The name of the external wallet selected.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트