@@ -110,9 +110,7 @@ type BraintreeValidationErrorsCollectionLike = {
110110 deepErrors ?: ( ) => BraintreeValidationErrorLike [ ] ;
111111} ;
112112
113- type TransactionSaleResponse = Awaited <
114- ReturnType < Braintree . BraintreeGateway [ 'transaction' ] [ 'sale' ] >
115- > ;
113+ type TransactionSaleResponse = Awaited < ReturnType < Braintree . BraintreeGateway [ 'transaction' ] [ 'sale' ] > > ;
116114
117115/**
118116 * Subset of Braintree Result / transaction fields used when classifying failures
@@ -231,9 +229,7 @@ const getBraintreeErrorMessage = (response: BraintreeErrorResponseLike): string
231229 const settlementResponseText = response . transaction ?. processorSettlementResponseText ?. trim ( ) ;
232230 if ( settlementResponseText ) {
233231 const settlementResponseCode = response . transaction ?. processorSettlementResponseCode ?. trim ( ) ;
234- return settlementResponseCode
235- ? `${ settlementResponseText } (${ settlementResponseCode } )`
236- : settlementResponseText ;
232+ return settlementResponseCode ? `${ settlementResponseText } (${ settlementResponseCode } )` : settlementResponseText ;
237233 }
238234
239235 const validationErrors = getBraintreeValidationErrors ( response . errors ) . map ( formatBraintreeValidationError ) ;
@@ -277,9 +273,7 @@ export function throwOnBraintreeFailure(
277273 response . transaction ?. gatewayRejectionReason ||
278274 response . transaction ?. processorResponseText ||
279275 response . transaction ?. processorSettlementResponseText ;
280- const type = hasProcessorSignal
281- ? MedusaError . Types . PAYMENT_AUTHORIZATION_ERROR
282- : MedusaError . Types . INVALID_DATA ;
276+ const type = hasProcessorSignal ? MedusaError . Types . PAYMENT_AUTHORIZATION_ERROR : MedusaError . Types . INVALID_DATA ;
283277
284278 log ( `${ operation } failed` , new Error ( message ) , {
285279 ...context ,
@@ -405,9 +399,7 @@ class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
405399 * Whether sandbox test settlement is enabled (`testForceSettled` option and env is sandbox).
406400 */
407401 private isTestForceSettledEnabled ( ) : boolean {
408- return (
409- ! ! this . options_ . testForceSettled && this . options_ . environment . toLowerCase ( ) === 'sandbox'
410- ) ;
402+ return ! ! this . options_ . testForceSettled && this . options_ . environment . toLowerCase ( ) === 'sandbox' ;
411403 }
412404
413405 /**
@@ -507,7 +499,10 @@ class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
507499 const requiredFields = [ 'merchantId' , 'publicKey' , 'privateKey' , 'webhookSecret' , 'environment' ] ;
508500
509501 for ( const field of requiredFields ) {
510- if ( ! isDefined ( options [ field as keyof BraintreeOptions ] ) || typeof options [ field as keyof BraintreeOptions ] !== 'string' ) {
502+ if (
503+ ! isDefined ( options [ field as keyof BraintreeOptions ] ) ||
504+ typeof options [ field as keyof BraintreeOptions ] !== 'string'
505+ ) {
511506 throw new MedusaError (
512507 MedusaError . Types . INVALID_ARGUMENT ,
513508 `Required option "${ field } " is missing or invalid in Braintree plugin` ,
@@ -541,7 +536,10 @@ class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
541536 'testForceSettled' ,
542537 ] ;
543538 for ( const field of booleanFields ) {
544- if ( isDefined ( options [ field as keyof BraintreeOptions ] ) && typeof options [ field as keyof BraintreeOptions ] !== 'boolean' ) {
539+ if (
540+ isDefined ( options [ field as keyof BraintreeOptions ] ) &&
541+ typeof options [ field as keyof BraintreeOptions ] !== 'boolean'
542+ ) {
545543 throw new MedusaError (
546544 MedusaError . Types . INVALID_ARGUMENT ,
547545 `Option "${ field } " must be a boolean in Braintree plugin` ,
@@ -873,11 +871,7 @@ class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
873871 * @param context - Optional log context
874872 * @throws {MedusaError } Always throws
875873 */
876- private rethrowGatewayError (
877- error : unknown ,
878- operation : string ,
879- context ?: Record < string , unknown > ,
880- ) : never {
874+ private rethrowGatewayError ( error : unknown , operation : string , context ?: Record < string , unknown > ) : never {
881875 if ( MedusaError . isMedusaError ( error ) ) throw error ;
882876 this . logErrorDetail ( operation , error , context ) ;
883877 throw buildBraintreeError ( error , operation , this . logger , context ) ;
@@ -946,10 +940,7 @@ class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
946940 const transactionId = saleResponse . transaction ?. id ;
947941
948942 if ( ! transactionId ) {
949- throw new MedusaError (
950- MedusaError . Types . INVALID_DATA ,
951- 'Braintree sale succeeded without a transaction id' ,
952- ) ;
943+ throw new MedusaError ( MedusaError . Types . INVALID_DATA , 'Braintree sale succeeded without a transaction id' ) ;
953944 }
954945
955946 try {
@@ -1209,9 +1200,7 @@ class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
12091200 if ( ! this . options_ . testForceSettled ) return transaction ;
12101201
12111202 if ( ! this . isTestForceSettledEnabled ( ) ) {
1212- this . logger . warn (
1213- '[Braintree refund] testForceSettled ignored — only supported when environment is sandbox' ,
1214- ) ;
1203+ this . logger . warn ( '[Braintree refund] testForceSettled ignored — only supported when environment is sandbox' ) ;
12151204 return transaction ;
12161205 }
12171206
@@ -1289,11 +1278,9 @@ class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
12891278 transaction . id ,
12901279 ) ;
12911280 } catch ( error ) {
1292- this . rethrowGatewayError (
1293- error ,
1294- kind === 'voided' ? 'void Braintree transaction' : 'create Braintree refund' ,
1295- { transactionId : transaction . id } ,
1296- ) ;
1281+ this . rethrowGatewayError ( error , kind === 'voided' ? 'void Braintree transaction' : 'create Braintree refund' , {
1282+ transactionId : transaction . id ,
1283+ } ) ;
12971284 }
12981285 }
12991286
0 commit comments