Skip to content

Commit 7fab1ea

Browse files
committed
fix sourceOfFunds and card issue
1 parent 381cd2b commit 7fab1ea

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

lib/ThreeDS.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Mastercard\Enums\MastercardApiOperations as ApiOp;
77
use Mastercard\Util\Factory;
8+
use phpDocumentor\Reflection\Types\This;
89

910
/**
1011
* Class ThreeDS
@@ -16,6 +17,9 @@ class ThreeDS extends ApiResource
1617
const OBJECT_NAME = "3DSecureId";
1718
const RETURN_OBJECT_NAME = "3DSecure";
1819

20+
const STATUS_DO_NOT_PROCEED = 'DO_NOT_PROCEED';
21+
const STATUS_PROCEED = 'PROCEED';
22+
1923
use ApiOperations\Retrieve;
2024
use ApiOperations\Update;
2125

@@ -100,4 +104,9 @@ public function acsEci()
100104
{
101105
return $this['3DSecure']['acsEci'] ?? '';
102106
}
107+
108+
public function needToProceed()
109+
{
110+
return (bool) $this->gatewayRecommendation() == self::STATUS_PROCEED;
111+
}
103112
}

lib/Transaction.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,52 @@ class Transaction extends ApiResource
2323
use ApiOperations\Retrieve;
2424

2525

26+
/**
27+
* @param $trans_id
28+
* @param $order_id
29+
* @param Factory $factory
30+
* @param null $opts
31+
* @return array|Transaction
32+
*/
2633
public static function pay($trans_id, $order_id, Factory $factory, $opts = null)
2734
{
2835
$params = $factory->apiOperation(ApiOp::PAY)->get();
2936
return static::update($order_id, $params, $opts, $trans_id);
3037
}
3138

39+
/**
40+
* @param $trans_id
41+
* @param $order_id
42+
* @param Factory $factory
43+
* @param null $opts
44+
* @return array|Transaction
45+
*/
3246
public static function void($trans_id, $order_id, Factory $factory, $opts = null)
3347
{
3448
$params = $factory->apiOperation(ApiOp::VOID)->get();
3549
return static::update($order_id, $params, $opts, $trans_id);
3650
}
3751

52+
/**
53+
* @param $trans_id
54+
* @param $order_id
55+
* @param Factory $factory
56+
* @param null $opts
57+
* @return array|Transaction
58+
*/
3859
public static function refund($trans_id, $order_id, Factory $factory, $opts = null)
3960
{
4061
$params = $factory->apiOperation(ApiOp::REFUND)->get();
4162
return static::update($order_id, $params, $opts, $trans_id);
4263
}
4364

65+
/**
66+
* @param $trans_id
67+
* @param $order_id
68+
* @param Factory $factory
69+
* @param null $opts
70+
* @return array|Transaction
71+
*/
4472
public static function verify($trans_id, $order_id, Factory $factory, $opts = null)
4573
{
4674
$params = $factory->apiOperation(ApiOp::VERIFY)->get();

lib/Util/ObjectBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,12 @@ public function get(): array
322322
}
323323

324324
if (!empty($this->card) || !empty($this->sourceOfFunds)) {
325-
$all_array = array_merge($this->card, $this->sourceOfFunds, $all_array);
325+
if (!empty($this->card) && !empty($this->sourceOfFunds)) {
326+
$this->card['sourceOfFunds']['type'] = $this->sourceOfFunds['sourceOfFunds']['type'];
327+
$all_array = array_merge($this->card, $all_array);
328+
} else {
329+
$all_array = array_merge($this->card, $this->sourceOfFunds, $all_array);
330+
}
326331
}
327332

328333
if (!empty($this->threeDS)) {

0 commit comments

Comments
 (0)