Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(POM-455): Adjust authorize endpoint payload #268

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,113 @@ import com.squareup.moshi.JsonClass
import java.util.Date

/**
* Request parameters used for invoice authorization.
* Request parameters for invoice authorization.
*
* @param invoiceId Invoice identifier to authorize.
* @param source Payment source to use for authorization.
* @param saveSource If you want us to save the payment source by creating a customer token during the authorization. Only supported with card payment source.
* @param incremental Boolean value indicating if authorization is incremental. Default value is _false_.
* @param enableThreeDS2 Boolean value indicating whether 3DS2 is enabled. Default value is _true_.
* @param preferredScheme Card scheme or co-scheme that should get priority if it is available.
* @param thirdPartySdkVersion Can be used for a 3DS2 request to indicate which third party SDK is used for the call.
* @param invoiceDetailsIds Can be used to to provide specific ids to indicate which of items provided in invoice details list are subject to capture.
* @param overrideMacBlocking Allows to specify if transaction blocking due to MasterCard Merchant Advice Code should be applied or not. Default value is _false_.
* @param initialSchemeTransactionId Allows to specify which scheme ID to use for subsequent CIT/MITs if applicable.
* @param autoCaptureAt You can set this property to arrange for the payment to be captured automatically after a time delay.
* @param captureAmount Amount of money to capture when partial captures are available. Note that this only applies if you are also using the [autoCaptureAt] option.
* @param authorizeOnly Boolean value indicating whether should only authorize the invoice or also capture it. Default value is _true_.
* @param allowFallbackToSale Boolean value indicating whether should fallback to sale if the gateway does not support separation between authorization and capture. Default value is _false_.
* @param clientSecret Client secret is a value of __X-ProcessOut-Client-Secret__ header of the invoice.
* @param metadata Additional metadata.
* @param[invoiceId] Identifier of invoice to authorize.
* @param[source] Payment source to use for authorization.
* @param[saveSource] Indicates whether we should save the payment source by creating a customer token during the authorization.
* Default value is _false_.
* @param[incremental] Indicates whether authorization is incremental.
* Default value is _false_.
* @param[enableThreeDS2] Indicates that request is coming directly from the frontend.
* It is used to understand if we can instantly step-up to 3DS.
* Value is always _true_.
* @param[preferredScheme] Card scheme or co-scheme that should get priority if it is available.
* @param[thirdPartySdkVersion] Can be used for a 3DS2 request to indicate which third party SDK is used for the call.
* @param[invoiceDetailsIds] Can be used to to provide specific IDs to indicate which of items provided in invoice details list are subject to capture.
* @param[overrideMacBlocking] Indicates whether transaction blocking should be applied due to MasterCard Merchant Advice Code.
* Default value is _false_.
* @param[initialSchemeTransactionId] Allows to specify which scheme ID to use for subsequent CIT/MITs if applicable.
* @param[autoCaptureAt] You can set this property to arrange for the payment to be captured automatically after a time delay.
* __Note:__ Preferably set auto capture date when creating the invoice.
* @param[captureAmount] Amount of money to capture when partial captures are available.
* __Note:__ This only applies if you are also using the [autoCaptureAt] option.
* @param[authorizeOnly] Indicates that payment should be authorized without capturing.
* __Note:__ You must capture the payment on the server if you use this option.
* Value is always _true_.
* @param[allowFallbackToSale] Indicates whether the payment should fallback to sale if the gateway does not support separation between authorization and capture.
* Default value is _false_.
* @param[clientSecret] Client secret is a value of __X-ProcessOut-Client-Secret__ header of the invoice.
* @param[metadata] Operation metadata.
*/
data class POInvoiceAuthorizationRequest(
data class POInvoiceAuthorizationRequest @Deprecated(message = "Use alternative constructor.") constructor(
val invoiceId: String,
val source: String,
val saveSource: Boolean = false,
val incremental: Boolean = false,
@Deprecated(message = "This property is an implementation detail and shouldn't be used.")
val enableThreeDS2: Boolean = true,
val preferredScheme: String? = null,
val thirdPartySdkVersion: String? = null,
@Deprecated(message = "This property is only available when capturing the invoice.")
val invoiceDetailsIds: List<String>? = null,
val overrideMacBlocking: Boolean = false,
val initialSchemeTransactionId: String? = null,
val autoCaptureAt: Date? = null,
val captureAmount: String? = null,
@Deprecated(message = "This property is only available when capturing the invoice.")
val authorizeOnly: Boolean = true,
val allowFallbackToSale: Boolean = false,
val clientSecret: String? = null,
val metadata: Map<String, String>? = null
)
) {

/**
* Request parameters for invoice authorization.
*
* @param[invoiceId] Identifier of invoice to authorize.
* @param[source] Payment source to use for authorization.
* @param[saveSource] Indicates whether we should save the payment source by creating a customer token during the authorization.
* Default value is _false_.
* @param[incremental] Indicates whether authorization is incremental.
* Default value is _false_.
* @param[preferredScheme] Card scheme or co-scheme that should get priority if it is available.
* @param[thirdPartySdkVersion] Can be used for a 3DS2 request to indicate which third party SDK is used for the call.
* @param[overrideMacBlocking] Indicates whether transaction blocking should be applied due to MasterCard Merchant Advice Code.
* Default value is _false_.
* @param[initialSchemeTransactionId] Allows to specify which scheme ID to use for subsequent CIT/MITs if applicable.
* @param[autoCaptureAt] You can set this property to arrange for the payment to be captured automatically after a time delay.
* __Note:__ Preferably set auto capture date when creating the invoice.
* @param[captureAmount] Amount of money to capture when partial captures are available.
* __Note:__ This only applies if you are also using the [autoCaptureAt] option.
* @param[allowFallbackToSale] Indicates whether the payment should fallback to sale if the gateway does not support separation between authorization and capture.
* Default value is _false_.
* @param[clientSecret] Client secret is a value of __X-ProcessOut-Client-Secret__ header of the invoice.
* @param[metadata] Operation metadata.
*/
constructor(
invoiceId: String,
source: String,
saveSource: Boolean = false,
incremental: Boolean = false,
preferredScheme: String? = null,
thirdPartySdkVersion: String? = null,
overrideMacBlocking: Boolean = false,
initialSchemeTransactionId: String? = null,
autoCaptureAt: Date? = null,
captureAmount: String? = null,
allowFallbackToSale: Boolean = false,
clientSecret: String? = null,
metadata: Map<String, String>? = null
) : this(
invoiceId = invoiceId,
source = source,
saveSource = saveSource,
incremental = incremental,
enableThreeDS2 = true,
preferredScheme = preferredScheme,
thirdPartySdkVersion = thirdPartySdkVersion,
invoiceDetailsIds = null,
overrideMacBlocking = overrideMacBlocking,
initialSchemeTransactionId = initialSchemeTransactionId,
autoCaptureAt = autoCaptureAt,
captureAmount = captureAmount,
authorizeOnly = true,
allowFallbackToSale = allowFallbackToSale,
clientSecret = clientSecret,
metadata = metadata
)
}

@JsonClass(generateAdapter = true)
internal data class InvoiceAuthorizationRequestWithDeviceData(
Expand All @@ -50,13 +120,11 @@ internal data class InvoiceAuthorizationRequestWithDeviceData(
val saveSource: Boolean,
val incremental: Boolean,
@Json(name = "enable_three_d_s_2")
val enableThreeDS2: Boolean,
val enableThreeDS2: Boolean = true,
@Json(name = "preferred_scheme")
val preferredScheme: String?,
@Json(name = "third_party_sdk_version")
val thirdPartySdkVersion: String?,
@Json(name = "invoice_detail_ids")
val invoiceDetailsIds: List<String>?,
@Json(name = "override_mac_blocking")
val overrideMacBlocking: Boolean,
@Json(name = "initial_scheme_transaction_id")
Expand All @@ -65,8 +133,6 @@ internal data class InvoiceAuthorizationRequestWithDeviceData(
val autoCaptureAt: Date?,
@Json(name = "capture_amount")
val captureAmount: String?,
@Json(name = "authorize_only")
val authorizeOnly: Boolean,
@Json(name = "allow_fallback_to_sale")
val allowFallbackToSale: Boolean,
val metadata: Map<String, String>?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,12 @@ internal class DefaultInvoicesRepository(
source = source,
saveSource = saveSource,
incremental = incremental,
enableThreeDS2 = enableThreeDS2,
preferredScheme = preferredScheme,
thirdPartySdkVersion = thirdPartySdkVersion,
invoiceDetailsIds = invoiceDetailsIds,
overrideMacBlocking = overrideMacBlocking,
initialSchemeTransactionId = initialSchemeTransactionId,
autoCaptureAt = autoCaptureAt,
captureAmount = captureAmount,
authorizeOnly = authorizeOnly,
allowFallbackToSale = allowFallbackToSale,
metadata = metadata,
deviceData = contextGraph.deviceData
Expand Down
1 change: 1 addition & 0 deletions sdk/src/main/kotlin/com/processout/sdk/core/POFailure.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class POFailure private constructor() {
invalidGatewayData("request.validation.invalid-gateway-data"),
invalidId("request.validation.invalid-id"),
invalidIpAddress("request.validation.invalid-ip-address"),
invalidInvoice("request.validation.invalid-invoice"),
invalidLegalDocument("request.validation.invalid-legal-document"),
invalidMetadata("request.validation.invalid-metadata"),
invalidName("request.validation.invalid-name"),
Expand Down