Move boost payment requests to extension in own file
This commit is contained in:
parent
06382e44fb
commit
f4af994294
@ -1128,6 +1128,7 @@
|
||||
D943F3EF2892F89B008C0C8B /* NSELogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = D943F3EE2892F89B008C0C8B /* NSELogger.swift */; };
|
||||
D9517ABE292C596B00DDD37E /* Paypal+WebAuthentication.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9517ABD292C596B00DDD37E /* Paypal+WebAuthentication.swift */; };
|
||||
D9517AC0292C5A3900DDD37E /* Paypal+API.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9517ABF292C5A3900DDD37E /* Paypal+API.swift */; };
|
||||
D95C39E6296DE9E900A9DA23 /* OWSRequestFactory+BoostPayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = D95C39E5296DE9E900A9DA23 /* OWSRequestFactory+BoostPayments.swift */; };
|
||||
D95DA7ED28B560D1003996BA /* ConversationViewController+SystemMessageItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = D95DA7EC28B560D1003996BA /* ConversationViewController+SystemMessageItems.swift */; };
|
||||
D9668B2F291AF63500665298 /* SSKJobQueues.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9668B2E291AF63500665298 /* SSKJobQueues.swift */; };
|
||||
D9668B33291B03C200665298 /* SessionResetJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D231761DC7E8F10034FA89 /* SessionResetJob.swift */; };
|
||||
@ -3512,6 +3513,7 @@
|
||||
D943F3EE2892F89B008C0C8B /* NSELogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSELogger.swift; sourceTree = "<group>"; };
|
||||
D9517ABD292C596B00DDD37E /* Paypal+WebAuthentication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Paypal+WebAuthentication.swift"; sourceTree = "<group>"; };
|
||||
D9517ABF292C5A3900DDD37E /* Paypal+API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Paypal+API.swift"; sourceTree = "<group>"; };
|
||||
D95C39E5296DE9E900A9DA23 /* OWSRequestFactory+BoostPayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OWSRequestFactory+BoostPayments.swift"; sourceTree = "<group>"; };
|
||||
D95DA7EC28B560D1003996BA /* ConversationViewController+SystemMessageItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConversationViewController+SystemMessageItems.swift"; sourceTree = "<group>"; };
|
||||
D9668B2E291AF63500665298 /* SSKJobQueues.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSKJobQueues.swift; sourceTree = "<group>"; };
|
||||
D9668B34291B088200665298 /* SignalMessagingJobQueues.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignalMessagingJobQueues.swift; sourceTree = "<group>"; };
|
||||
@ -8222,6 +8224,7 @@
|
||||
F9C5CAE1289453B200548EEE /* Requests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D95C39E5296DE9E900A9DA23 /* OWSRequestFactory+BoostPayments.swift */,
|
||||
F9C5CAE4289453B200548EEE /* OWSRequestFactory.h */,
|
||||
F9C5CAE6289453B200548EEE /* OWSRequestFactory.m */,
|
||||
F9C5CAE2289453B200548EEE /* OWSRequestFactory.swift */,
|
||||
@ -11038,6 +11041,7 @@
|
||||
F9C5CC68289453B300548EEE /* OWSRecoverableDecryptionPlaceholder+Replace.swift in Sources */,
|
||||
F9C5CC6E289453B300548EEE /* OWSRecoverableDecryptionPlaceholder+SDS.swift in Sources */,
|
||||
F9C5CC85289453B300548EEE /* OWSRecoverableDecryptionPlaceholder.m in Sources */,
|
||||
D95C39E6296DE9E900A9DA23 /* OWSRequestFactory+BoostPayments.swift in Sources */,
|
||||
F9C5CDB9289453B400548EEE /* OWSRequestFactory.m in Sources */,
|
||||
F9C5CDB5289453B400548EEE /* OWSRequestFactory.swift in Sources */,
|
||||
F9C5CC52289453B300548EEE /* OWSRequestMaker.swift in Sources */,
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
//
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension OWSRequestFactory {
|
||||
private enum BoostApiPaths {
|
||||
private static let basePath = "v1/subscription/boost"
|
||||
|
||||
static let stripeCreatePaymentIntent = "\(basePath)/create"
|
||||
static let paypalCreatePayment = "\(basePath)/paypal/create"
|
||||
static let paypalConfirmPayment = "\(basePath)/paypal/confirm"
|
||||
}
|
||||
|
||||
/// A request to create a Stripe payment intent for a boost.
|
||||
static func boostStripeCreatePaymentIntent(
|
||||
integerMoneyValue: UInt,
|
||||
inCurrencyCode currencyCode: Currency.Code,
|
||||
level: UInt64
|
||||
) -> TSRequest {
|
||||
let request = TSRequest(url: URL(string: BoostApiPaths.stripeCreatePaymentIntent)!,
|
||||
method: HTTPMethod.post.methodName,
|
||||
parameters: ["currency": currencyCode.lowercased(),
|
||||
"amount": integerMoneyValue,
|
||||
"level": level])
|
||||
request.shouldHaveAuthorizationHeaders = false
|
||||
return request
|
||||
}
|
||||
|
||||
/// A request to create a PayPal payment for a boost.
|
||||
static func boostPaypalCreatePayment(
|
||||
integerMoneyValue: UInt,
|
||||
inCurrencyCode currencyCode: Currency.Code,
|
||||
level: UInt64,
|
||||
returnUrl: URL,
|
||||
cancelUrl: URL
|
||||
) -> TSRequest {
|
||||
let request = TSRequest(
|
||||
url: URL(string: BoostApiPaths.paypalCreatePayment)!,
|
||||
method: HTTPMethod.post.methodName,
|
||||
parameters: [
|
||||
"currency": currencyCode.lowercased(),
|
||||
"amount": integerMoneyValue,
|
||||
"level": level,
|
||||
"returnUrl": returnUrl.absoluteString,
|
||||
"cancelUrl": cancelUrl.absoluteString
|
||||
]
|
||||
)
|
||||
|
||||
request.shouldHaveAuthorizationHeaders = false
|
||||
return request
|
||||
}
|
||||
|
||||
/// A request to confirm a PayPal payment for a boost.
|
||||
static func boostPaypalConfirmPayment(
|
||||
integerMoneyValue: UInt,
|
||||
inCurrencyCode currencyCode: Currency.Code,
|
||||
level: UInt64,
|
||||
payerId: String,
|
||||
paymentId: String,
|
||||
paymentToken: String
|
||||
) -> TSRequest {
|
||||
let request = TSRequest(
|
||||
url: URL(string: BoostApiPaths.paypalConfirmPayment)!,
|
||||
method: HTTPMethod.post.methodName,
|
||||
parameters: [
|
||||
"currency": currencyCode.lowercased(),
|
||||
"amount": integerMoneyValue,
|
||||
"level": level,
|
||||
"payerId": payerId,
|
||||
"paymentId": paymentId,
|
||||
"paymentToken": paymentToken
|
||||
]
|
||||
)
|
||||
|
||||
request.shouldHaveAuthorizationHeaders = false
|
||||
return request
|
||||
}
|
||||
}
|
||||
@ -22,9 +22,6 @@ public extension OWSRequestFactory {
|
||||
static let textSecureProfileAvatarFormAPI = "v1/profile/form/avatar"
|
||||
static let textSecure2FAAPI = "v1/accounts/pin"
|
||||
static let textSecureRegistrationLockV2API = "v1/accounts/registration_lock"
|
||||
static let textSecureBoostStripeCreatePaymentIntent = "v1/subscription/boost/create"
|
||||
static let textSecureBoostPaypalCreatePayment = "v1/subscription/boost/paypal/create"
|
||||
static let textSecureBoostPaypalConfirmPayment = "v1/subscription/boost/paypal/confirm"
|
||||
static let textSecureGiftBadgePricesAPI = "v1/subscription/boost/amounts/gift"
|
||||
|
||||
static let textSecureHTTPTimeOut: TimeInterval = 10
|
||||
@ -69,71 +66,6 @@ public extension OWSRequestFactory {
|
||||
parameters: [:])
|
||||
}
|
||||
|
||||
/// A request to create a Stripe payment intent for a boost.
|
||||
static func boostStripeCreatePaymentIntent(
|
||||
integerMoneyValue: UInt,
|
||||
inCurrencyCode currencyCode: Currency.Code,
|
||||
level: UInt64
|
||||
) -> TSRequest {
|
||||
let request = TSRequest(url: URL(string: textSecureBoostStripeCreatePaymentIntent)!,
|
||||
method: HTTPMethod.post.methodName,
|
||||
parameters: ["currency": currencyCode.lowercased(),
|
||||
"amount": integerMoneyValue,
|
||||
"level": level])
|
||||
request.shouldHaveAuthorizationHeaders = false
|
||||
return request
|
||||
}
|
||||
|
||||
/// A request to create a PayPal payment for a boost.
|
||||
static func boostPaypalCreatePayment(
|
||||
integerMoneyValue: UInt,
|
||||
inCurrencyCode currencyCode: Currency.Code,
|
||||
level: UInt64,
|
||||
returnUrl: URL,
|
||||
cancelUrl: URL
|
||||
) -> TSRequest {
|
||||
let request = TSRequest(
|
||||
url: URL(string: textSecureBoostPaypalCreatePayment)!,
|
||||
method: HTTPMethod.post.methodName,
|
||||
parameters: [
|
||||
"currency": currencyCode.lowercased(),
|
||||
"amount": integerMoneyValue,
|
||||
"level": level,
|
||||
"returnUrl": returnUrl.absoluteString,
|
||||
"cancelUrl": cancelUrl.absoluteString
|
||||
]
|
||||
)
|
||||
|
||||
request.shouldHaveAuthorizationHeaders = false
|
||||
return request
|
||||
}
|
||||
|
||||
/// A request to confirm a PayPal payment for a boost.
|
||||
static func boostPaypalConfirmPayment(
|
||||
integerMoneyValue: UInt,
|
||||
inCurrencyCode currencyCode: Currency.Code,
|
||||
level: UInt64,
|
||||
payerId: String,
|
||||
paymentId: String,
|
||||
paymentToken: String
|
||||
) -> TSRequest {
|
||||
let request = TSRequest(
|
||||
url: URL(string: textSecureBoostPaypalConfirmPayment)!,
|
||||
method: HTTPMethod.post.methodName,
|
||||
parameters: [
|
||||
"currency": currencyCode.lowercased(),
|
||||
"amount": integerMoneyValue,
|
||||
"level": level,
|
||||
"payerId": payerId,
|
||||
"paymentId": paymentId,
|
||||
"paymentToken": paymentToken
|
||||
]
|
||||
)
|
||||
|
||||
request.shouldHaveAuthorizationHeaders = false
|
||||
return request
|
||||
}
|
||||
|
||||
static let batchIdentityCheckElementsLimit = 1000
|
||||
static func batchIdentityCheckRequest(elements: [[String: String]]) -> TSRequest {
|
||||
precondition(elements.count <= batchIdentityCheckElementsLimit)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user