Skip to content

Commit

Permalink
Renamed OrderCancelResponse into OrderCancelResult and improved param…
Browse files Browse the repository at this point in the history
…eter names
  • Loading branch information
Robert-SD committed Nov 21, 2024
1 parent 6e6b94f commit 4754226
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 108 deletions.
37 changes: 19 additions & 18 deletions android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ data class DropInConfigurationDTO (
val preselectedPaymentMethodTitle: String? = null,
val paymentMethodNames: Map<String?, String?>? = null,
val isPartialPaymentSupported: Boolean

) {
companion object {
@Suppress("UNCHECKED_CAST")
Expand Down Expand Up @@ -1181,23 +1182,23 @@ data class ActionComponentConfigurationDTO (
}

/** Generated class from Pigeon that represents data sent in messages. */
data class OrderCancelResponseDTO (
val orderCancelResponseBody: Map<String?, Any?>,
val updatedPaymentMethods: Map<String?, Any?>? = null
data class OrderCancelResultDTO (
val orderCancelJson: Map<String?, Any?>,
val updatedPaymentMethodsJson: Map<String?, Any?>? = null

) {
companion object {
@Suppress("UNCHECKED_CAST")
fun fromList(list: List<Any?>): OrderCancelResponseDTO {
val orderCancelResponseBody = list[0] as Map<String?, Any?>
val updatedPaymentMethods = list[1] as Map<String?, Any?>?
return OrderCancelResponseDTO(orderCancelResponseBody, updatedPaymentMethods)
fun fromList(list: List<Any?>): OrderCancelResultDTO {
val orderCancelJson = list[0] as Map<String?, Any?>
val updatedPaymentMethodsJson = list[1] as Map<String?, Any?>?
return OrderCancelResultDTO(orderCancelJson, updatedPaymentMethodsJson)
}
}
fun toList(): List<Any?> {
return listOf<Any?>(
orderCancelResponseBody,
updatedPaymentMethods,
orderCancelJson,
updatedPaymentMethodsJson,
)
}
}
Expand Down Expand Up @@ -1308,7 +1309,7 @@ private object CheckoutPlatformInterfaceCodec : StandardMessageCodec() {
}
148.toByte() -> {
return (readValue(buffer) as? List<Any?>)?.let {
OrderCancelResponseDTO.fromList(it)
OrderCancelResultDTO.fromList(it)
}
}
149.toByte() -> {
Expand Down Expand Up @@ -1436,7 +1437,7 @@ private object CheckoutPlatformInterfaceCodec : StandardMessageCodec() {
stream.write(147)
writeValue(stream, value.toList())
}
is OrderCancelResponseDTO -> {
is OrderCancelResultDTO -> {
stream.write(148)
writeValue(stream, value.toList())
}
Expand Down Expand Up @@ -1696,7 +1697,7 @@ private object DropInPlatformInterfaceCodec : StandardMessageCodec() {
}
143.toByte() -> {
return (readValue(buffer) as? List<Any?>)?.let {
OrderCancelResponseDTO.fromList(it)
OrderCancelResultDTO.fromList(it)
}
}
144.toByte() -> {
Expand Down Expand Up @@ -1774,7 +1775,7 @@ private object DropInPlatformInterfaceCodec : StandardMessageCodec() {
stream.write(142)
writeValue(stream, value.toList())
}
is OrderCancelResponseDTO -> {
is OrderCancelResultDTO -> {
stream.write(143)
writeValue(stream, value.toList())
}
Expand All @@ -1800,7 +1801,7 @@ interface DropInPlatformInterface {
fun onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO)
fun onBalanceCheckResult(balanceCheckResponse: String)
fun onOrderRequestResult(orderRequestResponse: String)
fun onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO)
fun onOrderCancelResult(orderCancelResult: OrderCancelResultDTO)
fun cleanUpDropIn()

companion object {
Expand Down Expand Up @@ -1950,10 +1951,10 @@ interface DropInPlatformInterface {
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val orderCancelResponseArg = args[0] as OrderCancelResponseDTO
val orderCancelResultArg = args[0] as OrderCancelResultDTO
var wrapped: List<Any?>
try {
api.onOrderCancelResult(orderCancelResponseArg)
api.onOrderCancelResult(orderCancelResultArg)
wrapped = listOf<Any?>(null)
} catch (exception: Throwable) {
wrapped = wrapError(exception)
Expand Down Expand Up @@ -2191,7 +2192,7 @@ private object ComponentPlatformInterfaceCodec : StandardMessageCodec() {
}
148.toByte() -> {
return (readValue(buffer) as? List<Any?>)?.let {
OrderCancelResponseDTO.fromList(it)
OrderCancelResultDTO.fromList(it)
}
}
149.toByte() -> {
Expand Down Expand Up @@ -2319,7 +2320,7 @@ private object ComponentPlatformInterfaceCodec : StandardMessageCodec() {
stream.write(147)
writeValue(stream, value.toList())
}
is OrderCancelResponseDTO -> {
is OrderCancelResultDTO -> {
stream.write(148)
writeValue(stream, value.toList())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DeletedStoredPaymentMethodResultDTO
import DropInConfigurationDTO
import DropInFlutterInterface
import DropInPlatformInterface
import OrderCancelResponseDTO
import OrderCancelResultDTO
import PaymentEventDTO
import PaymentEventType
import PaymentResultDTO
Expand Down Expand Up @@ -134,8 +134,8 @@ class DropInPlatformApi(
DropInOrderRequestResultMessenger.sendResult(orderRequestResponse)
}

override fun onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) {
DropInOrderCancelResultMessenger.sendResult(orderCancelResponse)
override fun onOrderCancelResult(orderCancelResult: OrderCancelResultDTO) {
DropInOrderCancelResultMessenger.sendResult(orderCancelResult)
}

override fun cleanUpDropIn() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.adyen.checkout.flutter.dropIn.advanced

import DeletedStoredPaymentMethodResultDTO
import ErrorDTO
import OrderCancelResponseDTO
import OrderCancelResultDTO
import PaymentEventDTO
import PaymentEventType
import android.content.Intent
Expand Down Expand Up @@ -318,14 +318,14 @@ class AdvancedDropInService : DropInService(), LifecycleOwner {
}

private fun mapToOrderCancelDropInServiceResult(
orderCancelResponseDTO: OrderCancelResponseDTO?
orderCancelResponseDTO: OrderCancelResultDTO?
): DropInServiceResult? {
try {
val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelResponseBody?.let { JSONObject(it) }
val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelJson?.let { JSONObject(it) }
return when (val resultCode = orderCancelResponseBody?.optString(Constants.RESULT_CODE_KEY)) {
"Received" -> {
if (orderCancelResponseDTO.updatedPaymentMethods?.isNotEmpty() == true) {
val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethods
if (orderCancelResponseDTO.updatedPaymentMethodsJson?.isNotEmpty() == true) {
val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethodsJson
val paymentMethods =
PaymentMethodsApiResponse.SERIALIZER.deserialize(JSONObject(updatedPaymentMethods))
val orderResponse = OrderResponse.SERIALIZER.deserialize(orderCancelResponseBody)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.adyen.checkout.flutter.dropIn.advanced

import DeletedStoredPaymentMethodResultDTO
import OrderCancelResponseDTO
import OrderCancelResultDTO
import PaymentEventDTO
import androidx.lifecycle.LiveData
import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletionModel
Expand Down Expand Up @@ -149,14 +149,14 @@ class DropInOrderCancelPlatformMessenger : LiveData<Event<JSONObject>>() {
}
}

class DropInOrderCancelResultMessenger : LiveData<Event<OrderCancelResponseDTO>>() {
class DropInOrderCancelResultMessenger : LiveData<Event<OrderCancelResultDTO>>() {
companion object {
private val dropInOrderCancelResultMessenger =
DropInOrderCancelResultMessenger()

fun instance() = dropInOrderCancelResultMessenger

fun sendResult(value: OrderCancelResponseDTO) {
fun sendResult(value: OrderCancelResultDTO) {
dropInOrderCancelResultMessenger.postValue(Event(value))
}
}
Expand Down
14 changes: 7 additions & 7 deletions example/lib/repositories/adyen_drop_in_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,24 @@ class AdyenDropInRepository extends AdyenBaseRepository {
return service.postOrders(orderRequestBody);
}

Future<OrderCancelResponse> onCancelOrder(
Future<OrderCancelResult> onCancelOrder(
bool shouldUpdatePaymentMethods,
Map<String, dynamic> order,
) async {
final orderCancelRequestBody = <String, dynamic>{
"merchantAccount": Config.merchantAccount,
"order": order,
};
final Map<String, dynamic> orderCancelResponseBody =
final Map<String, dynamic> orderCancelJson =
await service.postOrdersCancel(orderCancelRequestBody);
final OrderCancelResponse orderCancelResponse =
OrderCancelResponse(orderCancelResponseBody: orderCancelResponseBody);
final OrderCancelResult orderCancelResult =
OrderCancelResult(orderCancelJson: orderCancelJson);
if (shouldUpdatePaymentMethods == true) {
final paymentMethods = await fetchPaymentMethods();
orderCancelResponse.updatedPaymentMethods = paymentMethods;
final paymentMethodsJson = await fetchPaymentMethods();
orderCancelResult.updatedPaymentMethodsJson = paymentMethodsJson;
}

return orderCancelResponse;
return orderCancelResult;
}

bool _hasOrderWithRemainingAmount(jsonResponse) {
Expand Down
40 changes: 20 additions & 20 deletions ios/Classes/PlatformApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1241,24 +1241,24 @@ struct ActionComponentConfigurationDTO {
}

/// Generated class from Pigeon that represents data sent in messages.
struct OrderCancelResponseDTO {
var orderCancelResponseBody: [String?: Any?]
var updatedPaymentMethods: [String?: Any?]?
struct OrderCancelResultDTO {
var orderCancelJson: [String?: Any?]
var updatedPaymentMethodsJson: [String?: Any?]?

static func fromList(_ list: [Any?]) -> OrderCancelResponseDTO? {
let orderCancelResponseBody = list[0] as! [String?: Any?]
let updatedPaymentMethods: [String?: Any?]? = nilOrValue(list[1])
static func fromList(_ list: [Any?]) -> OrderCancelResultDTO? {
let orderCancelJson = list[0] as! [String?: Any?]
let updatedPaymentMethodsJson: [String?: Any?]? = nilOrValue(list[1])

return OrderCancelResponseDTO(
orderCancelResponseBody: orderCancelResponseBody,
updatedPaymentMethods: updatedPaymentMethods
return OrderCancelResultDTO(
orderCancelJson: orderCancelJson,
updatedPaymentMethodsJson: updatedPaymentMethodsJson
)
}

func toList() -> [Any?] {
[
orderCancelResponseBody,
updatedPaymentMethods
orderCancelJson,
updatedPaymentMethodsJson
]
}
}
Expand Down Expand Up @@ -1307,7 +1307,7 @@ private class CheckoutPlatformInterfaceCodecReader: FlutterStandardReader {
case 147:
return MerchantInfoDTO.fromList(self.readValue() as! [Any?])
case 148:
return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?])
return OrderCancelResultDTO.fromList(self.readValue() as! [Any?])
case 149:
return OrderResponseDTO.fromList(self.readValue() as! [Any?])
case 150:
Expand Down Expand Up @@ -1392,7 +1392,7 @@ private class CheckoutPlatformInterfaceCodecWriter: FlutterStandardWriter {
} else if let value = value as? MerchantInfoDTO {
super.writeByte(147)
super.writeValue(value.toList())
} else if let value = value as? OrderCancelResponseDTO {
} else if let value = value as? OrderCancelResultDTO {
super.writeByte(148)
super.writeValue(value.toList())
} else if let value = value as? OrderResponseDTO {
Expand Down Expand Up @@ -1590,7 +1590,7 @@ private class DropInPlatformInterfaceCodecReader: FlutterStandardReader {
case 142:
return MerchantInfoDTO.fromList(self.readValue() as! [Any?])
case 143:
return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?])
return OrderCancelResultDTO.fromList(self.readValue() as! [Any?])
case 144:
return PaymentEventDTO.fromList(self.readValue() as! [Any?])
case 145:
Expand Down Expand Up @@ -1648,7 +1648,7 @@ private class DropInPlatformInterfaceCodecWriter: FlutterStandardWriter {
} else if let value = value as? MerchantInfoDTO {
super.writeByte(142)
super.writeValue(value.toList())
} else if let value = value as? OrderCancelResponseDTO {
} else if let value = value as? OrderCancelResultDTO {
super.writeByte(143)
super.writeValue(value.toList())
} else if let value = value as? PaymentEventDTO {
Expand Down Expand Up @@ -1686,7 +1686,7 @@ protocol DropInPlatformInterface {
func onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) throws
func onBalanceCheckResult(balanceCheckResponse: String) throws
func onOrderRequestResult(orderRequestResponse: String) throws
func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws
func onOrderCancelResult(orderCancelResult: OrderCancelResultDTO) throws
func cleanUpDropIn() throws
}

Expand Down Expand Up @@ -1806,9 +1806,9 @@ class DropInPlatformInterfaceSetup {
if let api {
onOrderCancelResultChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let orderCancelResponseArg = args[0] as! OrderCancelResponseDTO
let orderCancelResultArg = args[0] as! OrderCancelResultDTO
do {
try api.onOrderCancelResult(orderCancelResponse: orderCancelResponseArg)
try api.onOrderCancelResult(orderCancelResult: orderCancelResultArg)
reply(wrapResult(nil))
} catch {
reply(wrapError(error))
Expand Down Expand Up @@ -1988,7 +1988,7 @@ private class ComponentPlatformInterfaceCodecReader: FlutterStandardReader {
case 147:
return MerchantInfoDTO.fromList(self.readValue() as! [Any?])
case 148:
return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?])
return OrderCancelResultDTO.fromList(self.readValue() as! [Any?])
case 149:
return OrderResponseDTO.fromList(self.readValue() as! [Any?])
case 150:
Expand Down Expand Up @@ -2073,7 +2073,7 @@ private class ComponentPlatformInterfaceCodecWriter: FlutterStandardWriter {
} else if let value = value as? MerchantInfoDTO {
super.writeByte(147)
super.writeValue(value.toList())
} else if let value = value as? OrderCancelResponseDTO {
} else if let value = value as? OrderCancelResultDTO {
super.writeByte(148)
super.writeValue(value.toList())
} else if let value = value as? OrderResponseDTO {
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/dropIn/DropInPlatformApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class DropInPlatformApi: DropInPlatformInterface {
}
}

func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws {}
func onOrderCancelResult(orderCancelResult: OrderCancelResultDTO) throws {}

func cleanUpDropIn() {
sessionHolder.reset()
Expand Down
2 changes: 1 addition & 1 deletion lib/adyen_checkout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export 'src/common/model/checkout.dart';
export 'src/common/model/cse/encrypted_card.dart';
export 'src/common/model/cse/unencrypted_card.dart';
export 'src/common/model/order_response.dart';
export 'src/common/model/partial_payment/order_cancel_response.dart';
export 'src/common/model/partial_payment/order_cancel_result.dart';
export 'src/common/model/partial_payment/partial_payment.dart';
export 'src/common/model/payment_event.dart';
export 'src/common/model/payment_method_configurations/apple_pay/apple_pay_configuration.dart';
Expand Down

This file was deleted.

9 changes: 9 additions & 0 deletions lib/src/common/model/partial_payment/order_cancel_result.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class OrderCancelResult {
final Map<String, dynamic> orderCancelJson;
Map<String, dynamic>? updatedPaymentMethodsJson;

OrderCancelResult({
required this.orderCancelJson,
this.updatedPaymentMethodsJson,
});
}
4 changes: 2 additions & 2 deletions lib/src/common/model/partial_payment/partial_payment.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:adyen_checkout/src/common/model/partial_payment/order_cancel_response.dart';
import 'package:adyen_checkout/src/common/model/partial_payment/order_cancel_result.dart';

class PartialPayment {
Future<Map<String, dynamic>> Function(Map<String, dynamic> requestBody)
onCheckBalance;
Future<Map<String, dynamic>> Function() onRequestOrder;
Future<OrderCancelResponse> Function(
Future<OrderCancelResult> Function(
bool shouldUpdatePaymentMethods,
Map<String, dynamic> order,
) onCancelOrder;
Expand Down
Loading

0 comments on commit 4754226

Please sign in to comment.