Skip to content

Commit

Permalink
Started with integration of partial payments for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-SD committed Nov 18, 2024
1 parent a6d5f88 commit 92f9217
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Adyen
import Foundation

extension Balance: Decodable {

public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let availableAmount = try container.decode(Amount.self, forKey: .availableAmount)
let transactionLimit = try container.decodeIfPresent(Amount.self, forKey: .transactionLimit)
self = .init(availableAmount: availableAmount, transactionLimit: transactionLimit)
}

private enum CodingKeys: String, CodingKey {
case availableAmount = "balance"
case transactionLimit
}
}
12 changes: 12 additions & 0 deletions lib/src/drop_in/drop_in.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ class DropIn {
final Map<String, dynamic> submitDataDecoded = jsonDecode(submitData);
switch (advancedCheckout) {
case AdvancedCheckout it:
if (submitDataDecoded[Constants.submitDataKey].containsKey("order")) {
_mapOrderToCompactOrder(submitDataDecoded);
}

final PaymentEvent paymentEvent = await it.onSubmit(
submitDataDecoded[Constants.submitDataKey],
submitDataDecoded[Constants.submitExtraKey],
Expand All @@ -251,6 +255,14 @@ class DropIn {
}
}

void _mapOrderToCompactOrder(Map<String, dynamic> submitDataDecoded) {
final order = submitDataDecoded[Constants.submitDataKey]["order"];
submitDataDecoded[Constants.submitDataKey]["order"] = {
"pspReference": order["pspReference"],
"orderData": order["orderData"],
};
}

Future<PaymentEvent> _getOnAdditionalDetailsPaymentEvent(
PlatformCommunicationModel event, Checkout advancedCheckout) async {
switch (advancedCheckout) {
Expand Down

0 comments on commit 92f9217

Please sign in to comment.