|
1 | | -// Label StoreMax |
| 1 | +// // Label StoreMax |
| 2 | +// // |
| 3 | +// // Created by Anthony Gordon. |
| 4 | +// // 2025, WooSignal Ltd. All rights reserved. |
| 5 | +// // |
2 | 6 | // |
3 | | -// Created by Anthony Gordon. |
4 | | -// 2025, WooSignal Ltd. All rights reserved. |
| 7 | +// // Unless required by applicable law or agreed to in writing, software |
| 8 | +// // distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +// // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
5 | 10 | // |
6 | | - |
7 | | -// Unless required by applicable law or agreed to in writing, software |
8 | | -// distributed under the License is distributed on an "AS IS" BASIS, |
9 | | -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
10 | | - |
11 | | -import '/resources/pages/checkout_status_page.dart'; |
12 | | -import '/app/models/cart.dart'; |
13 | | -import '/bootstrap/data/order_wc.dart'; |
14 | | -import '/bootstrap/helpers.dart'; |
15 | | -import '/resources/pages/checkout_confirmation_page.dart'; |
16 | | -import 'package:nylo_framework/nylo_framework.dart'; |
17 | | -import 'package:razorpay_flutter/razorpay_flutter.dart'; |
18 | | -import 'package:woosignal/models/response/tax_rate.dart'; |
19 | | -import 'package:woosignal/models/payload/order_wc.dart'; |
20 | | -import 'package:woosignal/models/response/order.dart'; |
21 | | - |
22 | | -razorPay(context, {TaxRate? taxRate}) async { |
23 | | - Razorpay razorpay = Razorpay(); |
24 | | - |
25 | | - razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, |
26 | | - (PaymentSuccessResponse response) async { |
27 | | - OrderWC orderWC = await buildOrderWC(taxRate: taxRate); |
28 | | - |
29 | | - Order? order = await appWooSignal((api) => api.createOrder(orderWC)); |
30 | | - |
31 | | - if (order != null) { |
32 | | - showToastNotification( |
33 | | - context, |
34 | | - title: "Error".tr(), |
35 | | - description: trans("Something went wrong, please contact our store"), |
36 | | - ); |
37 | | - updateState(CheckoutConfirmationPage.path.nyPageName(), |
38 | | - data: {"reloadState": false}); |
39 | | - return; |
40 | | - } |
41 | | - Cart.getInstance.clear(); |
42 | | - routeTo(CheckoutStatusPage.path, data: order); |
43 | | - }); |
44 | | - |
45 | | - razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, (PaymentFailureResponse response) { |
46 | | - showToastNotification(context, |
47 | | - title: trans("Error"), |
48 | | - description: response.message ?? "", |
49 | | - style: ToastNotificationStyleType.warning); |
50 | | - updateState(CheckoutConfirmationPage.path.nyPageName(), |
51 | | - data: {"reloadState": false}); |
52 | | - }); |
53 | | - |
54 | | - razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet); |
55 | | - |
56 | | - // CHECKOUT HELPER |
57 | | - await checkout(taxRate, (total, billingDetails, cart) async { |
58 | | - var options = { |
59 | | - 'key': getEnv('RAZORPAY_API_KEY'), |
60 | | - 'amount': (double.parse(total) * 100).toInt(), |
61 | | - 'name': getEnv('APP_NAME'), |
62 | | - 'description': await cart.cartShortDesc(), |
63 | | - 'prefill': { |
64 | | - "name": [ |
65 | | - billingDetails!.billingAddress?.firstName, |
66 | | - billingDetails.billingAddress?.lastName |
67 | | - ].where((t) => t != null || t != "").toList().join(" "), |
68 | | - "method": "card", |
69 | | - 'email': billingDetails.billingAddress?.emailAddress ?? "" |
70 | | - } |
71 | | - }; |
72 | | - |
73 | | - updateState(CheckoutConfirmationPage.path.nyPageName(), |
74 | | - data: {"reloadState": true}); |
75 | | - |
76 | | - razorpay.open(options); |
77 | | - }); |
78 | | -} |
79 | | - |
80 | | -void _handleExternalWallet(ExternalWalletResponse response) {} |
| 11 | +// import '/resources/pages/checkout_status_page.dart'; |
| 12 | +// import '/app/models/cart.dart'; |
| 13 | +// import '/bootstrap/data/order_wc.dart'; |
| 14 | +// import '/bootstrap/helpers.dart'; |
| 15 | +// import '/resources/pages/checkout_confirmation_page.dart'; |
| 16 | +// import 'package:nylo_framework/nylo_framework.dart'; |
| 17 | +// import 'package:razorpay_flutter/razorpay_flutter.dart'; |
| 18 | +// import 'package:woosignal/models/response/tax_rate.dart'; |
| 19 | +// import 'package:woosignal/models/payload/order_wc.dart'; |
| 20 | +// import 'package:woosignal/models/response/order.dart'; |
| 21 | +// |
| 22 | +// razorPay(context, {TaxRate? taxRate}) async { |
| 23 | +// Razorpay razorpay = Razorpay(); |
| 24 | +// |
| 25 | +// razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, |
| 26 | +// (PaymentSuccessResponse response) async { |
| 27 | +// OrderWC orderWC = await buildOrderWC(taxRate: taxRate); |
| 28 | +// |
| 29 | +// Order? order = await appWooSignal((api) => api.createOrder(orderWC)); |
| 30 | +// |
| 31 | +// if (order != null) { |
| 32 | +// showToastNotification( |
| 33 | +// context, |
| 34 | +// title: "Error".tr(), |
| 35 | +// description: trans("Something went wrong, please contact our store"), |
| 36 | +// ); |
| 37 | +// updateState(CheckoutConfirmationPage.path.nyPageName(), |
| 38 | +// data: {"reloadState": false}); |
| 39 | +// return; |
| 40 | +// } |
| 41 | +// Cart.getInstance.clear(); |
| 42 | +// routeTo(CheckoutStatusPage.path, data: order); |
| 43 | +// }); |
| 44 | +// |
| 45 | +// razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, (PaymentFailureResponse response) { |
| 46 | +// showToastNotification(context, |
| 47 | +// title: trans("Error"), |
| 48 | +// description: response.message ?? "", |
| 49 | +// style: ToastNotificationStyleType.warning); |
| 50 | +// updateState(CheckoutConfirmationPage.path.nyPageName(), |
| 51 | +// data: {"reloadState": false}); |
| 52 | +// }); |
| 53 | +// |
| 54 | +// razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet); |
| 55 | +// |
| 56 | +// // CHECKOUT HELPER |
| 57 | +// await checkout(taxRate, (total, billingDetails, cart) async { |
| 58 | +// var options = { |
| 59 | +// 'key': getEnv('RAZORPAY_API_KEY'), |
| 60 | +// 'amount': (double.parse(total) * 100).toInt(), |
| 61 | +// 'name': getEnv('APP_NAME'), |
| 62 | +// 'description': await cart.cartShortDesc(), |
| 63 | +// 'prefill': { |
| 64 | +// "name": [ |
| 65 | +// billingDetails!.billingAddress?.firstName, |
| 66 | +// billingDetails.billingAddress?.lastName |
| 67 | +// ].where((t) => t != null || t != "").toList().join(" "), |
| 68 | +// "method": "card", |
| 69 | +// 'email': billingDetails.billingAddress?.emailAddress ?? "" |
| 70 | +// } |
| 71 | +// }; |
| 72 | +// |
| 73 | +// updateState(CheckoutConfirmationPage.path.nyPageName(), |
| 74 | +// data: {"reloadState": true}); |
| 75 | +// |
| 76 | +// razorpay.open(options); |
| 77 | +// }); |
| 78 | +// } |
| 79 | +// |
| 80 | +// void _handleExternalWallet(ExternalWalletResponse response) {} |
0 commit comments