Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
* master:
  add a helper for bank wire

Conflicts:
	Resources/config/services.yml
  • Loading branch information
paulandrieux committed Sep 12, 2016
2 parents 517a038 + c20b3f1 commit f46b25f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
73 changes: 73 additions & 0 deletions Helper/BankwireHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
namespace AppVentus\MangopayBundle\Helper;

use AppVentus\MangopayBundle\AppVentusMangopayEvents;
use AppVentus\MangopayBundle\Entity\CardPreAuthorisation;
use AppVentus\MangopayBundle\Entity\Order;
use AppVentus\MangopayBundle\Entity\UserInterface;
use AppVentus\MangopayBundle\Event\CardRegistrationEvent;
use AppVentus\MangopayBundle\Event\PayInEvent;
use AppVentus\MangopayBundle\Event\PreAuthorisationEvent;
use AppVentus\MangopayBundle\Exception\MongopayPayInCreationException;
use MangoPay\CardPreAuthorization;
use MangoPay\CardRegistration;
use MangoPay\Money;
use MangoPay\PayIn;
use MangoPay\PayInExecutionDetailsDirect;
use MangoPay\PayInPaymentDetailsBankWire;
use MangoPay\PayInPaymentDetailsPreAuthorized;
use MangoPay\User;
use MangoPay\Wallet;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
*
* ref: appventus_mangopay.bankwire_helper
*
**/
class BankwireHelper
{
protected $mangopayHelper;

public function __construct(MangopayHelper $mangopayHelper)
{
$this->mangopayHelper = $mangopayHelper;
}

/**
* Create a bankWire as discribed here: https://docs.mangopay.com/endpoints/v2/payins#e288_the-direct-debit-web-payin-object
* @param Wallet $wallet
* @param $authorId
* @param $creditedUserId
* @param $amount
* @param $feesAmount
*
* @return PayIn
*/
public function bankwireToWallet(Wallet $wallet, $authorId, $creditedUserId, $amount, $feesAmount)
{
$debitedFunds = new Money();
$debitedFunds->Amount = $amount * 100;
$debitedFunds->Currency = 'EUR';
$fees = new Money();
$fees->Amount = $feesAmount;
$fees->Currency = 'EUR';
$payin = new PayIn();
$payin->CreditedWalletId = $wallet->Id;
$payin->ExecutionType = 'Direct';
$executionDetails = new PayInExecutionDetailsDirect();
$payin->ExecutionDetails = $executionDetails;
$paymentDetails = new PayInPaymentDetailsBankWire();
$paymentDetails->DeclaredDebitedFunds = $debitedFunds;
$paymentDetails->DeclaredFees = $fees;
$payin->PaymentDetails = $paymentDetails;
$payin->AuthorId = $authorId;
$payin->CreditedUserId = $creditedUserId;

$bankWire = $this->mangopayHelper->PayIns->Create($payin);

return $bankWire;
}

}
5 changes: 5 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ parameters:
appventus_mangopay.card_registration_helper.class: "AppVentus\\MangopayBundle\\Helper\\CardRegistrationHelper"
appventus_mangopay.payment_direct_helper.class: "AppVentus\\MangopayBundle\\Helper\\PaymentDirectHelper"
appventus_mangopay.payment_out_helper.class: "AppVentus\\MangopayBundle\\Helper\\PaymentOutHelper"
appventus_mangopay.bankwire_helper.class: "AppVentus\\MangopayBundle\\Helper\\BankwireHelper"
appventus_mangopay.user_helper.class: "AppVentus\\MangopayBundle\\Helper\\UserHelper"
appventus_mangopay.bank_information_helper.class: "AppVentus\\MangopayBundle\\Helper\\BankInformationHelper"
appventus_mangopay.wallet_helper.class: "AppVentus\\MangopayBundle\\Helper\\WalletHelper"
Expand Down Expand Up @@ -59,6 +60,10 @@ services:
- @appventus_mangopay.mango_api
- @router
- "@event_dispatcher"
appventus_mangopay.bankwire_helper:
class: %appventus_mangopay.bankwire_helper.class%
arguments:
- @appventus_mangopay.mango_api

appventus_mangopay.payment_out_helper:
class: %appventus_mangopay.payment_out_helper.class%
Expand Down

0 comments on commit f46b25f

Please sign in to comment.