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

flutter_braintree 표지
패키지 상세v4.0.0

flutter_braintree

네이티브 브레인트리 SDK를 감싸는 플러터 플러그인입니다. 신용카드, PayPal, Google Pay 등으로 결제할 수 있습니다.

AndroidiOS
30일 다운로드
845
좋아요
211
Pub 점수
150

패키지 설치

flutter pub add flutter_braintree

패키지 개요

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

플러터 플러그인으로 네이티브 브레인트리 SDK를 통합하여 신용카드, 페이팔, 구글페이 및 기타 방법을 통해 안전한 앱 내 결제를 가능하게 합니다. 이 플러그인은 플러터 애플리케이션과 브레인트리의 강력한 결제 인프라 간에 원활한 연결을 제공하며 산업 표준 준수를 보장합니다. Android와 iOS 플랫폼을 모두 지원하여 개발자가 다양한 기기에서 일관된 결제 경험을 구현할 수 있도록 합니다. pub.dev를 통해 최소한의 설정만으로 플러터 앱 내 결제 토큰 및 거래 처리를 간편하게 할 수 있습니다.

사용 사례

  • 앱 내 구매
  • 전자상거래 체크아웃
  • 구독 결제
  • 디지털 서비스 결제
  • 모바일 지갑 통합

주요 기능

  • 여러 가지 결제 수단을 지원합니다
  • 보안 토큰화
  • 크로스 플랫폼 호환성
  • Braintree와의 간편한 통합
  • 실시간 거래 처리

적합한 대상

  • 전자상거래 앱
  • 구독 기반 서비스
  • 모바일 결제 게이트웨이
  • PCI 준수를 요구하는 앱
  • Braintree를 사용하는 개발자

고려 사항

  • Braintree 계정 설정이 필요합니다
  • 적절한 환경 구성이 필요합니다
  • 네이티브 SDK에 의존
  • 추가적인 백엔드 로직이 필요할 수 있습니다
  • 지원되는 결제 수단에 제한됨

원본 README

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

Braintree for Flutter

A Flutter plugin that wraps the native Braintree SDKs. Unlike other plugins, this plugin not only lets you start Braintree's native Drop-in UI, but also allows you to create your own custom Flutter UI with Braintree functionality.

Installation

Add flutter_braintree to your pubspec.yaml file:

dependencies:
  ...
  flutter_braintree: <version>
Android

You must migrate to AndroidX.
In /app/build.gradle, set your minSdkVersion to at least 21.

Card.io

Card.io enables credit card scanning so as to remove the need to type in credit card details manually. This feature became optional in flutter_braintree version 0.6.0 to potentially reduce app sizes. To enable it for the Braintree Drop-in UI, add the following line to your app level build.gradle file:

dependencies {
    ...
    implementation 'io.card:android-sdk:5.+'
}
PayPal / Venmo / 3D Secure

In order for this plugin to support PayPal, Venmo or 3D Secure payments, you must allow for the browser switch by adding an intent filter to your AndroidManifest.xml (inside the <application> body):

<activity android:name="com.braintreepayments.api.DropInActivity"
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="${applicationId}.braintree" />
    </intent-filter>
</activity>
<activity android:name="com.braintreepayments.api.ThreeDSecureActivity" android:theme="@style/Theme.AppCompat.Light" android:exported="true">
</activity>

Important: Your app's URL scheme must begin with your app's package ID and end with .braintree. For example, if the Package ID is com.your-company.your-app, then your URL scheme should be com.your-company.your-app.braintree. ${applicationId} is automatically applied with your app's package when using Gradle. Note: The scheme you define must use all lowercase letters. If your package contains underscores, the underscores should be removed when specifying the scheme in your Android Manifest.

Google Pay

Add the wallet enabled meta-data tag to your AndroidManifest.xml (inside the <application> body):

<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/>
iOS

You may need to add or uncomment the following line at the top of your ios/Podfile:

platform :ios, '12.0'

Warning: Device data collection is not yet supported for iOS.

PayPal / Venmo / 3D Secure

In your App Delegate or your Runner project, you need to specify the URL scheme for redirecting payments as following:

BTAppContextSwitcher.setReturnURLScheme("com.your-company.your-app.payments")

Moreover, you need to specify the same URL scheme in your Info.plist:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>com.your-company.your-app.payments</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>com.your-company.your-app.payments</string>
        </array>
    </dict>
</array>

See the official Braintree documentation for a more detailed explanation.

Usage

You must first create a Braintree account. In your control panel you can create a tokenization key. You likely also want to set up a backend server. Make sure to read the Braintree developer documentation so you understand all key concepts.

In your code, import the plugin:

import 'package:flutter_braintree/flutter_braintree.dart';

You can then create your own user interface using Flutter or use Braintree's drop-in UI.

Flutter UI
Credit cards

Create a credit card request object:

final request = BraintreeCreditCardRequest(
  cardNumber: '4111111111111111',
  expirationMonth: '12',
  expirationYear: '2021',
  cvv: '367'
);

Then ask Braintree to tokenize it:

BraintreePaymentMethodNonce result = await Braintree.tokenizeCreditCard(
   '<Insert your tokenization key or client token here>',
   request,
);
print(result.nonce);
PayPal

Create a PayPal request object:

final request = BraintreePayPalRequest(amount: '13.37');

Or, for the Vault flow:

final request = BraintreePayPalRequest(
  billingAgreementDescription: 'I hereby agree that flutter_braintree is great.',
);

Then launch the PayPal request:

BraintreePaymentMethodNonce result = await Braintree.requestPaypalNonce(
   '<Insert your tokenization key or client token here>',
   request,
);
if (result != null) {
  print('Nonce: ${result.nonce}');
} else {
  print('PayPal flow was canceled.');
}
Braintree's native drop-in

Create a drop-in request object:

final request = BraintreeDropInRequest(
  clientToken: '<Insert your client token here>',
  collectDeviceData: true,
  googlePaymentRequest: BraintreeGooglePaymentRequest(
    totalPrice: '4.20',
    currencyCode: 'USD',
    billingAddressRequired: false,
  ),
  paypalRequest: BraintreePayPalRequest(
    amount: '4.20',
    displayName: 'Example company',
  ),
);

Then launch the drop-in:

BraintreeDropInResult result = await BraintreeDropIn.start(request);

Access the payment nonce:

if (result != null) {
  print('Nonce: ${result.paymentMethodNonce.nonce}');
} else {
  print('Selection was canceled.');
}

To increase the chances of success with 3DS2 challenge is possible to add additional information about the user as mentioned in the guide to Migrate to 3D Secure 2.

var request = BraintreeDropInRequest(
  clientToken: '<Insert your client token here>',
  collectDeviceData: true,
  requestThreeDSecureVerification: true,
  email: "test@email.com",
  amount: "0,01",
  billingAddress: BraintreeBillingAddress(
    givenName: "Jill",
    surname: "Doe",
    phoneNumber: "5551234567",
    streetAddress: "555 Smith St",
    extendedAddress: "#2",
    locality: "Chicago",
    region: "IL",
    postalCode: "12345",
    countryCodeAlpha2: "US",
  ),
  cardEnabled: true,
);

See BraintreeDropInRequest and BraintreeDropInResult for more documentation.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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