Skip to content

Commit

Permalink
chore: update dependencies and pump version to 2.7.0
Browse files Browse the repository at this point in the history
- Updated FlutterPaytabsBridge with minor formatting improvements for readability.
- Set main version to 2.7.0 in pubspec.yaml and example/pubspec.yaml.
- Ensured consistency in version updates across the main project and example project.
  • Loading branch information
muhammadalkady committed Nov 25, 2024
1 parent 6c3c0b4 commit bfffdae
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 109 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Flutter PayTabs Bridge
![Version](https://img.shields.io/badge/flutter%20paytabs%20bridge-v2.6.20-green)
![Version](https://img.shields.io/badge/flutter%20paytabs%20bridge-v2.7.0-green)

Flutter paytabs plugin is a wrapper for the native PayTabs Android and iOS SDKs, It helps you integrate with PayTabs payment gateway.

Expand All @@ -12,7 +12,7 @@ Plugin Support:

```
dependencies:
flutter_paytabs_bridge: ^2.6.20
flutter_paytabs_bridge: ^2.7.0
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ android {
}

dependencies {
implementation 'com.paytabs:payment-sdk:6.6.14'
implementation 'com.paytabs:payment-sdk:6.7.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static com.payment.paymentsdk.integrationmodels.PaymentSdkTransactionTypeKt.createPaymentSdkTransactionType;

import android.app.Activity;
import android.os.Build;

import androidx.annotation.NonNull;

Expand Down Expand Up @@ -99,9 +98,6 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
case "queryTransaction":
queryTransaction(call);
break;
case "startPaymentWithSavedCards":
makePaymentWithSavedCards(call);
break;
case "startSamsungPayPayment":
makeSamsungPayment(call);
break;
Expand All @@ -111,23 +107,6 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
case "cancelPayment":
cancelPayment();
break;
case "clearSavedCards":
clearSavedCards(result);
break;
}
}


private void clearSavedCards(Result result) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PaymentSdkActivity.clearSavedCards(activity);
result.success(null);
} else {
result.error("0", "Unsupported Android Version. Min supported SDK is 23", "{}");
}
} catch (Exception e) {
result.error("0", e.getMessage(), "{}");
}
}

Expand Down Expand Up @@ -179,15 +158,6 @@ private void queryTransaction(@NonNull MethodCall call) {
}
}

private void makePaymentWithSavedCards(@NonNull MethodCall call) {
try {
HashMap<String, Object> arguments = call.arguments();
JSONObject paymentDetails = new JSONObject(arguments);
PaymentSdkActivity.startPaymentWithSavedCards(activity, getPaymentSdkConfigurationDetails(paymentDetails), getIsSupport3DS(paymentDetails), getCallback());
} catch (Exception e) {
eventSink.error("0", e.getMessage(), "{}");
}
}

private void makeApmsPayment(@NonNull MethodCall call) {
try {
Expand Down Expand Up @@ -359,29 +329,7 @@ private PaymentSdkConfigurationDetails getPaymentSdkConfigurationDetails(JSONObj
shippingData = new PaymentSdkShippingDetails(shippingDetails.optString("pt_city_shipping"), shippingDetails.optString("pt_country_shipping"), shippingDetails.optString("pt_email_shipping"), shippingDetails.optString("pt_name_shipping"), shippingDetails.optString("pt_phone_shipping"), shippingDetails.optString("pt_state_shipping"), shippingDetails.optString("pt_address_shipping"), shippingDetails.optString("pt_zip_shipping"));
}
final List<PaymentSdkCardDiscount> paymentSdkCardDiscounts = getPaymentSdkCardDiscounts(paymentDetails);
return new PaymentSdkConfigBuilder(profileId, serverKey, clientKey, amount, currency)
.setCartDescription(cartDesc)
.setLanguageCode(locale)
.setBillingData(billingData)
.setMerchantCountryCode(paymentDetails.optString("pt_merchant_country_code"))
.setShippingData(shippingData)
.setCartId(orderId)
.setTransactionClass(createPaymentSdkTransactionClass(paymentDetails.optString("pt_transaction_class")))
.setTransactionType(transaction_type).setTokenise(tokeniseType, tokenFormat)
.setTokenisationData(token, transRef)
.setAlternativePaymentMethods(aPmsList)
.showBillingInfo(paymentDetails.optBoolean("pt_show_billing_info"))
.showShippingInfo(paymentDetails.optBoolean("pt_show_shipping_info"))
.forceShippingInfo(paymentDetails.optBoolean("pt_force_validate_shipping"))
.setMerchantIcon(iconUri).setScreenTitle(screenTitle)
.linkBillingNameWithCard(paymentDetails.optBoolean("pt_link_billing_name"))
.hideCardScanner(paymentDetails.optBoolean("pt_hide_card_scanner"))
.enableZeroContacts(paymentDetails.optBoolean("pt_enable_zero_contacts"))
.isDigitalProduct(paymentDetails.optBoolean("pt_is_digital_product"))
.setPaymentExpiry(paymentScreenExpiry)
.setMetadata(getMetadata())
.setCardApproval(getCardApproval(paymentDetails))
.setCardDiscount(paymentSdkCardDiscounts).build();
return new PaymentSdkConfigBuilder(profileId, serverKey, clientKey, amount, currency).setCartDescription(cartDesc).setLanguageCode(locale).setBillingData(billingData).setMerchantCountryCode(paymentDetails.optString("pt_merchant_country_code")).setShippingData(shippingData).setCartId(orderId).setTransactionClass(createPaymentSdkTransactionClass(paymentDetails.optString("pt_transaction_class"))).setTransactionType(transaction_type).setTokenise(tokeniseType, tokenFormat).setTokenisationData(token, transRef).setAlternativePaymentMethods(aPmsList).showBillingInfo(paymentDetails.optBoolean("pt_show_billing_info")).showShippingInfo(paymentDetails.optBoolean("pt_show_shipping_info")).forceShippingInfo(paymentDetails.optBoolean("pt_force_validate_shipping")).setMerchantIcon(iconUri).setScreenTitle(screenTitle).linkBillingNameWithCard(paymentDetails.optBoolean("pt_link_billing_name")).hideCardScanner(paymentDetails.optBoolean("pt_hide_card_scanner")).enableZeroContacts(paymentDetails.optBoolean("pt_enable_zero_contacts")).isDigitalProduct(paymentDetails.optBoolean("pt_is_digital_product")).setPaymentExpiry(paymentScreenExpiry).setMetadata(getMetadata()).setCardApproval(getCardApproval(paymentDetails)).setCardDiscount(paymentSdkCardDiscounts).build();
}

/**
Expand All @@ -392,7 +340,7 @@ private PaymentSdkConfigurationDetails getPaymentSdkConfigurationDetails(JSONObj
private Map<String, Object> getMetadata() {
Map<String, Object> metadata = new HashMap<>();
metadata.put("PaymentSDKPluginName", "flutter");
metadata.put("PaymentSDKPluginVersion", "2.6.20");
metadata.put("PaymentSDKPluginVersion", "2.7.0");
return metadata;
}

Expand All @@ -410,8 +358,7 @@ private static List<PaymentSdkCardDiscount> getPaymentSdkCardDiscounts(JSONObjec
cards.add(cardsPrefixes.optString(j));
}
}
final PaymentSdkCardDiscount cardDiscount = new PaymentSdkCardDiscount(cards, discount.optDouble("pt_discount_value"),
discount.optString("pt_discount_title"), discount.optBoolean("pt_is_percentage"));
final PaymentSdkCardDiscount cardDiscount = new PaymentSdkCardDiscount(cards, discount.optDouble("pt_discount_value"), discount.optString("pt_discount_title"), discount.optBoolean("pt_is_percentage"));
paymentSdkCardDiscounts.add(cardDiscount);
}
}
Expand All @@ -427,11 +374,7 @@ private static List<PaymentSdkCardDiscount> getPaymentSdkCardDiscounts(JSONObjec
private static PaymentSdkCardApproval getCardApproval(JSONObject paymentDetails) {
JSONObject cardApproval = paymentDetails.optJSONObject("pt_card_approval");
if (cardApproval == null) return null;
return new PaymentSdkCardApproval(
cardApproval.optString("pt_validation_url"),
cardApproval.optInt("pt_bin_length"),
cardApproval.optBoolean("pt_block_if_no_response")
);
return new PaymentSdkCardApproval(cardApproval.optString("pt_validation_url"), cardApproval.optInt("pt_bin_length"), cardApproval.optBoolean("pt_block_if_no_response"));
}

public static String optString(JSONObject json, String key) {
Expand Down
17 changes: 0 additions & 17 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ class _MyAppState extends State<MyApp> {
onPressed: _handleQuery,
child: Text('Query Transaction'),
),
TextButton(
onPressed: _clearSavedCards,
child: Text('Clear Saved Cards'),
),
_buildApplePayButton(),
],
),
Expand Down Expand Up @@ -340,14 +336,6 @@ class _MyAppState extends State<MyApp> {
});
}

/// Clears saved cards.
///
/// This method clears the saved cards using the FlutterPaytabsBridge and logs the result.
Future<void> _clearSavedCards() async {
final result = await FlutterPaytabsBridge.clearSavedCards();
debugPrint("ClearSavedCards $result");
}

/// Builds the Apple Pay button, shown only on iOS.
///
/// This method returns a [TextButton] widget for Apple Pay if the platform is iOS,
Expand Down Expand Up @@ -387,11 +375,6 @@ class _MyAppState extends State<MyApp> {
FlutterPaytabsBridge.start3DSecureTokenizedCardPayment),
child: Text('Pay with 3DS'),
),
TextButton(
onPressed: () =>
_handlePayment(FlutterPaytabsBridge.startPaymentWithSavedCards),
child: Text('Pay with Saved Cards'),
),
TextButton(
onPressed: () =>
_handlePayment(FlutterPaytabsBridge.startAlternativePaymentMethod),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.6.20"
version: "2.7.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/SwiftFlutterPaytabsBridgePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public class SwiftFlutterPaymentSDKBridgePlugin: NSObject, FlutterPlugin {
configuration.paymentNetworks = generatePaymentNetworks(paymentsArray: paymentNetworks)
}

configuration.metaData = ["PaymentSDKPluginName": "flutter", "PaymentSDKPluginVersion": "2.6.20"]
configuration.metaData = ["PaymentSDKPluginName": "flutter", "PaymentSDKPluginVersion": "2.7.0"]
return configuration
}

Expand Down
2 changes: 1 addition & 1 deletion ios/flutter_paytabs_bridge.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'flutter_paytabs_bridge'
s.version = '2.6.20'
s.version = '2.7.0'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new flutter plugin project.
Expand Down
24 changes: 0 additions & 24 deletions lib/flutter_paytabs_bridge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,6 @@ class FlutterPaytabsBridge {
'start3DSecureTokenizedCardPayment', argsMap);
}

static Future<dynamic> startPaymentWithSavedCards(
PaymentSdkConfigurationDetails arg,
bool support3DS,
void eventsCallBack(dynamic)) async {
arg.samsungPayToken = null;
MethodChannel localChannel = MethodChannel('flutter_paytabs_bridge');
EventChannel localStream =
const EventChannel('flutter_paytabs_bridge_stream');
localStream.receiveBroadcastStream().listen(eventsCallBack);
var logoImage = arg.iOSThemeConfigurations?.logoImage ?? "";
if (logoImage != "") {
arg.iOSThemeConfigurations?.logoImage = await handleImagePath(logoImage);
}
var argsMap = arg.map;
argsMap["support3DS"] = support3DS;
return await localChannel.invokeMethod(
'startPaymentWithSavedCards', argsMap);
}

static Future<dynamic> queryTransaction(
PaymentSdkConfigurationDetails arg,
PaymentSDKQueryConfiguration paymentSDKQueryConfiguration,
Expand Down Expand Up @@ -291,9 +272,4 @@ class FlutterPaytabsBridge {
localStream.receiveBroadcastStream().listen(eventsCallBack);
return await localChannel.invokeMethod('startApplePayPayment', arg.map);
}

static Future<dynamic> clearSavedCards() async {
MethodChannel localChannel = MethodChannel('flutter_paytabs_bridge');
return await localChannel.invokeMethod('clearSavedCards');
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_paytabs_bridge
description: Flutter plugin for Paytabs, used to handle payments using Card, Apms ... etc.
version: 2.6.20
version: 2.7.0
homepage: "https://github.com/paytabscom/flutter-sdk-bridge"
environment:
sdk: ">=2.12.0 <4.0.0"
Expand Down

0 comments on commit bfffdae

Please sign in to comment.