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 1f6e5b8..66c5116 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -2,6 +2,7 @@ parameters: appventus_mangopay.mango_api.class: "AppVentus\\MangopayBundle\\Helper\\MangopayHelper" appventus_mangopay.payment_helper.class: "AppVentus\\MangopayBundle\\Helper\\PaymentHelper" appventus_mangopay.payment_direct_helper.class: "AppVentus\\MangopayBundle\\Helper\\PaymentDirectHelper" + 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" @@ -51,6 +52,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.form.card: class: %appventus_mangopay.form.card%