Mpsdk Third Party Api
Denotes that the annotated element is part of a third-party Mobile Payments API. If you see this annotation in some 1P code or in a shared module, please try to replace the field with an equivalent non-3P class field. It might be already a fields in the same data class, e.g.
data class Output(
@MpsdkThirdPartyApi val payment: Payment, // Stop using this
val connectPayment: com.squareup.protos.connect.v2.Payment, // Use this instead
)
If there is no equivalent field in the same class, take a peek at the class instantiation, maybe the third-party object is being created there from a 1P object.
data class CardSwiped(
@MpsdkThirdPartyApi val card: Card,
val cardBytes: ByteArray,
)
// Class instantiation
output = CardSwiped(
card = swipeData.card.toV2Card(), // swipeData.card is a non-3P Card object, use it instead
cardBytes = swipeData.cardData.toByteArray(),
)
⬇
// Refactored class without 3P object
data class CardSwiped(
val card: com.squareup.Card,
val cardBytes: ByteArray,
)
Most commonly used third-party APIs and their 1P equivalents:
com.squareup.sdk.mobilepayments.payment.Payment ->com.squareup.protos.connect.v2.Payment
com.squareup.sdk.mobilepayments.payment.Card ->com.squareup.protos.connect.v2.resources.Card (from connect-v2 protos) or com.squareup.Card (from common/cardlib/public) or com.squareup.cardreader.CardDescription (from cardreader, pairs well with
CardreaderType
)com.squareup.sdk.mobilepayments.core.ErrorDetails ->com.squareup.protos.connect.v2.resources.Error
com.squareup.sdk.mobilepayments.payment.Money ->com.squareup.protos.connect.v2.common.Money
Third-party APIs usage should be limited to the following modules:
reader-sdk-2/api/
reader-sdk-2/authorization/
reader-sdk-2/cardreader/manager/
reader-sdk-2/core/
reader-sdk-2/demo-app/
reader-sdk-2/mockreader/
reader-sdk-2/mockreader-ui/
reader-sdk-2/payment/manager/
reader-sdk-2/payment/offline/impl
reader-sdk-2/settings/
There is a commented out @Deprecated
annotation on this annotation. It is left there to make it easier to find the places where MpsdkThirdPartyApi is used. Just uncomment it and the code will not compile until all the usages are fixed.