Skip to content

Commit

Permalink
changing tokenformat transormation
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed khairy committed Mar 25, 2021
1 parent fd3809d commit ec205aa
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ android {

dependencies {

implementation 'com.paytabs:payment-sdk:6.0.1'
implementation 'com.paytabs:payment-sdk:6.0.2-rc04'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.payment.paymentsdk.integrationmodels.PaymentSdkTokenFormatKt.createPaymentSdkTokenFormat;
import static com.payment.paymentsdk.integrationmodels.PaymentSdkTokeniseKt.createPaymentSdkTokenise;
import static com.payment.paymentsdk.integrationmodels.PaymentSdkTransactionClassKt.createPaymentSdkTransactionClass;

import android.app.Activity;
import android.content.Context;
Expand All @@ -18,7 +19,9 @@
import com.payment.paymentsdk.integrationmodels.PaymentSdkShippingDetails;
import com.payment.paymentsdk.integrationmodels.PaymentSdkTokenFormat;
import com.payment.paymentsdk.integrationmodels.PaymentSdkTokenise;
import com.payment.paymentsdk.integrationmodels.PaymentSdkTransactionClass;
import com.payment.paymentsdk.integrationmodels.PaymentSdkTransactionDetails;
import com.payment.paymentsdk.integrationmodels.PaymentSdkTransactionType;
import com.payment.paymentsdk.sharedclasses.interfaces.CallbackPaymentInterface;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -134,35 +137,15 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
.setMerchantCountryCode(paymentDetails.getString("pt_merchant_country_code"))
.setShippingData(shippingData)
.setCartId(orderId)
.setTransactionClass(createPaymentSdkTransactionClass(paymentDetails.getString("pt_transaction_class")))
.setTransactionType(PaymentSdkTransactionType.SALE)
.setTokenise(tokeniseType, tokenFormat)
.setTokenisationData(token, transRef)
.showBillingInfo(paymentDetails.getBoolean("pt_show_billing_info"))
.showShippingInfo(paymentDetails.getBoolean("pt_show_shipping_info"))
.forceShippingInfo(paymentDetails.getBoolean("pt_force_validate_shipping"))
.setScreenTitle(screenTitle)
.build();
String pt_samsung_token = paymentDetails.getString("pt_samsung_pay_token");
if (pt_samsung_token != null && pt_samsung_token.length() > 0)
PaymentSdkActivity.startSamsungPayment(activity, configData, pt_samsung_token, new CallbackPaymentInterface() {
@Override
public void onError(@NotNull PaymentSdkError err) {
eventSink.error(err.getCode() + "", err.getMsg(), new Gson().toJson(err));

}

@Override
public void onPaymentFinish(@NotNull PaymentSdkTransactionDetails paymentSdkTransactionDetails) {
eventSink.success(new Gson().toJson(paymentSdkTransactionDetails));

}

@Override
public void onPaymentCancel() {
eventSink.error("0", "Cancelled", "{}");

}
});
else
PaymentSdkActivity.startCardPayment(activity, configData, new CallbackPaymentInterface() {
@Override
public void onError(@NotNull PaymentSdkError err) {
Expand Down
3 changes: 3 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_paytabs_bridge/PaymentSdkLocale.dart';
import 'package:flutter_paytabs_bridge/PaymentSdkTokenFormat.dart';
import 'package:flutter_paytabs_bridge/PaymentSdkTokeniseType.dart';
import 'package:flutter_paytabs_bridge/flutter_paytabs_bridge.dart';
import 'package:flutter_paytabs_bridge/PaymentSdkTransactionClass.dart';

void main() {
runApp(MyApp());
Expand Down Expand Up @@ -50,12 +51,14 @@ class _MyAppState extends State<MyApp> {
clientKey: "CKKMDG-KDD262-TQTK22-GQGMHN",
cartId: "12433",
cartDescription: "Flowers",
transactionClass: PaymentSdkTransactionClass.ECOM,
merchantName: "Flowers Store",
screentTitle: "Pay with Card",
billingDetails: billingDetails,
shippingDetails: shippingDetails,
locale: PaymentSdkLocale.DEFAULT,
amount: 20.0,
token: "",
currencyCode: "AED",
merchantCountryCode: "ae",
tokenFormat: PaymentSdkTokenFormat.Hex32Format,
Expand Down
6 changes: 6 additions & 0 deletions lib/PaymentSdkConfigurationDetails.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:flutter_paytabs_bridge/PaymentSdkTransactionClass.dart';

import 'BaseBillingShippingInfo.dart';
import 'IOSThemeConfiguration.dart';
import 'PaymentSdkLocale.dart';
Expand Down Expand Up @@ -30,6 +32,7 @@ class PaymentSdkConfigurationDetails {
PaymentSdkLocale? locale;
PaymentSdkTokenFormat? tokenFormat;
PaymentSdkTokeniseType? tokeniseType;
PaymentSdkTransactionClass? transactionClass;
IOSThemeConfigurations? iOSThemeConfigurations;


Expand Down Expand Up @@ -59,13 +62,15 @@ class PaymentSdkConfigurationDetails {
this.hideCardScanner,
this.locale,
this.iOSThemeConfigurations,
this.transactionClass,
}) {
if (iOSThemeConfigurations == null)
iOSThemeConfigurations = IOSThemeConfigurations();
if(showBillingInfo==null)showBillingInfo=false;
if(showShippingInfo==null)showShippingInfo=false;
if(hideCardScanner==null)hideCardScanner=false;
if(forceShippingInfo==null)forceShippingInfo=false;
if(transactionClass==null)transactionClass=PaymentSdkTransactionClass.ECOM;
}
}

Expand Down Expand Up @@ -98,6 +103,7 @@ extension PaymentSdkConfigurationDetailsExtension
pt_merchant_id: this.merchantApplePayIndentifier,
pt_simplify_apple_pay_validation: this.simplifyApplePayValidation,
pt_hide_card_scanner: this.hideCardScanner,
pt_transaction_class: this.transactionClass?.name,
};
}
}
18 changes: 9 additions & 9 deletions lib/PaymentSdkTokenFormat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ enum PaymentSdkTokenFormat {
extension PaymentSdkTokenFormatExtension on PaymentSdkTokenFormat {
String? get name {
switch (this) {
case PaymentSdkTokenFormat.Hex32Format:
return 'hex32Format';
case PaymentSdkTokenFormat.NoneFormat:
return 'noneFormat';
return '1';
case PaymentSdkTokenFormat.Hex32Format:
return '2';
case PaymentSdkTokenFormat.AlphaNum20Format:
return 'alphaNum20Format';
case PaymentSdkTokenFormat.AlphaNum32Format:
return 'alphaNum32Format';
case PaymentSdkTokenFormat.Digit16Format:
return 'Digit16Format';
return '3';
case PaymentSdkTokenFormat.Digit22Format:
return 'digit22Format';
return '4';
case PaymentSdkTokenFormat.Digit16Format:
return '5';
case PaymentSdkTokenFormat.AlphaNum32Format:
return '6';
default:
return null;
}
Expand Down
12 changes: 12 additions & 0 deletions lib/PaymentSdkTransactionClass.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
enum PaymentSdkTransactionClass { ECOM, RECURRING }

extension PaymentSdkTransactionClassExtension on PaymentSdkTransactionClass {
String get name {
switch (this) {
case PaymentSdkTransactionClass.RECURRING:
return "recurring";
default:
return "ecom";
}
}
}
1 change: 1 addition & 0 deletions lib/flutter_paytabs_bridge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const String pt_samsung_pay_token = 'pt_samsung_pay_token';
const String pt_merchant_name = 'pt_merchant_name';
const String pt_merchant_id = "pt_merchant_id";
const String pt_server_ip = "pt_server_ip";
const String pt_transaction_class = "pt_transaction_class";
const String pt_hide_card_scanner = "pt_hide_card_scanner";
const String pt_simplify_apple_pay_validation = "pt_simplify_apple_pay_validation";
// Billing
Expand Down

0 comments on commit ec205aa

Please sign in to comment.