gocardless / gocardless-dotnet

GoCardless .NET Client
https://developer.gocardless.com/api-reference/?lang=dotnet
MIT License
28 stars 15 forks source link

Internal Server Error when Posting a payment #22

Open dolphinsd opened 5 years ago

dolphinsd commented 5 years ago

Simple post payment with a mandate fails.

var paymentRequest = new GoCardless.Services.PaymentCreateRequest()
                {
                    Amount = (int)amount.Value,
                    Currency = cur,
                    Description = description,
                    Links = new GoCardless.Services.PaymentCreateRequest.PaymentLinks()
                    {
                        Mandate = mandate                   
                    }
                };

if (metadata != null)
  paymentRequest.Metadata = metadata;

var service = GoCardlessClient.Create(transactionKey, GoCardlessClient.Environment.SANDBOX);
var paymentResponse = await service.Payments.CreateAsync(paymentRequest);

In Sandbox, post method

{
 Method: POST, 
 RequestUri: 'https://api-sandbox.gocardless.com/payments',
 Version: 2.0,
 Content: System.Net.Http.StringContent, 
 Headers: { 
  User-Agent: gocardless-dotnet/2.15.0  
  GoCardless-Version: 2015-07-06  
  GoCardless-Client-Version: 2.15.0  
  GoCardless-Client-Library: gocardless-dotnet
  Authorization: Bearer sandbox__SIHdkkwccDVQTnFS3fELLOj9WSAjWhinsngy4SM  
  Idempotency-Key: d18aa3c3-9275-4d46-a55e-7aaf481099e7  
  Content-Type: application/json; charset=utf-8
  Content-Length: 361
 }
}

Response:

{
 StatusCode: 500, 
 ReasonPhrase: 'Internal Server Error', 
 Version: 1.1, 
 Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, 
 Headers: { 
  Date: Sun, 25 Aug 2019 20:28:19 GMT  
  X-Request-ID: 0AA40E33DD51_AC12054E1F90_5D62EF62_87BE90008  
  Strict-Transport-Security: max-age=31556926; includeSubDomains; preload  
  Vary: Origin  
  X-XSS-Protection: 1; mode=block  
  X-Content-Type-Options: nosniff  
  RateLimit-Limit: 1000 
  RateLimit-Remaining: 999  
  RateLimit-Reset: Sun, 25 Aug 2019 20:29:00 GMT  
  Via: 1.1 google
  Transfer-Encoding: chunked
  Alt-Svc: clear
  Content-Type: text/html
 }
}
danwakefield commented 5 years ago

Hi, It seems we are having issues returning the correct validation errors for US payments. In this case the error is that the customer you are trying to create a payment for does not have an address set which is mandatory for US payments.

If you update post_code, country, city, region and address_line_1 with the correct details in the edit view creating the payment should work. https://manage-sandbox.gocardless.com/customers/CU00076SGBKGYZ/edit

I've also raised a ticket for the relevant engineering team to ensure we start returning these errors correctly ASAP.

PS. The description of the error you have posted includes your sandbox access token. While sandbox will not move money, it being visible means that anyone can make requests for data in your sandbox account. Since we have no way of knowing if the data is sensitive we have to assume it is and as such I have disabled the access token in our system. I apologize for any inconvenience this may cause but the security of your data is our top priority

dolphinsd commented 5 years ago

@danwakefield thanks for an update. yes, your tip worked. another bug we found, that there are no way to simulate mandate for usd account. it says, no resource found when we tried.

dolphinsd commented 5 years ago

@danwakefield , out team suggests that for usd accounts you validate for customer address on CustomerBankAccountCreateRequest

danwakefield commented 5 years ago
  1. ACH mandates cannot be activated by themselves. The way they are activated in the real world is that a payment made against the mandate is successful. If you create a payment linked to the mandate and use the Payment Confirmed simulator on the payment ID then the mandate will becomes active. Screenshot 2019-08-28 at 10 28 17

  2. I've created a ticket so we can explore this but we're unable to guarantee if or when it would be completed as it would be a breaking change in how our API behaves.

If you need anymore help with our API our developer support team is available at api@gocardless.com