|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by Carl Owens ([email protected]) |
|
4
|
|
|
* Company: PartFire Ltd (www.partfire.co.uk) |
|
5
|
|
|
* Copyright © 2017 PartFire Ltd. All rights reserved. |
|
6
|
|
|
* |
|
7
|
|
|
* User: Carl Owens |
|
8
|
|
|
* Date: 20/01/2017 |
|
9
|
|
|
* Time: 15:58 |
|
10
|
|
|
* File: PayOutTranslator.php |
|
11
|
|
|
**/ |
|
12
|
|
|
|
|
13
|
|
|
namespace PartFire\MangoPayBundle\Models\DTOs\Translators; |
|
14
|
|
|
|
|
15
|
|
|
use MangoPay\Money; |
|
16
|
|
|
use MangoPay\PayOut; |
|
17
|
|
|
use MangoPay\PayOutPaymentDetailsBankWire; |
|
18
|
|
|
use PartFire\MangoPayBundle\Models\DTOs\PayOutBankWire; |
|
19
|
|
|
|
|
20
|
|
|
class PayOutTranslator |
|
21
|
|
|
{ |
|
22
|
|
|
public function translatePayOutDtoToMango(PayOutBankWire $payOutBankWire) : PayOut |
|
23
|
|
|
{ |
|
24
|
|
|
$payOut = new PayOut(); |
|
25
|
|
|
$payOut->Tag = $payOutBankWire->getTag(); |
|
26
|
|
|
$payOut->AuthorId = $payOutBankWire->getAuthorId(); |
|
27
|
|
|
$payOut->DebitedWalletId = $payOutBankWire->getDebitedWalletId(); |
|
28
|
|
|
$payOut->DebitedFunds = new Money(); |
|
29
|
|
|
$payOut->DebitedFunds->Amount = $payOutBankWire->getDebitedFundsAmount(); |
|
30
|
|
|
$payOut->DebitedFunds->Currency = $payOutBankWire->getDebitedFundsCurrency(); |
|
31
|
|
|
$payOut->Fees = new Money(); |
|
32
|
|
|
$payOut->Fees->Amount = $payOutBankWire->getFeesAmount(); |
|
33
|
|
|
$payOut->Fees->Currency = $payOutBankWire->getFeesCurrency(); |
|
34
|
|
|
$payOut->PaymentType = $payOutBankWire->getPaymentType(); |
|
35
|
|
|
$payOut->MeanOfPaymentDetails = new PayOutPaymentDetailsBankWire(); |
|
36
|
|
|
$payOut->MeanOfPaymentDetails->BankAccountId = $payOutBankWire->getBankAccountId(); |
|
37
|
|
|
return $payOut; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function translateMangoToPayOutDto(PayOut $createdPayout) |
|
41
|
|
|
{ |
|
42
|
|
|
$payOutBankWire = new PayOutBankWire(); |
|
43
|
|
|
$payOutBankWire->setAuthorId($createdPayout->AuthorId); |
|
44
|
|
|
$payOutBankWire->setDebitedWalletId($createdPayout->CreditedWalletId); |
|
45
|
|
|
$payOutBankWire->setDebitedFundsAmount($createdPayout->DebitedFunds->Amount); |
|
46
|
|
|
$payOutBankWire->setDebitedFundsCurrency($createdPayout->DebitedFunds->Currency); |
|
47
|
|
|
$payOutBankWire->setFeesAmount($createdPayout->Fees->Amount); |
|
48
|
|
|
$payOutBankWire->setFeesCurrency($createdPayout->Fees->Currency); |
|
49
|
|
|
$payOutBankWire->setPaymentType($createdPayout->PaymentType); |
|
50
|
|
|
$payOutBankWire->setBankAccountId($createdPayout->MeanOfPaymentDetails->BankAccountId); |
|
51
|
|
|
$payOutBankWire->setTag($createdPayout->Tag); |
|
52
|
|
|
$payOutBankWire->setStatus($createdPayout->Status); |
|
53
|
|
|
$payOutBankWire->setNature($createdPayout->Nature); |
|
54
|
|
|
$payOutBankWire->setType($createdPayout->Type); |
|
55
|
|
|
$payOutBankWire->setBankWireRef($createdPayout->MeanOfPaymentDetails->BankWireRef); |
|
56
|
|
|
return $payOutBankWire; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|