Skip to content

Commit

Permalink
Merge branch 'v7' into update-btcard-parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
richherrera committed Oct 23, 2024
2 parents 6b1c65d + 6b3af91 commit 7f6c766
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 61 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* Update `BTVenmoRequest` to make all properties accessible on the initializer only vs via the dot syntax.
* BraintreeCard
* Update `BTCard` to make all properties accessible on the initializer only vs via the dot syntax.

* BraintreeSEPADirectDebit
* Update `BTSEPADirectDebitRequest` to make all properties accessible on the initializer only vs via the dot syntax.

## unreleased
* BraintreePayPal
* Add `BTPayPalRequest.userPhoneNumber` optional property
Expand Down
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
39 changes: 13 additions & 26 deletions Sources/BraintreeSEPADirectDebit/BTSEPADirectDebitRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,15 @@ 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?
var accountHolderName: String
var iban: String
var customerID: String
var billingAddress: BTPostalAddress
var mandateType: BTSEPADirectDebitMandateType?
var merchantAccountID: String?
var locale: String?

/// Initialize a new SEPA Direct Debit request.
/// - Parameters:
Expand All @@ -42,19 +29,19 @@ import BraintreeCore
/// 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 init(
accountHolderName: String? = nil,
iban: String? = nil,
customerID: String? = nil,
accountHolderName: String,
iban: String,
customerID: String,
billingAddress: BTPostalAddress,
mandateType: BTSEPADirectDebitMandateType? = .oneOff,
billingAddress: BTPostalAddress? = nil,
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
12 changes: 6 additions & 6 deletions Sources/BraintreeSEPADirectDebit/SEPADebitRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ struct SEPADebitRequest: Encodable {
self.accountHolderName = sepaDirectDebitRequest.accountHolderName
self.iban = sepaDirectDebitRequest.iban
self.billingAddress = BillingAddress(
streetAddress: sepaDirectDebitRequest.billingAddress?.streetAddress,
extendedAddress: sepaDirectDebitRequest.billingAddress?.extendedAddress,
locality: sepaDirectDebitRequest.billingAddress?.locality,
region: sepaDirectDebitRequest.billingAddress?.region,
postalCode: sepaDirectDebitRequest.billingAddress?.postalCode,
countryCodeAlpha2: sepaDirectDebitRequest.billingAddress?.countryCodeAlpha2
streetAddress: sepaDirectDebitRequest.billingAddress.streetAddress,
extendedAddress: sepaDirectDebitRequest.billingAddress.extendedAddress,
locality: sepaDirectDebitRequest.billingAddress.locality,
region: sepaDirectDebitRequest.billingAddress.region,
postalCode: sepaDirectDebitRequest.billingAddress.postalCode,
countryCodeAlpha2: sepaDirectDebitRequest.billingAddress.countryCodeAlpha2
)
}
}
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")!

override func setUp() {
Expand All @@ -20,12 +20,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")!
var mockCreateMandateResult = CreateMandateResult(json:
Expand Down Expand Up @@ -34,12 +34,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 @@ -54,19 +56,21 @@ class SEPADirectDebitAPI_Tests: XCTestCase {
}

func testCreateMandate_properlyFormatsPOSTBody() {
let sepaDirectDebitRequest = BTSEPADirectDebitRequest()
billingAddress.streetAddress = "fake-street-addres"
billingAddress.extendedAddress = "fake-extended-address"
billingAddress.locality = "fake-locality"
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",
customerID: "fake-customer-id",
billingAddress: billingAddress,
merchantAccountID: "fake-account-id",
locale: "fr-FR"
)

let api = SEPADirectDebitAPI(apiClient: mockAPIClient)
api.createMandate(sepaDirectDebitRequest: sepaDirectDebitRequest) { _, _ in }
Expand Down
4 changes: 4 additions & 0 deletions V7_MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _Documentation for v7 will be published to https://developer.paypal.com/braintre
1. [Supported Versions](#supported-versions)
1. [Card](#card)
1. [Venmo](#venmo)
1. [SEPA Direct Debit](#sepa-direct-debit)

## Supported Versions

Expand All @@ -32,3 +33,6 @@ All properties within `BTVenmoRequest` can only be accessed on the initializer v
```
let venmoRequest = BTVenmoRequest(paymentMethodUsage: .multiUse, vault: true, fallbackToWeb: true)
```

## SEPA Direct Debit
All properties within `BTSEPADirectDebitRequest` can only be accessed on the initializer vs via the dot syntax.

0 comments on commit 7f6c766

Please sign in to comment.