Get payment using Connect and Test Env #219
-
Hello, thanks for all the effort to create this library 👍 🙏! I am currently implementing Mollie with it. I think I came around one edge case that seems not to work properly.
I would expect that it would try to retrieve the transaction with the I assume this behavior from this error message:
This is how I create the client for every request: // NewMollieService creates a new mollie client instance with the given token
func (m mollieService) newClient(token oauth2.Token) (*mollie.Client, error) {
tokenSource := m.authConfig.TokenSource(context.Background(), &token)
baseClient := oauth2.NewClient(context.Background(), tokenSource)
logrus.WithField("testMode", m.testMode).Info("testMode") // testMode=true
config := mollie.NewConfig(m.testMode, false, "NOT_NEEDED_HERE?")
mollieClient, err := mollie.NewClient(baseClient, config)
if err != nil {
logrus.WithError(err).Error("could not create mollie mollieClient")
return nil, err
}
return mollieClient, nil
} I am not sure, if this might be a bug or if I am using the client wrong. Thank you very much for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @mschewe, I appreciate you bringing this issue to our attention. I have a few theories and suggestions to: 1. Verify that it is operating in test-mode (which, as of right now, I believe it is not); and 2. Resolve the connect client problem. Verify that it is operating in test-mode// client initialization
tokenSource := m.authConfig.TokenSource(context.Background(), &token)
baseClient := oauth2.NewClient(context.Background(), tokenSource)
logrus.WithField("testMode", m.testMode).Info("testMode") // testMode=true
config := mollie.NewConfig(m.testMode, false, "NOT_NEEDED_HERE?")
mollieClient, err := mollie.NewClient(baseClient, config)
if err != nil {
logrus.WithError(err).Error("could not create mollie mollieClient")
return nil, err
}
// payment creation
res, payment, err := mollieClient.Payments.Create(context.Background(), &mollie.Payment{/*required values */}, nil)
if err != nil {
logrus.WithError(err).Error("payment creation failed")
}
// Check correct values are set
logrus.WithField("query-values", res.Request.URL.Query().Get("testmode")).Info("testmode query param") // should be true and is set by the global client config
logrus.WithField("payment-mode", payment.TestMode).Info("testmode inside payment") // should also be true and is set by the `PaymentsService.Create` method. Theories on why it is failing
This calls for either writing a method to handle the OAuth use case (similar to |
Beta Was this translation helpful? Give feedback.
Hello @mschewe, I appreciate you bringing this issue to our attention. I have a few theories and suggestions to: 1. Verify that it is operating in test-mode (which, as of right now, I believe it is not); and 2. Resolve the connect client problem.
Verify that it is operating in test-mode