Fixes for fees and settings object

This commit is contained in:
David Bomba 2020-08-05 21:48:53 +10:00
parent 715fdf5e2d
commit a5d2ac2cb9
2 changed files with 15 additions and 5 deletions

View File

@ -475,8 +475,12 @@ class Client extends BaseModel implements HasLocalePreference
$valid_gateways = $gateways->filter(function ($method) use ($amount) { $valid_gateways = $gateways->filter(function ($method) use ($amount) {
if(isset($method->fees_and_limits)) if(isset($method->fees_and_limits)){
$fees_and_limits = $method->fees_and_limits->{"1"}; //sometimes the key value of the fees and limits object are not static,
//we have to harvest the key value as follows
$properties = array_keys(get_object_vars($method->fees_and_limits));
$fees_and_limits = $method->fees_and_limits->{$properties[0]};
}
else else
return true; return true;

View File

@ -63,7 +63,11 @@ class CompanyGatewayTest extends TestCase
$cg->save(); $cg->save();
$this->assertNotNull($cg->fees_and_limits); $this->assertNotNull($cg->fees_and_limits);
$this->assertNotNull($cg->fees_and_limits->{"1"});
$properties = array_keys(get_object_vars($cg->fees_and_limits));
$fees_and_limits = $cg->fees_and_limits->{$properties[0]};
$this->assertNotNull($fees_and_limits);
//confirm amount filtering works //confirm amount filtering works
@ -83,8 +87,10 @@ class CompanyGatewayTest extends TestCase
public function checkSieve($cg, $amount) public function checkSieve($cg, $amount)
{ {
if(isset($cg->fees_and_limits)) if(isset($cg->fees_and_limits)){
$fees_and_limits = $cg->fees_and_limits->{"1"}; $properties = array_keys(get_object_vars($cg->fees_and_limits));
$fees_and_limits = $cg->fees_and_limits->{$properties[0]};
}
else else
$passes = true; $passes = true;