Skip to content

Commit 97c9499

Browse files
author
WooSignal
committed
RazorPay checkout added, Option to use shipping address, Config update, Pubspec.yaml change, Option to use different billing or shipping address, Bug fixes
1 parent c399e88 commit 97c9499

File tree

15 files changed

+713
-165
lines changed

15 files changed

+713
-165
lines changed

LabelStoreMax/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [2.0.5] - 2020-05-16
2+
3+
* RazorPay checkout added
4+
* Option to use shipping address
5+
* Config update
6+
* Pubspec.yaml change
7+
* Option to use different billing or shipping address
8+
* Bug fixes
9+
110
## [2.0.4] - 2020-05-13
211

312
* Added Flexible widget for checkout details
63.5 KB
Loading

LabelStoreMax/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@
272272
"${BUILT_PRODUCTS_DIR}/flutter_web_browser/flutter_web_browser.framework",
273273
"${BUILT_PRODUCTS_DIR}/package_info/package_info.framework",
274274
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
275+
"${PODS_ROOT}/razorpay-pod/Pod/Razorpay.framework",
276+
"${BUILT_PRODUCTS_DIR}/razorpay_flutter/razorpay_flutter.framework",
275277
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
276278
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
277279
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
@@ -287,6 +289,8 @@
287289
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_web_browser.framework",
288290
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework",
289291
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
292+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Razorpay.framework",
293+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/razorpay_flutter.framework",
290294
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
291295
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
292296
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",

LabelStoreMax/lang/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"Done": "Done",
128128
"Billing Details": "Billing Details",
129129
"Shipping Details": "Shipping Details",
130+
"Shipping Address": "Shipping Address",
130131
"State": "State",
131132
"Country": "Country",
132133
"UPDATE DETAILS": "UPDATE DETAILS",
@@ -145,5 +146,9 @@
145146
"Welcome back": "Welcome back",
146147
"Quantity": "Quantity",
147148
"Select a state": "Select a state",
148-
"Select state": "Select state"
149+
"Select state": "Select state",
150+
"Ship to a different address?": "Ship to a different address?",
151+
"USE DETAILS": "USE DETAILS",
152+
"Not supported, try a card payment": "Not supported, try a card payment",
153+
"Invalid shipping address, please check your shipping details": "Invalid shipping address, please check your shipping details"
149154
}

LabelStoreMax/lib/app_payment_methods.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import 'package:label_storemax/helpers/tools.dart';
1212
import 'package:label_storemax/models/payment_type.dart';
1313
import 'package:label_storemax/providers/cash_on_delivery.dart';
14+
import 'package:label_storemax/providers/razor_pay.dart';
1415
import 'package:label_storemax/providers/stripe_pay.dart';
1516

1617
// Payment methods available for uses in the app
@@ -36,15 +37,25 @@ List<PaymentType> arrPaymentMethods = [
3637
),
3738
),
3839

40+
addPayment(
41+
PaymentType(
42+
id: 3,
43+
name: "RazorPay",
44+
desc: "Debit or Credit Card",
45+
assetImage: "razorpay.png",
46+
pay: razorPay,
47+
),
48+
),
49+
3950
// e.g. add more here
4051

4152
// addPayment(
4253
// PaymentType(
43-
// id: 3,
54+
// id: 4,
4455
// name: "MyNewPaymentMethod",
4556
// desc: "Debit or Credit Card",
4657
// assetImage: "add icon image to assets/images/myimage.png",
47-
// pay: stripePay
58+
// pay: myCustomPaymentFunction
4859
// ),
4960
// ),
5061
];

LabelStoreMax/lib/helpers/data/order_wc.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ Future<OrderWC> buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
6666
billing.postcode = billingDetails.billingAddress.postalCode;
6767
billing.country = billingDetails.billingAddress.country;
6868
billing.email = billingDetails.billingAddress.emailAddress;
69+
if (billingDetails.billingAddress.country == "United States") {
70+
billing.state = billingDetails.billingAddress.state;
71+
}
6972

7073
orderWC.billing = billing;
7174

@@ -75,6 +78,9 @@ Future<OrderWC> buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
7578
shipping.address1 = billingDetails.shippingAddress.addressLine;
7679
shipping.city = billingDetails.shippingAddress.city;
7780
shipping.postcode = billingDetails.shippingAddress.postalCode;
81+
if (billingDetails.shippingAddress.country == "United States") {
82+
shipping.state = billingDetails.shippingAddress.state;
83+
}
7884
shipping.country = billingDetails.shippingAddress.country;
7985

8086
orderWC.shipping = shipping;

LabelStoreMax/lib/labelconfig.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ import 'dart:ui';
1616
Developer Notes
1717
1818
SUPPORT EMAIL - [email protected]
19-
VERSION - 2.0.4
19+
VERSION - 2.0.5
2020
https://woosignal.com
2121
*/
2222

2323
/*<! ------ CONFIG ------!>*/
2424

2525
const app_name = "MyApp";
2626

27-
const app_key = "Your app key from WooSignal";
27+
const app_key =
28+
"app_b2538b4325a4a6b0f3b919f4c91cea8087ba80977f4a7c1feda669127aca";
2829

2930
// Your App key from WooSignal
3031
// link: https://woosignal.com/dashboard/apps
@@ -47,7 +48,7 @@ const app_locales_supported = [
4748

4849
/*<! ------ PAYMENT GATEWAYS ------!>*/
4950

50-
// Available: "Stripe", "CashOnDelivery",
51+
// Available: "Stripe", "CashOnDelivery", "RazorPay"
5152
// Add the method to the array below e.g. ["Stripe", "CashOnDelivery"]
5253

5354
const app_payment_methods = ["Stripe"];
@@ -78,6 +79,11 @@ const app_forgot_password_url =
7879
"https://mysite.com/my-account/lost-password"; // change to your forgot password url
7980
const app_wp_api_path = "/wp-json"; // By default "/wp-json" should work
8081

82+
/*<! ------ Razor Pay (OPTIONAL) ------!>*/
83+
// https://razorpay.com/
84+
85+
const app_razor_id = "Your Razor ID from RazorPay";
86+
8187
/*<! ------ DEBUGGER ENABLED ------!>*/
8288

8389
const app_debug = true;

LabelStoreMax/lib/models/checkout_session.dart

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import 'package:woosignal/models/response/tax_rate.dart';
2121
import '../helpers/tools.dart';
2222

2323
class CheckoutSession {
24-
String sfKeyCheckout = "CS_BILLING_DETAILS";
24+
String sfKeyBillingCheckout = "CS_BILLING_DETAILS";
25+
String sfKeyShippingCheckout = "CS_SHIPPING_DETAILS";
26+
bool shipToDifferentAddress = false;
27+
2528
CheckoutSession._privateConstructor();
2629
static final CheckoutSession getInstance =
2730
CheckoutSession._privateConstructor();
@@ -35,19 +38,25 @@ class CheckoutSession {
3538
shippingType = null;
3639
}
3740

41+
void clear() {
42+
billingDetails = null;
43+
shippingType = null;
44+
paymentType = null;
45+
}
46+
3847
void saveBillingAddress() {
3948
SharedPref sharedPref = SharedPref();
4049
CustomerAddress customerAddress =
4150
CheckoutSession.getInstance.billingDetails.billingAddress;
4251

4352
String billingAddress = jsonEncode(customerAddress.toJson());
44-
sharedPref.save(sfKeyCheckout, billingAddress);
53+
sharedPref.save(sfKeyBillingCheckout, billingAddress);
4554
}
4655

4756
Future<CustomerAddress> getBillingAddress() async {
4857
SharedPref sharedPref = SharedPref();
4958

50-
String strCheckoutDetails = await sharedPref.read(sfKeyCheckout);
59+
String strCheckoutDetails = await sharedPref.read(sfKeyBillingCheckout);
5160

5261
if (strCheckoutDetails != null && strCheckoutDetails != "") {
5362
return CustomerAddress.fromJson(jsonDecode(strCheckoutDetails));
@@ -57,7 +66,30 @@ class CheckoutSession {
5766

5867
void clearBillingAddress() {
5968
SharedPref sharedPref = SharedPref();
60-
sharedPref.remove(sfKeyCheckout);
69+
sharedPref.remove(sfKeyBillingCheckout);
70+
}
71+
72+
void saveShippingAddress() {
73+
SharedPref sharedPref = SharedPref();
74+
CustomerAddress customerAddress =
75+
CheckoutSession.getInstance.billingDetails.shippingAddress;
76+
77+
String shippingAddress = jsonEncode(customerAddress.toJson());
78+
sharedPref.save(sfKeyShippingCheckout, shippingAddress);
79+
}
80+
81+
Future<CustomerAddress> getShippingAddress() async {
82+
SharedPref sharedPref = SharedPref();
83+
String strCheckoutDetails = await sharedPref.read(sfKeyShippingCheckout);
84+
if (strCheckoutDetails != null && strCheckoutDetails != "") {
85+
return CustomerAddress.fromJson(jsonDecode(strCheckoutDetails));
86+
}
87+
return null;
88+
}
89+
90+
void clearShippingAddress() {
91+
SharedPref sharedPref = SharedPref();
92+
sharedPref.remove(sfKeyShippingCheckout);
6193
}
6294

6395
Future<String> total({bool withFormat, TaxRate taxRate}) async {

LabelStoreMax/lib/pages/checkout_confirmation.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ class CheckoutConfirmationPageState extends State<CheckoutConfirmationPage> {
291291
.getTotal(withFormatting: true)),
292292
(_taxRate != null
293293
? wsCheckoutTaxAmountWidgetFB(taxRate: _taxRate)
294-
: Container()),
294+
: null),
295295
wsCheckoutTotalWidgetFB(
296296
title: trans(context, "Total"), taxRate: _taxRate),
297297
Divider(
298298
color: Colors.black12,
299299
thickness: 1,
300300
),
301-
],
301+
].where((e) => e != null).toList(),
302302
),
303303
wsPrimaryButton(
304304
context,

0 commit comments

Comments
 (0)