Skip to content

Commit

Permalink
habba babba
Browse files Browse the repository at this point in the history
  • Loading branch information
josemigallas committed Jan 31, 2023
1 parent 45270f8 commit b77edd4
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions app/helpers/payment_details_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ def braintree_form_data
threeDSecureEnabled: site_account.payment_gateway_options[:three_ds_enabled],
clientToken: braintree_authorization,
countriesList: merchant_countries,
errors: billing_address.errors,
billingAddress: has_billing_address? ? billing_address_data : empty_billing_address_data
}
end

# This smells of :reek:UtilityFunction so maybe move it to Account::BillingAddress or a presenter
# FIXME: this smells of :reek:UtilityFunction so maybe move it to Account::BillingAddress or a presenter
def billing_address_data # rubocop:disable Metrics/AbcSize
{
firstName: current_account.billing_address_first_name,
Expand Down
3 changes: 1 addition & 2 deletions app/javascript/packs/braintree_customer_form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ document.addEventListener('DOMContentLoaded', () => {
throw new Error('Braintree data was not provided')
}

const { billingAddress, clientToken, countriesList, errors, formActionPath, threeDSecureEnabled } = data
console.error(errors) // TODO: handle errors?
const { billingAddress, clientToken, countriesList, formActionPath, threeDSecureEnabled } = data

BraintreeFormWrapper({
billingAddress,
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/braintree_edit_form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ document.addEventListener('DOMContentLoaded', () => {
const authorization = document.getElementById('braintree_data')?.dataset.authorization

if (!authorization) {
return
throw new Error('Braintree authorization not found')
}

void getClient(authorization)
Expand Down
7 changes: 3 additions & 4 deletions app/javascript/src/PaymentGateways/braintree/braintree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const fields: HostedFieldFieldOptions = {
expirationDate: {
container: '#customer_credit_card_expiration_date',
placeholder: 'MM/YY'
// prefill: ''
}
} as const

Expand All @@ -43,7 +42,7 @@ const create3DSecure = (authorization: string, payload: HostedFieldsTokenizePayl
nonce: payload.nonce,
bin: payload.details.bin,
challengeRequested: true,
// @ts-expect-error This is supposed to be a string. braintree-web types are not officially supported and outdated. See https://braintree.github.io/braintree-web/current/ThreeDSecure.html#verifyCard
// @ts-expect-error Accordint to API docs, this is a tring. Types are outdated. See https://braintree.github.io/braintree-web/current/ThreeDSecure.html#verifyCard
amount: '0.0',
billingAddress: {
givenName: billingAddress.firstName,
Expand All @@ -55,9 +54,9 @@ const create3DSecure = (authorization: string, payload: HostedFieldsTokenizePayl
region: billingAddress.state,
countryCodeAlpha2: billingAddress.country
},
// @ts-expect-error This is supposed to be mandatory. braintree-web types are not officially supported and outdated. See https://braintree.github.io/braintree-web/current/ThreeDSecure.html#verifyCard
// @ts-expect-error Accordint to API docs this is mandatory. Types outdated. See https://braintree.github.io/braintree-web/current/ThreeDSecure.html#verifyCard
onLookupComplete: (data, next) => {
console.log(data) // TODO: is this relevant/useful?
console.log(data) // TODO: what is this lookup anr is it relevant/useful for us?
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
next()
}
Expand Down
1 change: 0 additions & 1 deletion app/javascript/src/PaymentGateways/braintree/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface BraintreeFormDataset {
billingAddress: BillingAddress;
clientToken: string;
countriesList: [string, string][];
errors: unknown;
formActionPath: string;
threeDSecureEnabled: boolean;
}

0 comments on commit b77edd4

Please sign in to comment.