Skip to content

glin94/yookassa-dart-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yookassa_client

Dart REST client for Yookassa Payments API

Get started

Add dependency

dependencies:
  yookassa_client: ^1.0.5

Simple to use

import 'package:dio/dio.dart';
import 'package:yookassa_client/yookassa_client.dart';


    final dio = Dio();

  final yookassaClient = YookassaClient(
    dio,
    shopId: 'your_shop_id',
    secretKey: 'your_secret_key',
  );

  const createdPaymentRequest = CreatePaymentRequest(
    amount: Amount(
      value: '100.00',
      currency: 'RUB',
    ),
    paymentMethodData: YookassaPaymentMethod.sbp(),
    confirmation: YookassaConfirmation.qr(),
    capture: true,
    description: 'Заказ #1',
  );

  try {
    final payment =
        await yookassaClient.createPayment(payment: createdPaymentRequest);

    payment.map(
      pending: (payment) {
        print(payment);
      },
      waitingForCapture: (payment) {
        print(payment);
      },
      succeeded: (payment) {
        print(payment);
      },
      canceled: (payment) {
        print(payment);
      },
    );
  } on YookassaError catch (e) {
    print(e);
  }
}

About

Dart REST client for Yookassa Payments API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages