|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Oledrion; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
You may not change or alter any portion of this comment or credits |
|
7
|
|
|
of supporting developers from this source code or any supporting source code |
|
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
|
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* oledrion |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
19
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
|
20
|
|
|
* @author Ahmed Khan ([email protected]) |
|
21
|
|
|
* based on: https://www.startutorial.com/articles/view/a-quick-guide-on-integration-omnipay-on-php-projects |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
use Omnipay\Common\CreditCard; |
|
|
|
|
|
|
25
|
|
|
use Omnipay\Omnipay; |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class Payment |
|
29
|
|
|
*/ |
|
30
|
|
|
class PaymentOmni |
|
31
|
|
|
{ |
|
32
|
|
|
private $pay; |
|
33
|
|
|
private $card; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param $value |
|
37
|
|
|
* @return bool|string |
|
38
|
|
|
*/ |
|
39
|
|
|
public function setcard($value) |
|
40
|
|
|
{ |
|
41
|
|
|
$card = [ |
|
42
|
|
|
'number' => $value['card'], |
|
43
|
|
|
'expiryMonth' => $value['expiremonth'], |
|
44
|
|
|
'expiryYear' => $value['expireyear'], |
|
45
|
|
|
'cvv' => $value['cvv'], |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
try { |
|
49
|
|
|
$ccard = new CreditCard($card); |
|
50
|
|
|
$ccard->validate(); |
|
51
|
|
|
$this->card = $card; |
|
52
|
|
|
|
|
53
|
|
|
return true; |
|
54
|
|
|
} |
|
55
|
|
|
catch (\Throwable $ex) { |
|
56
|
|
|
return $ex->getMessage(); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param $value |
|
62
|
|
|
* @return string |
|
63
|
|
|
*/ |
|
64
|
|
|
public function makepayment($value) |
|
65
|
|
|
{ |
|
66
|
|
|
try { |
|
67
|
|
|
// Setup payment Gateway |
|
68
|
|
|
$pay = Omnipay::create('Stripe'); |
|
69
|
|
|
$pay->setApiKey('YOUR API KEY'); |
|
70
|
|
|
// Send purchase request |
|
71
|
|
|
$response = $pay->purchase([ |
|
72
|
|
|
'amount' => $value['amount'], |
|
73
|
|
|
'currency' => $value['currency'], |
|
74
|
|
|
'card' => $this->card, |
|
75
|
|
|
])->send(); |
|
76
|
|
|
|
|
77
|
|
|
// Process response |
|
78
|
|
|
if ($response->isSuccessful()) { |
|
79
|
|
|
return 'Thankyou for your payment'; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
if ($response->isRedirect()) { |
|
83
|
|
|
// Redirect to offsite payment gateway |
|
84
|
|
|
return $response->getMessage(); |
|
85
|
|
|
} |
|
86
|
|
|
// Payment failed |
|
87
|
|
|
return $response->getMessage(); |
|
88
|
|
|
} |
|
89
|
|
|
catch (\Throwable $ex) { |
|
90
|
|
|
return $ex->getMessage(); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths