|
1
|
|
|
<?php |
|
2
|
|
|
namespace Loevgaard\DandomainAltapayBundle\Manager; |
|
3
|
|
|
|
|
4
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
5
|
|
|
use Doctrine\Common\Persistence\ObjectRepository; |
|
6
|
|
|
use Loevgaard\DandomainAltapayBundle\Entity\CallbackInterface; |
|
7
|
|
|
use Loevgaard\DandomainAltapayBundle\Entity\OrderLineInterface; |
|
8
|
|
|
use Loevgaard\DandomainAltapayBundle\Entity\TerminalInterface; |
|
9
|
|
|
use Loevgaard\DandomainFoundationBundle\Manager\Manager; |
|
10
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @method CallbackInterface create() |
|
14
|
|
|
* @method delete(CallbackInterface $obj) |
|
15
|
|
|
* @method update(CallbackInterface $obj, $flush = true) |
|
16
|
|
|
*/ |
|
17
|
|
|
class CallbackManager extends Manager |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param Request $request |
|
21
|
|
|
* @return CallbackInterface |
|
22
|
|
|
*/ |
|
23
|
|
|
public function createCallbackFromRequest(Request $request) : CallbackInterface |
|
24
|
|
|
{ |
|
25
|
|
|
$fields = [ |
|
26
|
|
|
'shop_orderid' => 'orderId', |
|
27
|
|
|
'amount' => 'amount', |
|
28
|
|
|
'currency' => 'currency', |
|
29
|
|
|
'language' => 'language', |
|
30
|
|
|
'transaction_info' => 'transactionInfo', |
|
31
|
|
|
'status' => 'status', |
|
32
|
|
|
'error_message' => 'errorMessage', |
|
33
|
|
|
'merchant_error_message' => 'merchantErrorMessage', |
|
34
|
|
|
'cardholder_message_must_be_shown' => 'cardholderMessageMustBeShown', |
|
35
|
|
|
'transaction_id' => 'transactionId', |
|
36
|
|
|
'type' => 'type', |
|
37
|
|
|
'payment_status' => 'paymentStatus', |
|
38
|
|
|
'masked_credit_card' => 'maskedCreditCard', |
|
39
|
|
|
'blacklist_token' => 'blacklistToken', |
|
40
|
|
|
'credit_card_token' => 'creditCardToken', |
|
41
|
|
|
'nature' => 'nature', |
|
42
|
|
|
'require_capture' => 'requireCapture', |
|
43
|
|
|
'xml' => 'xml', |
|
44
|
|
|
'checksum' => 'checksum', |
|
45
|
|
|
'fraud_risk_score' => 'fraudRiskScore', |
|
46
|
|
|
'fraud_explanation' => 'fraudExplanation', |
|
47
|
|
|
'fraud_recommendation' => 'fraudRecommendation', |
|
48
|
|
|
'avs_code' => 'avsCode', |
|
49
|
|
|
'avs_text' => 'avsText', |
|
50
|
|
|
]; |
|
51
|
|
|
$obj = $this->create(); |
|
52
|
|
|
$obj->setRequest((string)$request); |
|
53
|
|
|
|
|
54
|
|
|
foreach ($fields as $key => $field) { |
|
55
|
|
|
$val = $request->get($key); |
|
56
|
|
|
if($val) { |
|
57
|
|
|
$setter = 'set'.ucfirst($field); |
|
58
|
|
|
$obj->{$setter}($val); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return $obj; |
|
63
|
|
|
} |
|
64
|
|
|
} |