Mangopay / mangopay2-php-sdk

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

Add `Id` on PayInRecurringRegistration #565

Closed AntoineLemaire closed 1 year ago

AntoineLemaire commented 2 years ago

It's not a big issue, but when we fetch a recurringRegistration by his ID $this->mangoPayApi->PayIns->GetRecurringRegistration('1234567');, the result does not have the ID:

image

This could be usefull when we work with a user and we don't know if he already has a recurringRegistration or not, so if not we create it:

public function getOrCreateRecurringRegistration($user): ?PayInRecurringRegistration
{
    $recurringRegistration = null;

    // Verify actual recurringRegistration
    if ($user->getRecurringRegistrationId()) {
        try {
            $recurringRegistration = $this->mangoPayApi->PayIns->GetRecurringRegistration($user->getRecurringRegistrationId());
        }catch (Exception $e) {
        }
    }

    if (null === $recurringRegistration) {
        // Return PayInRecurringRegistrationRequestResponse
        $recurringRegistration = $this->createRecurringRegistration($user);
    }

    return $recurringRegistration;
}

This function either return PayInRecurringRegistrationGet or PayInRecurringRegistrationRequestResponse, which both extends PayInRecurringRegistration, but only PayInRecurringRegistrationRequestResponse has Id

I also removed Status from PayInRecurringRegistrationRequestResponse because it's already present in PayInRecurringRegistration

iulian03 commented 1 year ago

@AntoineLemaire please update your PR with the latest version of master in order to merge. Thanks!

AntoineLemaire commented 1 year ago

@iulian03 done

iulian03 commented 1 year ago

@AntoineLemaire we've just merged a PR that should fix all tests. Please update your PR again with the master branch, thanks! Sorry you had to do it twice :)

AntoineLemaire commented 1 year ago

Updated