Skip to content

Commit

Permalink
add ca support (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkong87 authored Nov 2, 2023
1 parent 01ed1bb commit fc9122c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Config implements ConfigInterface
const SUFFIX_CANADA = '_ca';
const KEY_ASLOWAS_DEVELOPER = 'affirm_aslowas_developer';
const KEY_PIXEL = 'affirm_pixel';
const PARTIAL_CAPTURE_COUNTRIES = ['USA', 'CAN'];
/**#@-*/

/**
Expand Down Expand Up @@ -743,7 +744,7 @@ public function getCheckoutFlowType()
*/
public function getPartialCapture($countryCode = self::COUNTRY_CODE_USA)
{
return $this->getConfigData('partial_capture') && $countryCode == self::COUNTRY_CODE_USA;
return $this->getConfigData('partial_capture') && in_array($countryCode, self::PARTIAL_CAPTURE_COUNTRIES);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Model/Plugin/Payment/CanCapturePartial.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CanCapturePartial
* Define constants
*/
const DEFAULT_COUNTRY_CODE = 'USA';
const PARTIAL_CAPTURE_COUNTRIES = ['USA', 'CAN'];

/**
* Constructor
Expand Down Expand Up @@ -58,7 +59,7 @@ public function afterCanCapturePartial(Payment $subject, $result)
$countryCode = $subject->getData()['additional_information']['country_code'];
}

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

0 comments on commit fc9122c

Please sign in to comment.