Mangopay / mangopay2-php-sdk

PHP SDK for MANGOPAY
https://packagist.org/packages/mangopay/php-sdk-v2
MIT License
123 stars 133 forks source link

Fix idempotency response should return an Error object #654

Closed williamdes closed 1 day ago

williamdes commented 2 months ago

Before this PR it would build an invalid object and get the code in trouble. See:

MangoPay\Response {
  +StatusCode: "400"
  +ContentLength: ""
  +ContentType: "application/json"
  +Date: "Tue, 27 Aug 2024 09:00:05 GMT"
  +RequestURL: "https://api.sandbox.mangopay.com/v2.01/xxxx-dev/users/legal"
  +Resource: MangoPay\UserLegal {#2972
    +Id: "e97b2e7b-b5f6-4fce-8ff7-d55252da9bb1#1724749205"
    +Tag: null
    +CreationDate: null
    +PersonType: "LEGAL"
    +Email: null
    +KYCLevel: null
    +TermsAndConditionsAccepted: null
    +TermsAndConditionsAcceptedDate: null
    +UserCategory: null
    +Name: null
    +LegalPersonType: null
    +HeadquartersAddress: null
    +LegalRepresentativeFirstName: null
    +LegalRepresentativeLastName: null
    +LegalRepresentativeAddress: null
    +LegalRepresentativeEmail: null
    +LegalRepresentativeBirthday: null
    +LegalRepresentativeNationality: null
    +LegalRepresentativeCountryOfResidence: null
    +LegalRepresentativeProofOfIdentity: null
    +Statute: null
    +ProofOfRegistration: null
    +ShareholderDeclaration: null
    +CompanyNumber: null
  }
}

You can see that the Id is very wrong and start to understand where the problem is. This PR fixes it.

williamdes commented 2 months ago

@fredericdelordm can you please dispatch this PR for review please, it fixes an important bug