-
Notifications
You must be signed in to change notification settings - Fork 243
/
android_pay_payment_request.dart
75 lines (67 loc) · 2.74 KB
/
android_pay_payment_request.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import 'package:flutter/material.dart';
class AndroidPayPaymentRequest {
bool? billingAddressRequired;
String? currencyCode;
List<LineItem>? lineItems;
bool? shippingAddressRequired;
List<String>? shippingCountries;
String? totalPrice;
AndroidPayPaymentRequest(
{this.billingAddressRequired,
required this.currencyCode,
this.lineItems,
this.shippingAddressRequired,
this.shippingCountries,
required this.totalPrice});
factory AndroidPayPaymentRequest.fromJson(Map<dynamic, dynamic> json) {
return AndroidPayPaymentRequest(
billingAddressRequired: json['billing_address_required'],
currencyCode: json['currency_code'],
lineItems:
json['line_items'] != null ? (json['line_items'] as List).map((i) => LineItem.fromJson(i)).toList() : null,
shippingAddressRequired: json['shipping_address_required'],
shippingCountries: json['shipping_countries'] != null ? new List<String>.from(json['shipping_countries']) : null,
totalPrice: json['total_price'],
);
}
Map<dynamic, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.billingAddressRequired != null) data['billing_address_required'] = this.billingAddressRequired;
if (this.currencyCode != null) data['currency_code'] = this.currencyCode;
if (this.shippingAddressRequired != null) data['shipping_address_required'] = this.shippingAddressRequired;
if (this.totalPrice != null) data['total_price'] = this.totalPrice;
if (this.lineItems != null) {
data['line_items'] = this.lineItems!.map((v) => v.toJson()).toList();
}
if (this.shippingCountries != null) {
if (this.shippingCountries != null) data['shipping_countries'] = this.shippingCountries;
}
return data;
}
}
class LineItem {
String? currencyCode;
String? description;
String? quantity;
String? totalPrice;
String? unitPrice;
LineItem({this.currencyCode, this.description, this.quantity, this.totalPrice, this.unitPrice});
factory LineItem.fromJson(Map<dynamic, dynamic> json) {
return LineItem(
currencyCode: json['currency_code'],
description: json['description'],
quantity: json['quantity'],
totalPrice: json['total_price'],
unitPrice: json['unit_price'],
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.currencyCode != null) data['currency_code'] = this.currencyCode;
if (this.description != null) data['description'] = this.description;
if (this.quantity != null) data['quantity'] = this.quantity;
if (this.totalPrice != null) data['total_price'] = this.totalPrice;
if (this.unitPrice != null) data['unit_price'] = this.unitPrice;
return data;
}
}