Skip to content

Commit

Permalink
Merge pull request #2 from james-ingold/payment-advice-code-fixes
Browse files Browse the repository at this point in the history
Fixes paypal#11 43 is invalid for PaymentAdviceCode
  • Loading branch information
james-ingold authored Nov 25, 2024
2 parents 649924c + 4d66fa5 commit 18ffd03
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 18ffd03

Please sign in to comment.