Skip to content

Commit

Permalink
Merge pull request #572 from Mangopay/bugfix/failing-tests
Browse files Browse the repository at this point in the history
fixed failing tests
  • Loading branch information
iulian03 authored Oct 18, 2022
2 parents e7e04cc + 35e3910 commit cfebe0b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
37 changes: 25 additions & 12 deletions tests/Cases/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ private function getPayInPaymentDetailsCard()
self::$PayInPaymentDetailsCard = new \MangoPay\PayInPaymentDetailsCard();
self::$PayInPaymentDetailsCard->CardType = 'CB_VISA_MASTERCARD';
self::$PayInPaymentDetailsCard->IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C";
self::$PayInPaymentDetailsCard->BrowserInfo = $this->getBrowserInfo();
}

return self::$PayInPaymentDetailsCard;
Expand Down Expand Up @@ -390,6 +391,8 @@ protected function getJohnsWalletWithMoneyAndCardId($amount = 1000)
// payment type as CARD
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardId = $card->Id;
$payIn->PaymentDetails->IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C";
$payIn->PaymentDetails->BrowserInfo = $this->getBrowserInfo();

// execution type as DIRECT
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
Expand Down Expand Up @@ -445,6 +448,8 @@ protected function getJohnsWalletWithMoney($amount = 1000)
// payment type as CARD
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardId = $card->Id;
$payIn->PaymentDetails->IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C";
$payIn->PaymentDetails->BrowserInfo = $this->getBrowserInfo();

// execution type as DIRECT
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
Expand Down Expand Up @@ -501,7 +506,7 @@ protected function getPaylineCorrectRegistrationData($cardRegistration)
*/
$data = 'data=' . $cardRegistration->PreregistrationData .
'&accessKeyRef=' . $cardRegistration->AccessKey .
'&cardNumber=4972485830400064' .
'&cardNumber=4970105191923460' .
'&cardExpirationDate=1224' .
'&cardCvx=123';

Expand Down Expand Up @@ -658,6 +663,7 @@ protected function getNewPayInCardDirect($userId = null)
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardId = $card->Id;
$payIn->PaymentDetails->IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C";
$payIn->PaymentDetails->BrowserInfo = $this->getBrowserInfo();
// execution type as DIRECT
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->SecureModeReturnURL = 'http://test.com';
Expand Down Expand Up @@ -714,17 +720,7 @@ protected function getNewPayInCardDirect3DSecure($userId = null)
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardId = $card->Id;
$payIn->PaymentDetails->IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C";
$browserInfo = new BrowserInfo();
$browserInfo->AcceptHeader = "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8";
$browserInfo->JavaEnabled = true;
$browserInfo->Language = "FR-FR";
$browserInfo->ColorDepth = 4;
$browserInfo->ScreenHeight = 1800;
$browserInfo->ScreenWidth = 400;
$browserInfo->JavascriptEnabled = true;
$browserInfo->TimeZoneOffset = "+60";
$browserInfo->UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148";
$payIn->PaymentDetails->BrowserInfo = $browserInfo;
$payIn->PaymentDetails->BrowserInfo = $this->getBrowserInfo();
// execution type as DIRECT
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->SecureModeReturnURL = 'http://test.com';
Expand Down Expand Up @@ -863,6 +859,7 @@ protected function getJohnsCardPreAuthorization($idempotencyKey = null)
$cardPreAuthorization->CardId = $getCardRegistration->CardId;
$cardPreAuthorization->SecureModeReturnURL = 'http://test.com';
$cardPreAuthorization->IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C";
$cardPreAuthorization->BrowserInfo = $this->getBrowserInfo();

$address = new \MangoPay\Address();
$address->AddressLine1 = 'Main Street no 5';
Expand Down Expand Up @@ -1225,4 +1222,20 @@ protected function getClientBankAccount()

return $account;
}

protected function getBrowserInfo()
{
$browserInfo = new BrowserInfo();
$browserInfo->AcceptHeader = "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8";
$browserInfo->JavaEnabled = true;
$browserInfo->Language = "FR-FR";
$browserInfo->ColorDepth = 4;
$browserInfo->ScreenHeight = 1800;
$browserInfo->ScreenWidth = 400;
$browserInfo->JavascriptEnabled = true;
$browserInfo->TimeZoneOffset = "+60";
$browserInfo->UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148";

return $browserInfo;
}
}
5 changes: 5 additions & 0 deletions tests/Cases/IdempotencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,15 @@ public function test_GetIdempotencyKey_PayinsCardDirectCreate()
$payIn->Fees = new \MangoPay\Money();
$payIn->Fees->Amount = 0;
$payIn->Fees->Currency = 'EUR';

$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardId = $card->Id;
$payIn->PaymentDetails->IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C";
$payIn->PaymentDetails->BrowserInfo = $this->getBrowserInfo();

$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->SecureModeReturnURL = 'http://test.com';

$this->_api->PayIns->Create($payIn, $key);

$resp = $this->_api->Responses->Get($key);
Expand Down
24 changes: 2 additions & 22 deletions tests/Cases/PayInsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,7 @@ public function test_Create_Recurring_PayIn_CIT()
$cit->SecureModeReturnURL = "http://www.my-site.com/returnurl";
$cit->StatementDescriptor = "lorem";
$cit->Tag = "custom meta";
$browserInfo = new BrowserInfo();
$browserInfo->AcceptHeader = "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8";
$browserInfo->JavaEnabled = true;
$browserInfo->Language = "FR-FR";
$browserInfo->ColorDepth = 4;
$browserInfo->ScreenHeight = 1800;
$browserInfo->ScreenWidth = 400;
$browserInfo->JavascriptEnabled = true;
$browserInfo->TimeZoneOffset = "+60";
$browserInfo->UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148";
$cit->BrowserInfo = $browserInfo;
$cit->BrowserInfo = $this->getBrowserInfo();

$result = $this->_api->PayIns->CreateRecurringPayInRegistrationCIT($cit);

Expand Down Expand Up @@ -619,17 +609,7 @@ public function test_Create_Recurring_PayIn_CIT_With_Debited_Funds_And_Fees()
$cit->SecureModeReturnURL = "http://www.my-site.com/returnurl";
$cit->StatementDescriptor = "lorem";
$cit->Tag = "custom meta";
$browserInfo = new BrowserInfo();
$browserInfo->AcceptHeader = "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8";
$browserInfo->JavaEnabled = true;
$browserInfo->Language = "FR-FR";
$browserInfo->ColorDepth = 4;
$browserInfo->ScreenHeight = 1800;
$browserInfo->ScreenWidth = 400;
$browserInfo->JavascriptEnabled = true;
$browserInfo->TimeZoneOffset = "+60";
$browserInfo->UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148";
$cit->BrowserInfo = $browserInfo;
$cit->BrowserInfo = $this->getBrowserInfo();
$cit->DebitedFunds = new Money();
$cit->DebitedFunds->Amount = 10;
$cit->DebitedFunds->Currency = 'EUR';
Expand Down

0 comments on commit cfebe0b

Please sign in to comment.