ottu_flutter_sdk

Last updated:

0 purchases

ottu_flutter_sdk Image
ottu_flutter_sdk Images
Add to Cart

Description:

ottu flutter sdk

OTTU Flutter Plugin #


Example #
To run the example project, clone the repo, and run flutter pub get in the main repository folder, make sure you have iOS simulator or device already plugged in, and run flutter run from the Example directory.
Requirements #

Flutter 1.22.6 or greater
Dart 1.19.0 or greater
iOS 12.1 or greater

Installation #
pub.dev #
OTTU Flutter Plugin is available through pub.dev. To install
it, simply add the following lines to your pubspec.yaml:

dependencies:
flutter:
sdk: flutter

ottu_flutter_sdk: ^0.0.1

copied to clipboard
manually #
OTTU Flutter Plugin can be installed manually by adding the following lines to your pubspec.yaml:

dependencies:
flutter:
sdk: flutter

ottu_flutter_sdk:
path: /path/to/flutter_ottu_checkout


copied to clipboard
Using #
Integrate with Xcode
Add the Apple Pay capability to your app. In Xcode, open your project settings, choose the Capabilities tab, and enable the Apple Pay switch. You may be prompted to log in to your developer account at this point. Enable the checkbox next to the merchant ID you created earlier, and your app is ready to accept Apple Pay.

Setup #
in your working dart file
After installing the plugin from Pub.dev or manually you will need to import the used package classes

import 'package:ottu_flutter_sdk/models/payment_item.dart';
import 'package:ottu_flutter_sdk/ottu_flutter_sdk.dart';
import 'package:ottu_flutter_sdk/enums/enums.dart';
import 'package:ottu_flutter_sdk/delegates/payment_delegate.dart';

copied to clipboard
Then implement the sdk delegate like this

class _MyHomePageState extends State<MyHomePage> implements PaymentDelegate {

@override
void paymentDismissed() {
print("Payment dismissed");

}

@override
void paymentFinished(bool idApproved) {
print("Payment finished");

}

@override
void paymentInfo(PaymentStatus status) {
print(status.getDescription);

}

@override
void paymentError(int statusCode, String serverResponse){
print("Status Code $statusCode");
}
}

copied to clipboard
After this you can config apple pay request like this

OttuFlutterSdk.setPaymentDelegate(this);

await OttuFlutterSdk.performPayment(
countryCode: CountryCode.SA,
paymentCards: [PaymentCard.Visa, PaymentCard.Amex, PaymentCard.MasterCard],
paymentItems: [PaymentItem("Potato", 3.2), PaymentItem("Tomato", 4.1)],
paymentAmount: double.tryParse(_amountTextController.text) ?? 0.1,
currencyCode: CurrencyCode.SAR,
merchantID: "merchant.dev.ottu.ksa",
domain: "ksa.ottu.dev",
sessionId: _sessionIdTextController.text,
code: _codeTextController.text,
);

copied to clipboard
All of the parameters are mandetory and not nullable



Name
Type
Description
Example Value




countryCode
CountryCode enum
The two-letter ISO 3166 country code.
CountryCode.SA


paymentCards
List of PaymentCard enum
List of available payment methods that are supported by Apple Pay.
[PaymentCard.Visa]


paymentItems
List of PaymentItem class
An array of payment summary item objects that summarize the amount of the payment.
[PaymentItem("Potato", 3.2)]


paymentAmount
double
The sum to pay
.01


currencyCode
CurrencyCode enum
The three-letter ISO 4217 currency code.
CurrencyCode.SAR


merchantID
String
Your merchant identifier.
merchant.dev.ottu.ksa


domain
String
API pay url, where payment shall be confirmed against Apple Pay token
"ksa.ottu.dev"


sessionId
String
Specified token which you need to get here https://docs.ottu.com/#/sessionAPI
"34e097cbe7a1b358628bb4b8e183083ffa78af9c"


code
String
A string code to idetify the operation
"apple-pay"



Delegate #
You need to delegate PaymentDelegate

OttuFlutterSdk.setPaymentDelegate(this);

copied to clipboard
Then implement PaymentDelegate protocol to your Class

class MyClass implements PaymentDelegate {

@override
void paymentDismissed() {
print("Payment dismissed");

}

@override
void paymentFinished(bool idApproved) {
print("Payment finished");

}

@override
void paymentInfo(PaymentStatus status) {
print(status.getDescription);

}

@override
void paymentError(int statusCode, String serverResponse){
print("Status Code $statusCode");
}


}

copied to clipboard
PaymentStatus can be one of the following values

switch (status) {

case .Eligible:
break;
case .NeedSetup:
break;
case .NotEligible:
break;
case .SessionIDNotSetuped:
break;
case .DomainURLNotSetuped:
break;
case .CodeNotSetuped:
break;
}

copied to clipboard
Author #
Ottu, [email protected]
License #
OttuCheckout is available under the MIT license. See the LICENSE file for more info.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.