@@ -92,7 +92,7 @@ func (p *paypalPaymentProvider) NewCharger(ctx context.Context, r *http.Request,
9292 }
9393
9494 return func (amount uint64 , currency string , order * models.Order , invoiceNumber int64 ) (string , error ) {
95- return p .charge (bp .PaypalID , bp .PaypalUserID , amount , currency , order , invoiceNumber )
95+ return p .charge (log , bp .PaypalID , bp .PaypalUserID , amount , currency , order , invoiceNumber )
9696 }, nil
9797}
9898
@@ -154,16 +154,10 @@ func (p *paypalPaymentProvider) updatePaymentWithOrder(paymentID string, order *
154154 }
155155
156156 _ , err := p .client .PatchPayment (paymentID , []paypalsdk.PaymentPatch {invoiceNumPatch , itemListPatch })
157- if err != nil {
158- switch e := err .(type ) {
159- case * paypalsdk.ErrorResponse :
160- fmt .Println (e .Details )
161- }
162- }
163157 return err
164158}
165159
166- func (p * paypalPaymentProvider ) charge (paymentID string , userID string , amount uint64 , currency string , order * models.Order , invoiceNumber int64 ) (string , error ) {
160+ func (p * paypalPaymentProvider ) charge (log logrus. FieldLogger , paymentID string , userID string , amount uint64 , currency string , order * models.Order , invoiceNumber int64 ) (string , error ) {
167161 payment , err := p .client .GetPayment (paymentID )
168162 if err != nil {
169163 return "" , err
@@ -183,7 +177,12 @@ func (p *paypalPaymentProvider) charge(paymentID string, userID string, amount u
183177 }
184178
185179 if err := p .updatePaymentWithOrder (paymentID , order , invoiceNumber ); err != nil {
186- return "" , errors .Wrap (err , "Updating the PayPal payment with order details failed" )
180+ log := log .WithError (err )
181+ switch e := err .(type ) {
182+ case * paypalsdk.ErrorResponse :
183+ log = log .WithField ("err_detail" , e .Details )
184+ }
185+ log .Warn ("Failed to update transaction with details" )
187186 }
188187
189188 executeResult , err := p .client .ExecuteApprovedPayment (paymentID , userID )
0 commit comments