Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 8 additions & 7 deletions Demo/Application/Features/SEPADirectDebitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ class SEPADirectDebitViewController: PaymentButtonBaseViewController {
billingAddress.postalCode = "09456"
billingAddress.countryCodeAlpha2 = "FR"

let sepaDirectDebitRequest = BTSEPADirectDebitRequest()
sepaDirectDebitRequest.accountHolderName = "John Doe"
sepaDirectDebitRequest.iban = BTSEPADirectDebitTestHelper.generateValidSandboxIBAN()
sepaDirectDebitRequest.customerID = generateRandomCustomerID()
sepaDirectDebitRequest.mandateType = .oneOff
sepaDirectDebitRequest.billingAddress = billingAddress
sepaDirectDebitRequest.merchantAccountID = "EUR-sepa-direct-debit"
let sepaDirectDebitRequest = BTSEPADirectDebitRequest(
accountHolderName: "John Doe",
iban: BTSEPADirectDebitTestHelper.generateValidSandboxIBAN(),
customerID: generateRandomCustomerID(),
billingAddress: billingAddress,
mandateType: .oneOff,
merchantAccountID: "EUR-sepa-direct-debit"
)

sepaDirectDebitClient.tokenize(sepaDirectDebitRequest) { sepaDirectDebitNonce, error in
if let sepaDirectDebitNonce {
Expand Down
43 changes: 15 additions & 28 deletions Sources/BraintreeSEPADirectDebit/BTSEPADirectDebitRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,23 @@ import BraintreeCore
/// Parameters for creating a SEPA Direct Debit tokenization request.
@objcMembers public class BTSEPADirectDebitRequest: NSObject {

/// Required. The account holder name.
public var accountHolderName: String?

/// Required. The full IBAN.
public var iban: String?

/// Required. The customer ID.
public var customerID: String?
// MARK: - Internal Properties

/// Optional. The `BTSEPADebitMandateType`. If not set, defaults to `.oneOff`
public var mandateType: BTSEPADirectDebitMandateType?

/// Required. The user's billing address.
public var billingAddress: BTPostalAddress?

/// Optional. A non-default merchant account to use for tokenization.
public var merchantAccountID: String?

/// Optional. A locale code to use for creating a mandate.
/// See https://developer.paypal.com/reference/locale-codes/ for a list of possible values.
/// Locale code should be supplied as a BCP-47 formatted locale code.
public var locale: String?
let accountHolderName: String?
let iban: String?
let customerID: String?
let billingAddress: BTPostalAddress?
let mandateType: BTSEPADirectDebitMandateType?
let merchantAccountID: String?
let locale: String?

/// Initialize a new SEPA Direct Debit request.
/// - Parameters:
/// - accountHolderName:Required. The account holder name.
/// - iban: Required. The full IBAN.
/// - customerID: Required. The customer ID.
/// - mandateType: Optional. The `BTSEPADebitMandateType`. If not set, defaults to `.oneOff`
/// - billingAddress: Required. The user's billing address.
/// - accountHolderName: Optional. The account holder name.
/// - iban: Optional. The full IBAN.
/// - customerID: Optional. The customer ID.
/// - billingAddress: Optional. The user's billing address.
/// - mandateType: Optional. The `BTSEPADebitMandateType`. If not set, defaults to `.oneOff
/// - merchantAccountID: Optional. A non-default merchant account to use for tokenization.
/// - locale: Optional. A locale code to use for creating a mandate.
/// See https://developer.paypal.com/reference/locale-codes/ for a list of possible values.
Expand All @@ -45,16 +32,16 @@ import BraintreeCore
accountHolderName: String? = nil,
iban: String? = nil,
customerID: String? = nil,
mandateType: BTSEPADirectDebitMandateType? = .oneOff,
billingAddress: BTPostalAddress? = nil,
mandateType: BTSEPADirectDebitMandateType? = .oneOff,
merchantAccountID: String? = nil,
locale: String? = nil
) {
self.accountHolderName = accountHolderName
self.iban = iban
self.customerID = customerID
self.mandateType = mandateType
self.billingAddress = billingAddress
self.mandateType = mandateType
self.merchantAccountID = merchantAccountID
self.locale = locale
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AuthenticationServices
class BTSEPADirectDebitClient_Tests: XCTestCase {

var billingAddress = BTPostalAddress()
var sepaDirectDebitRequest = BTSEPADirectDebitRequest()
var sepaDirectDebitRequest: BTSEPADirectDebitRequest!
var mockAPIClient : MockAPIClient = MockAPIClient(authorization: "development_client_key")
let authorization: String = "sandbox_9dbg82cq_dcpspy2brwdjr3qn"

Expand All @@ -21,12 +21,13 @@ class BTSEPADirectDebitClient_Tests: XCTestCase {
billingAddress.postalCode = "09456"
billingAddress.countryCodeAlpha2 = "FR"

sepaDirectDebitRequest.accountHolderName = "John Doe"
sepaDirectDebitRequest.iban = "FR891751244434203564412313"
sepaDirectDebitRequest.customerID = "A0E243A0A200491D929D"
sepaDirectDebitRequest.mandateType = .oneOff
sepaDirectDebitRequest.billingAddress = billingAddress
sepaDirectDebitRequest.merchantAccountID = "eur_pwpp_multi_account_merchant_account"
sepaDirectDebitRequest = BTSEPADirectDebitRequest(
accountHolderName: "John Doe",
iban: "FR891751244434203564412313",
customerID: "A0E243A0A200491D929D",
billingAddress: billingAddress,
merchantAccountID: "eur_pwpp_multi_account_merchant_account"
)
}

func testTokenizeWithPresentationContext_callsCreateMandateWithError_returnsError_andSendsAnalytics() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import XCTest

class SEPADirectDebitAPI_Tests: XCTestCase {
var billingAddress = BTPostalAddress()
var sepaDirectDebitRequest = BTSEPADirectDebitRequest()
var sepaDirectDebitRequest: BTSEPADirectDebitRequest!
var successApprovalURL: String = ""
var mockAPIClient : MockAPIClient = MockAPIClient(authorization: "development_client_key")
let authorization: String = "sandbox_9dbg82cq_dcpspy2brwdjr3qn"
Expand Down Expand Up @@ -35,12 +35,14 @@ class SEPADirectDebitAPI_Tests: XCTestCase {
billingAddress.postalCode = "09456"
billingAddress.countryCodeAlpha2 = "FR"

sepaDirectDebitRequest.accountHolderName = "John Doe"
sepaDirectDebitRequest.iban = "FR891751244434203564412313"
sepaDirectDebitRequest.customerID = "A0E243A0A200491D929D"
sepaDirectDebitRequest.mandateType = .oneOff
sepaDirectDebitRequest.billingAddress = billingAddress
sepaDirectDebitRequest.merchantAccountID = "eur_pwpp_multi_account_merchant_account"
sepaDirectDebitRequest = BTSEPADirectDebitRequest(
accountHolderName: "John Doe",
iban: "FR891751244434203564412313",
customerID: "A0E243A0A200491D929D",
billingAddress: billingAddress,
mandateType: .oneOff,
merchantAccountID: "eur_pwpp_multi_account_merchant_account"
)

successApprovalURL = """
https://api.test19.stage.paypal.com/directdebit/mandate/authorize?cart_id=1JH42426EL748934W&auth_code=C21_A.AAdcUj4loKRxLtfw336KxbGY7dA7UsLJQTpZU3cE2h49eKkhN1OjFcLxxxzOGVzRiwOzGLlS_cS2BU4ZLKjMnR6lZSG2iQ
Expand All @@ -61,13 +63,6 @@ class SEPADirectDebitAPI_Tests: XCTestCase {
billingAddress.region = "fake-region"
billingAddress.postalCode = "fake-postal-code"
billingAddress.countryCodeAlpha2 = "fake-country-code"
sepaDirectDebitRequest.accountHolderName = "fake-name"
sepaDirectDebitRequest.iban = "fake-iban"
sepaDirectDebitRequest.customerID = "fake-customer-id"
sepaDirectDebitRequest.billingAddress = billingAddress
sepaDirectDebitRequest.merchantAccountID = "fake-account-id"
sepaDirectDebitRequest.locale = "fr-FR"

let sepaDirectDebitRequest = BTSEPADirectDebitRequest(
accountHolderName: "fake-name",
iban: "fake-iban",
Expand Down
Loading