|
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: 19/01/2017 |
|
9
|
|
|
* Time: 12:49 |
|
10
|
|
|
* File: PayInTranslator.php |
|
11
|
|
|
**/ |
|
12
|
|
|
|
|
13
|
|
|
namespace PartFire\MangoPayBundle\Models\DTOs\Translators; |
|
14
|
|
|
|
|
15
|
|
|
use MangoPay\Money; |
|
16
|
|
|
use MangoPay\PayIn; |
|
17
|
|
|
use MangoPay\PayInExecutionDetailsDirect; |
|
18
|
|
|
use MangoPay\PayInPaymentDetailsCard; |
|
19
|
|
|
use PartFire\MangoPayBundle\Models\DTOs\CardDirectPayIn; |
|
20
|
|
|
|
|
21
|
|
|
class PayInTranslator |
|
22
|
|
|
{ |
|
23
|
|
|
public function translateDtoToMangoPayInForDirectPayIn(CardDirectPayIn $cardDirectPayIn) |
|
24
|
|
|
{ |
|
25
|
|
|
$payIn = new PayIn(); |
|
26
|
|
|
$payIn->CreditedWalletId = $cardDirectPayIn->getCreditedWalletId(); |
|
27
|
|
|
$payIn->AuthorId = $cardDirectPayIn->getAuthorId(); |
|
28
|
|
|
$payIn->DebitedFunds = new Money(); |
|
29
|
|
|
$payIn->DebitedFunds->Amount = $cardDirectPayIn->getAmount(); |
|
30
|
|
|
$payIn->DebitedFunds->Currency = $cardDirectPayIn->getCurrency(); |
|
31
|
|
|
$payIn->Fees = new Money(); |
|
32
|
|
|
$payIn->Fees->Amount = $cardDirectPayIn->getFees(); |
|
33
|
|
|
$payIn->Fees->Currency = $cardDirectPayIn->getFeesCurrency(); |
|
34
|
|
|
|
|
35
|
|
|
// payment type as CARD |
|
36
|
|
|
$payIn->PaymentDetails = new PayInPaymentDetailsCard(); |
|
37
|
|
|
$payIn->PaymentDetails->CardType = $cardDirectPayIn->getCardType(); |
|
38
|
|
|
$payIn->PaymentDetails->CardId = $cardDirectPayIn->getCardId(); |
|
39
|
|
|
|
|
40
|
|
|
// execution type as DIRECT |
|
41
|
|
|
$payIn->ExecutionDetails = new PayInExecutionDetailsDirect(); |
|
42
|
|
|
$payIn->ExecutionDetails->SecureModeReturnURL = $cardDirectPayIn->getSecureModeReturnUrl(); |
|
43
|
|
|
return $payIn; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function translateMangoPayDirectPayInToDto(PayIn $payIn) |
|
47
|
|
|
{ |
|
48
|
|
|
$cardDirectPayIn = new CardDirectPayIn(); |
|
49
|
|
|
$cardDirectPayIn->setStatus($payIn->Status); |
|
50
|
|
|
$cardDirectPayIn->setCurrency($payIn->DebitedFunds->Currency); |
|
51
|
|
|
$cardDirectPayIn->setAmount($payIn->DebitedFunds->Amount); |
|
52
|
|
|
$cardDirectPayIn->setAuthorId($payIn->AuthorId); |
|
53
|
|
|
$cardDirectPayIn->setFees($payIn->Fees->Amount); |
|
54
|
|
|
$cardDirectPayIn->setFeesCurrency($payIn->Fees->Currency); |
|
55
|
|
|
$cardDirectPayIn->setCardId($payIn->PaymentDetails->CardId); |
|
56
|
|
|
$cardDirectPayIn->setCardType($payIn->PaymentDetails->CardType); |
|
57
|
|
|
$cardDirectPayIn->setSecureModeReturnUrl($payIn->ExecutionDetails->SecureModeReturnURL); |
|
58
|
|
|
$cardDirectPayIn->setSecureMode($payIn->ExecutionDetails->SecureMode); |
|
59
|
|
|
$cardDirectPayIn->setSecureModeReturnUrl($payIn->ExecutionDetails->SecureModeReturnURL); |
|
60
|
|
|
$cardDirectPayIn->setSecureModeRedirectUrl($payIn->ExecutionDetails->SecureModeRedirectURL); |
|
61
|
|
|
$cardDirectPayIn->setSecureModeNeeded($payIn->ExecutionDetails->SecureModeNeeded); |
|
62
|
|
|
return $cardDirectPayIn; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|