diff --git a/Helper/User/LegalUserHelper.php b/Helper/User/LegalUserHelper.php index 7022784..c1b3334 100644 --- a/Helper/User/LegalUserHelper.php +++ b/Helper/User/LegalUserHelper.php @@ -172,7 +172,6 @@ protected function createDocument($fileContent, UserInterface $user, $type) $kycDocument = new KycDocument(); $kycDocument->UserId = $user->getMangoUserId(); $kycDocument->Type = $type; - $kycDocument->Status = KycDocumentStatus::ValidationAsked; $document = $this->mangopayHelper->Users->CreateKycDocument($user->getMangoUserId(), $kycDocument); @@ -181,6 +180,9 @@ protected function createDocument($fileContent, UserInterface $user, $type) $this->mangopayHelper->Users->CreateKycPage($user->getMangoUserId(), $document->Id, $page); + $document->Status = KycDocumentStatus::ValidationAsked; + + $this->mangopayHelper->Users->UpdateKycDocument($user->getMangoUserId(), $document); return $document; } diff --git a/Helper/WalletHelper.php b/Helper/WalletHelper.php index d8c65e1..2da7402 100644 --- a/Helper/WalletHelper.php +++ b/Helper/WalletHelper.php @@ -3,6 +3,8 @@ namespace Troopers\MangopayBundle\Helper; use Doctrine\ORM\EntityManager; +use MangoPay\Money; +use MangoPay\Transfer; use MangoPay\Wallet; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Troopers\MangopayBundle\Entity\UserInterface; @@ -65,4 +67,32 @@ public function getTransactions($walletId) { return $this->mangopayHelper->Wallets->GetTransactions($walletId); } + + public function createTransfer(UserInterface $debitedUser, UserInterface $creditedUser, int $debitedAmount, int $feesAmount, string $tag = null, UserInterface $author = null) + { + $tranfer = new Transfer(); + + $tranfer->CreditedWalletId = $creditedUser->getMangoWalletId(); + $tranfer->DebitedWalletId = $debitedUser->getMangoWalletId(); + $tranfer->CreditedUserId = $creditedUser->getMangoUserId(); + + $debited = new Money(); + $debited->Amount = $debitedAmount; + $debited->Currency = 'EUR'; + + $fees = new Money(); + $fees->Amount = $feesAmount; + $fees->Currency = 'EUR'; + + $tranfer->DebitedFunds = $debited; + $tranfer->Fees = $fees; + + $tranfer->Tag = $tag; + + if ($author) { + $tranfer->AuthorId = $author->getMangoUserId(); + } + + return $this->mangopayHelper->Transfers->Create($tranfer); + } }