diff --git a/Helper/BankwireHelper.php b/Helper/BankwireHelper.php new file mode 100644 index 0000000..cc3ef8d --- /dev/null +++ b/Helper/BankwireHelper.php @@ -0,0 +1,73 @@ +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; + } + +} diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 1003a2d..73d23cb 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -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" @@ -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%