From bcd57469c114ee7ee1cffd3887ec027bfbd6b161 Mon Sep 17 00:00:00 2001 From: Paul Andrieux Date: Tue, 9 Apr 2019 12:21:22 +0200 Subject: [PATCH 1/4] add a method to transfer funds between wallets --- Helper/WalletHelper.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Helper/WalletHelper.php b/Helper/WalletHelper.php index d8c65e1..faeeb58 100644 --- a/Helper/WalletHelper.php +++ b/Helper/WalletHelper.php @@ -3,6 +3,7 @@ namespace Troopers\MangopayBundle\Helper; use Doctrine\ORM\EntityManager; +use MangoPay\Transfer; use MangoPay\Wallet; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Troopers\MangopayBundle\Entity\UserInterface; @@ -65,4 +66,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 = $debited; + $debited->Currency = 'EUR'; + + $fees = new Money(); + $fees->Amount = $fees; + $fees->Currency = 'EUR'; + + $tranfer->DebitedFunds = $debited; + $tranfer->Fees = $fees; + + $tranfer->Tag = $tag; + + if ($author) { + $tranfer->AuthorId = $author->getMangoUserId(); + } + + return $this->mangopayHelper->Transfers->Create($tranfer); + } } From e97f06cea7bb6e2cc01c165d68c849c6fe32144f Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Tue, 9 Apr 2019 16:42:05 +0200 Subject: [PATCH 2/4] Add missing import --- Helper/WalletHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Helper/WalletHelper.php b/Helper/WalletHelper.php index faeeb58..f725f9e 100644 --- a/Helper/WalletHelper.php +++ b/Helper/WalletHelper.php @@ -3,6 +3,7 @@ namespace Troopers\MangopayBundle\Helper; use Doctrine\ORM\EntityManager; +use MangoPay\Money; use MangoPay\Transfer; use MangoPay\Wallet; use Symfony\Component\EventDispatcher\EventDispatcherInterface; From 22f4bf254c421c90785bbd593b5115e875a2af82 Mon Sep 17 00:00:00 2001 From: Paul Andrieux Date: Tue, 9 Apr 2019 17:33:54 +0200 Subject: [PATCH 3/4] Update WalletHelper.php --- Helper/WalletHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Helper/WalletHelper.php b/Helper/WalletHelper.php index f725f9e..2da7402 100644 --- a/Helper/WalletHelper.php +++ b/Helper/WalletHelper.php @@ -77,11 +77,11 @@ public function createTransfer(UserInterface $debitedUser, UserInterface $credit $tranfer->CreditedUserId = $creditedUser->getMangoUserId(); $debited = new Money(); - $debited->Amount = $debited; + $debited->Amount = $debitedAmount; $debited->Currency = 'EUR'; $fees = new Money(); - $fees->Amount = $fees; + $fees->Amount = $feesAmount; $fees->Currency = 'EUR'; $tranfer->DebitedFunds = $debited; From aa19253dab355bf7cd39444ed47fcc0a0e183713 Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Thu, 11 Apr 2019 11:12:37 +0200 Subject: [PATCH 4/4] LegalUserHelper: ask validation after file upload --- Helper/User/LegalUserHelper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; }