Skip to content

Commit

Permalink
feat: integrate PaymentSDKCardApproval and update SDK dependencies
Browse files Browse the repository at this point in the history
- Upgraded PayTabs SDK to version 6.6.5 in build.gradle.
- Added PaymentSDKCardApproval handling in FlutterPaytabsBridgePlugin.java for enhanced card approval functionality.
- Refactored payment logic in main.dart for improved readability and added support for card approval.
- Updated dependencies in pubspec.lock, including leak_tracker, material_color_utilities, meta, and test_api.
- Introduced PaymentSDKCardApproval.dart to manage card approval details like validation URL and bin length.
  • Loading branch information
muhammadalkady committed Sep 16, 2024
1 parent 7644ad1 commit 521f56d
Show file tree
Hide file tree
Showing 6 changed files with 401 additions and 315 deletions.
42 changes: 21 additions & 21 deletions .idea/libraries/Dart_SDK.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.4'
implementation 'com.paytabs:payment-sdk:6.6.5'
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.payment.paymentsdk.integrationmodels.PaymentSDKQueryConfiguration;
import com.payment.paymentsdk.integrationmodels.PaymentSdkApms;
import com.payment.paymentsdk.integrationmodels.PaymentSdkBillingDetails;
import com.payment.paymentsdk.integrationmodels.PaymentSdkCardApproval;
import com.payment.paymentsdk.integrationmodels.PaymentSdkCardDiscount;
import com.payment.paymentsdk.integrationmodels.PaymentSdkConfigurationDetails;
import com.payment.paymentsdk.integrationmodels.PaymentSdkError;
Expand Down Expand Up @@ -379,6 +380,7 @@ private PaymentSdkConfigurationDetails getPaymentSdkConfigurationDetails(JSONObj
.isDigitalProduct(paymentDetails.optBoolean("pt_is_digital_product"))
.setPaymentExpiry(paymentScreenExpiry)
.setMetadata(getMetadata())
.setCardApproval(getCardApproval(paymentDetails))
.setCardDiscount(paymentSdkCardDiscounts).build();
}

Expand Down Expand Up @@ -411,6 +413,22 @@ private static List<PaymentSdkCardDiscount> getPaymentSdkCardDiscounts(JSONObjec
return paymentSdkCardDiscounts;
}

/**
* Retrieves the card approval details from the provided JSON object.
*
* @param paymentDetails The JSON object containing payment details.
* @return A PaymentSdkCardApproval object containing the card approval details, or null if not present.
*/
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")
);
}

public static String optString(JSONObject json, String key) {
if (json.isNull(key)) return "";
else return json.optString(key, null);
Expand Down
Loading

0 comments on commit 521f56d

Please sign in to comment.