Skip to content

Commit

Permalink
Fixes paypal#11 43 is invalid for PaymentAdviceCode
Browse files Browse the repository at this point in the history
Added a new constant ENUM_43 with the value '43'
Including self::ENUM_43 in the _ALL_VALUES array
Updates ProcessorResponse class to handle unknown payment advice codes gracefully
  • Loading branch information
james-ingold committed Nov 21, 2024
1 parent de24c9e commit 4d66fa5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Models/PaymentAdviceCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class PaymentAdviceCode

public const ENUM_21 = '21';

private const _ALL_VALUES = [self::ENUM_01, self::ENUM_02, self::ENUM_03, self::ENUM_21];
public const ENUM_43 = '43';

private const _ALL_VALUES = [self::ENUM_01, self::ENUM_02, self::ENUM_03, self::ENUM_21, self::ENUM_43];

/**
* Ensures that all the given values are present in this Enum.
Expand Down
7 changes: 6 additions & 1 deletion src/Models/ProcessorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ public function jsonSerialize(bool $asArrayWhenEmpty = false)
$json['response_code'] = ProcessorResponseCode::checkValue($this->responseCode);
}
if (isset($this->paymentAdviceCode)) {
$json['payment_advice_code'] = PaymentAdviceCode::checkValue($this->paymentAdviceCode);
try {
$json['payment_advice_code'] = PaymentAdviceCode::checkValue($this->paymentAdviceCode);
} catch (Exception $e) {
// If the payment advice code is not recognized, just pass it through as-is
$json['payment_advice_code'] = $this->paymentAdviceCode;
}
}

return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
Expand Down

0 comments on commit 4d66fa5

Please sign in to comment.