Skip to content

Commit

Permalink
Merge pull request #88 from Affirm/bugfix_PT-4099
Browse files Browse the repository at this point in the history
Refactor accessing country code data from payment attribute
  • Loading branch information
taehyunlim authored Oct 6, 2022
2 parents ac76b3f + 5d377de commit 78b777f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Model/Plugin/Payment/CanCapturePartial.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
*/
class CanCapturePartial
{
/**
* Define constants
*/
const DEFAULT_COUNTRY_CODE = 'USA';

/**
* Constructor
*
Expand All @@ -40,8 +45,12 @@ public function __construct(
*/
public function afterCanCapturePartial(Payment $subject, $result)
{
$countryCode = $subject->getData()['additional_information']['country_code'] ?: 'USA';
if (!$this->affirmPaymentConfig->getPartialCapture() || $countryCode != 'USA') {
$countryCode = self::DEFAULT_COUNTRY_CODE;
if (isset($subject->getData()['additional_information']['country_code'])) {
$countryCode = $subject->getData()['additional_information']['country_code'];
}

if (!$this->affirmPaymentConfig->getPartialCapture() || $countryCode != self::DEFAULT_COUNTRY_CODE) {
return false;
}
return $result;
Expand Down

0 comments on commit 78b777f

Please sign in to comment.