Skip to content

Commit

Permalink
Merge branch 'feature/conversions' into feature/quoted_conversion
Browse files Browse the repository at this point in the history
# Conflicts:
#	MangoPay/Libraries/ApiBase.php
#	tests/Cases/ConversionsTest.php
  • Loading branch information
mihaimoiseanu committed Mar 7, 2024
2 parents 54a0656 + eb8ff0d commit f795725
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
14 changes: 7 additions & 7 deletions MangoPay/ApiConversions.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ public function GetInstantConversion($id)

/**
* This call guarantees a conversion rate to let you Create a Quoted Conversion.
* @param Quote $quote
* @return Quote
* @param ConversionQuote $quote
* @return ConversionQuote
*/
public function CreateQuote($quote)
public function CreateConversionQuote($quote)
{
return $this->CreateObject('create_conversion_quote', $quote, '\MangoPay\Quote');
return $this->CreateObject('create_conversion_quote', $quote, '\MangoPay\ConversionQuote');
}

/**
* This endpoint allows the platform to get the details of a quote
* @param string $quoteId
* @return Quote
* @return ConversionQuote
*/
public function GetQuote($quoteId)
public function GetConversionQuote($quoteId)
{
return $this->GetObject('get_conversion_quote', '\MangoPay\Quote', $quoteId);
return $this->GetObject('get_conversion_quote', '\MangoPay\ConversionQuote', $quoteId);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion MangoPay/Quote.php → MangoPay/ConversionQuote.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use MangoPay\Libraries\EntityBase;

class Quote extends EntityBase
class ConversionQuote extends EntityBase
{
/**
* Expiration date
Expand Down
7 changes: 7 additions & 0 deletions MangoPay/InstantConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,11 @@ class InstantConversion extends Libraries\EntityBase
* @var int
*/
public $ExecutionDate;

/**
* Information about the fees taken by the platform for
* this transaction (and hence transferred to the Fees Wallet).
* @var Money
*/
public $Fees;
}
6 changes: 3 additions & 3 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ protected function getLogger()
'deposits_get' => ['/deposit-preauthorizations/%s', RequestType::GET],
'deposits_cancel' => ['/deposit-preauthorizations/%s', RequestType::PUT],

'get_conversion_rate' => ['/conversion/rate/%s/%s', RequestType::GET],
'create_instant_conversion' => ['/instant-conversion', RequestType::POST],
'get_instant_conversion' => ['/instant-conversion/%s', RequestType::GET],
'get_conversion_rate' => ['/conversions/rate/%s/%s', RequestType::GET],
'create_instant_conversion' => ['/conversions/instant-conversion', RequestType::POST],
'get_instant_conversion' => ['/conversions/%s', RequestType::GET],
'create_conversion_quote' => ['/conversions/quote', RequestType::POST],
'get_conversion_quote' => ['/conversions/quote/%s', RequestType::GET],
'create_quoted_conversion' => ['/conversions/quoted-conversion', RequestType::POST],
Expand Down
22 changes: 14 additions & 8 deletions tests/Cases/ConversionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MangoPay\Tests\Cases;

use MangoPay\ConversionQuote;
use MangoPay\InstantConversion;
use MangoPay\Money;
use MangoPay\Quote;
Expand Down Expand Up @@ -43,9 +44,9 @@ public function test_getInstantConversion()
$this->assertSame(TransactionType::Conversion, $returnedInstantConversion->Type);
}

public function test_createQuote()
public function test_createConversionQuote()
{
$response = $this->createQuote();
$response = $this->createConversionQuote();

$this->assertNotNull($response);
$this->assertNotNull($response->DebitedFunds->Amount);
Expand All @@ -54,10 +55,10 @@ public function test_createQuote()
$this->assertSame('ACTIVE', $response->Status);
}

public function test_getQuote()
public function test_getConversionQuote()
{
$quote = $this->createQuote();
$response = $this->_api->Conversions->GetQuote($quote->Id);
$quote = $this->createConversionQuote();
$response = $this->_api->Conversions->GetConversionQuote($quote->Id);

$this->assertNotNull($response);
$this->assertNotNull($response->DebitedFunds->Amount);
Expand Down Expand Up @@ -117,15 +118,20 @@ private function createInstantConversion()
$debitedFunds->Amount = 79;
$instantConversion->DebitedFunds = $debitedFunds;

$fees = new Money();
$fees->Currency = 'EUR';
$fees->Amount = 9;
$instantConversion->Fees = $fees;

$instantConversion->Tag = "create instant conversion";

return $this->_api->Conversions->CreateInstantConversion($instantConversion);
}

private function createQuote()
private function createConversionQuote()
{

$quote = new Quote();
$quote = new ConversionQuote();
$creditedFunds = new Money();
$creditedFunds->Currency = 'GBP';
$quote->CreditedFunds = $creditedFunds;
Expand All @@ -138,6 +144,6 @@ private function createQuote()
$quote->Duration = 90;
$quote->Tag = "Created using the Mangopay PHP SDK";

return $this->_api->Conversions->CreateQuote($quote);
return $this->_api->Conversions->CreateConversionQuote($quote);
}
}

0 comments on commit f795725

Please sign in to comment.