Skip to content

Commit

Permalink
Merge branch 'ericmp33-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheduardo committed Mar 5, 2024
2 parents e2636cd + bf05e88 commit 3d3b2fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/Sermepa/Tpv/Tpv.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ public function setTradeName($tradename = '')
* z = Bizum
* p = PayPal
* N = Masterpass
* xpay = GooglePay y ApplePay
* ]
*
* @return $this
Expand All @@ -639,7 +640,7 @@ public function setMethod($method = 'C')
throw new TpvException('Add pay method');
}

if (!in_array($method, ['T', 'C', 'R', 'D', 'z', 'p', 'N'])) {
if (!in_array($method, ['T', 'C', 'R', 'D', 'z', 'p', 'N', 'xpay'])) {
throw new TpvException('Pay method is not valid');
}

Expand Down
36 changes: 13 additions & 23 deletions tests/TpvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function merchant_direct_payment_return_false_or_true($boolean)
$redsys = new Tpv();
$redsys->setMerchantDirectPayment($boolean);
$ds = $redsys->getParameters();
$this->assertIsBool( $ds['DS_MERCHANT_DIRECTPAYMENT']);
$this->assertIsBool($ds['DS_MERCHANT_DIRECTPAYMENT']);
}

public function amountProvider()
Expand All @@ -58,7 +58,6 @@ public function amount_is_valid($correctAmount, $amount)
$redsys->setAmount($amount);
$ds = $redsys->getParameters();
$this->assertEquals($correctAmount, $ds['DS_MERCHANT_AMOUNT']);

}


Expand All @@ -72,7 +71,6 @@ public function sum_total_is_valid($correctAmount, $amount)
$redsys->setSumTotal($amount);
$ds = $redsys->getParameters();
$this->assertEquals($correctAmount, $ds['DS_MERCHANT_SUMTOTAL']);

}

/**
Expand Down Expand Up @@ -196,7 +194,6 @@ public function throw_when_order_is_invalid($orderNumber)
$this->expectException(\Sermepa\Tpv\TpvException::class);
$redsys = new Tpv();
$redsys->setOrder($orderNumber);

}

public function orderNumberProvider()
Expand Down Expand Up @@ -280,8 +277,6 @@ public function throw_environment_is_not_test_or_live()
$this->expectException(\Sermepa\Tpv\TpvException::class);
$redsys = new Tpv();
$redsys->setEnvironment('production');


}

public function SearchingFormProvider()
Expand All @@ -292,7 +287,6 @@ public function SearchingFormProvider()
['Ds_SignatureVersion'],
['btn_submit'],
];

}

/**
Expand All @@ -303,7 +297,7 @@ public function check_if_form_create_inputs_with_parameters($search)
{
$redsys = new Tpv();
$form = $redsys->createForm();
$this->assertStringContainsString($search,$form);
$this->assertStringContainsString($search, $form);
}

/**
Expand All @@ -314,7 +308,7 @@ public function when_set_all_parameters_should_obtain_all_ds_merchant_valid()
{
$redsys = new Tpv();
$redsys->setEnvironment('test')
->setAmount(rand(10,600))
->setAmount(rand(10, 600))
->setOrder(time())
->setMerchantcode('999008881')
->setCurrency('978')
Expand All @@ -338,7 +332,6 @@ public function when_set_all_parameters_should_obtain_all_ds_merchant_valid()
$this->assertArrayHasKey('DS_MERCHANT_MERCHANTURL', $parameters);
$this->assertArrayHasKey('DS_MERCHANT_URLOK', $parameters);
$this->assertArrayHasKey('DS_MERCHANT_URLKO', $parameters);

}

/**
Expand Down Expand Up @@ -383,8 +376,8 @@ public function check_if_url_of_tpv_is_test_or_live($environment, $url)
public function force_to_send_the_form_with_javascript()
{
$redsys = new Tpv();
$redsys->setNameForm('custom_form_'.date('His'));
$js = 'document.forms["'.$redsys->getNameForm().'"].submit();';
$redsys->setNameForm('custom_form_' . date('His'));
$js = 'document.forms["' . $redsys->getNameForm() . '"].submit();';

$redirect = $redsys->executeRedirection(true);

Expand Down Expand Up @@ -458,7 +451,6 @@ public function invalidExpiryDateProvider()
['am'],
['236'],
];

}

/**
Expand Down Expand Up @@ -503,11 +495,10 @@ public function invalidParameters()
[45],
[666],
[
[100,'R'],
[100, 'R'],
['Ds_store' => 233]
]
];

}

/**
Expand All @@ -522,24 +513,22 @@ public function throw_parameters_is_not_an_array($parameters)
$this->expectException(\Sermepa\Tpv\TpvException::class);
$redsys = new Tpv();

$redsys->setParameters($parameters);

$redsys->setParameters($parameters);
}

/**
* @test
*/

public function set_new_parameters()
{
public function set_new_parameters()
{
$parameters = ['DS_MERCHANT_COF_INI' => 'S', 'DS_MERCHANT_COF_TYPE' => 'R'];
$redsys = new Tpv();
$redsys->setParameters($parameters);

$this->assertArrayHasKey('DS_MERCHANT_COF_INI', $parameters);
$this->assertArrayHasKey('DS_MERCHANT_COF_TYPE', $parameters);

}
}

public function invalidSetMethod()
{
Expand All @@ -549,6 +538,7 @@ public function invalidSetMethod()
['X'],
['AA'],
['Np'],
['Xpay']
];
}

Expand All @@ -573,7 +563,8 @@ public function methodsProvider()
['D'],
['z'],
['p'],
['N']
['N'],
['xpay']
];
}

Expand Down Expand Up @@ -639,5 +630,4 @@ public function throw_when_set_environment_or_version_is_invalid($environment, $
$redsys = new Tpv();
$redsys->getJsPath($environment, $version);
}

}

0 comments on commit 3d3b2fc

Please sign in to comment.