|
@@ -10,18 +10,20 @@ |
|
@@ -10,18 +10,20 @@ |
|
10
|
namespace App\Helper;
|
10
|
namespace App\Helper;
|
|
11
|
|
11
|
|
|
12
|
use App\Models\ExtentModule\ExtensionModuleValue;
|
12
|
use App\Models\ExtentModule\ExtensionModuleValue;
|
|
|
|
13
|
+use App\Services\ProjectServer;
|
|
|
|
14
|
+use Illuminate\Support\Facades\DB;
|
|
13
|
|
15
|
|
|
14
|
class PayStripeApi
|
16
|
class PayStripeApi
|
|
15
|
{
|
17
|
{
|
|
16
|
private $secretKey;
|
18
|
private $secretKey;
|
|
17
|
//币种对应支付方式
|
19
|
//币种对应支付方式
|
|
18
|
public $currency_types = [
|
20
|
public $currency_types = [
|
|
19
|
- 'usd' => ['card', 'alipay', 'wechat_pay', 'cashapp', 'link', 'afterpay_clearpay'],
|
21
|
+ 'usd' => ['card', 'cashapp', 'link', 'afterpay_clearpay'],
|
|
20
|
'eur' => ['card', 'ideal', 'giropay', 'sofort', 'bancontact', 'klarna', 'link'],
|
22
|
'eur' => ['card', 'ideal', 'giropay', 'sofort', 'bancontact', 'klarna', 'link'],
|
|
21
|
'gbp' => ['card', 'apple_pay', 'google_pay', 'klarna', 'link', 'afterpay_clearpay'],
|
23
|
'gbp' => ['card', 'apple_pay', 'google_pay', 'klarna', 'link', 'afterpay_clearpay'],
|
|
22
|
'aud' => ['card', 'afterpay_clearpay', 'apple_pay', 'google_pay'],
|
24
|
'aud' => ['card', 'afterpay_clearpay', 'apple_pay', 'google_pay'],
|
|
23
|
'cad' => ['card', 'apple_pay', 'google_pay', 'link'],
|
25
|
'cad' => ['card', 'apple_pay', 'google_pay', 'link'],
|
|
24
|
- 'sgd' => ['card', 'grabpay', 'fpx', 'wechat_pay', 'apple_pay', 'google_pay'],
|
26
|
+ 'sgd' => ['card', 'grabpay', 'fpx', 'google_pay'],
|
|
25
|
'jpy' => ['card', 'apple_pay', 'google_pay'],
|
27
|
'jpy' => ['card', 'apple_pay', 'google_pay'],
|
|
26
|
'cny' => ['alipay', 'wechat_pay'],
|
28
|
'cny' => ['alipay', 'wechat_pay'],
|
|
27
|
'brl' => ['card', 'boleto', 'pix'],
|
29
|
'brl' => ['card', 'boleto', 'pix'],
|
|
@@ -81,13 +83,13 @@ class PayStripeApi |
|
@@ -81,13 +83,13 @@ class PayStripeApi |
|
81
|
* @method :post
|
83
|
* @method :post
|
|
82
|
* @time :2024/12/24 10:38
|
84
|
* @time :2024/12/24 10:38
|
|
83
|
*/
|
85
|
*/
|
|
84
|
- public function createPaymentIntent($amount, $currency = 'usd', $paymentMethodTypes = 'card')
|
86
|
+ public function createPaymentIntent($amount, $currency = 'usd')
|
|
85
|
{
|
87
|
{
|
|
86
|
$url = "https://api.stripe.com/v1/payment_intents";
|
88
|
$url = "https://api.stripe.com/v1/payment_intents";
|
|
87
|
$data = [
|
89
|
$data = [
|
|
88
|
'amount' => $amount,
|
90
|
'amount' => $amount,
|
|
89
|
'currency' => $currency,
|
91
|
'currency' => $currency,
|
|
90
|
- 'payment_method_types[]' => $paymentMethodTypes,
|
92
|
+ 'payment_method_types' => $this->currency_types[$currency],
|
|
91
|
];
|
93
|
];
|
|
92
|
return $this->sendRequest($url, 'POST', $data);
|
94
|
return $this->sendRequest($url, 'POST', $data);
|
|
93
|
}
|
95
|
}
|
|
@@ -176,7 +178,6 @@ class PayStripeApi |
|
@@ -176,7 +178,6 @@ class PayStripeApi |
|
176
|
break;
|
178
|
break;
|
|
177
|
case 'payment_intent.payment_failed':
|
179
|
case 'payment_intent.payment_failed':
|
|
178
|
// 处理支付失败逻辑
|
180
|
// 处理支付失败逻辑
|
|
179
|
- @file_put_contents(storage_path('logs/lyh_error.log'), var_export($eventData, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
180
|
$error = $eventData['last_payment_error'];
|
181
|
$error = $eventData['last_payment_error'];
|
|
181
|
break;
|
182
|
break;
|
|
182
|
case 'charge.refunded':
|
183
|
case 'charge.refunded':
|
|
@@ -200,6 +201,8 @@ class PayStripeApi |
|
@@ -200,6 +201,8 @@ class PayStripeApi |
|
200
|
* @time :2024/12/25 14:43
|
201
|
* @time :2024/12/25 14:43
|
|
201
|
*/
|
202
|
*/
|
|
202
|
public static function getExtensionInfo($id,$eventData){
|
203
|
public static function getExtensionInfo($id,$eventData){
|
|
|
|
204
|
+ @file_put_contents(storage_path('logs/lyh_3059_error.log'), var_export('进入', true) . PHP_EOL, FILE_APPEND);
|
|
|
|
205
|
+ ProjectServer::useProject(3059);
|
|
203
|
$extensionModel = new ExtensionModuleValue();
|
206
|
$extensionModel = new ExtensionModuleValue();
|
|
204
|
$info = $extensionModel->read(['value'=>$id]);
|
207
|
$info = $extensionModel->read(['value'=>$id]);
|
|
205
|
if($info === false){
|
208
|
if($info === false){
|
|
@@ -210,8 +213,9 @@ class PayStripeApi |
|
@@ -210,8 +213,9 @@ class PayStripeApi |
|
210
|
['uuid'=>$info['uuid'],'module_id'=>$info['module_id'],'field_id'=>6,'value'=>'success'],
|
213
|
['uuid'=>$info['uuid'],'module_id'=>$info['module_id'],'field_id'=>6,'value'=>'success'],
|
|
211
|
['uuid'=>$info['uuid'],'module_id'=>$info['module_id'],'field_id'=>7,'value'=>json_encode($eventData)],
|
214
|
['uuid'=>$info['uuid'],'module_id'=>$info['module_id'],'field_id'=>7,'value'=>json_encode($eventData)],
|
|
212
|
];
|
215
|
];
|
|
213
|
- $moduleValueModel = new ExtensionModuleValue();
|
|
|
|
214
|
- $moduleValueModel->insertAll($data);
|
216
|
+ $rs = $extensionModel->insertAll($data);
|
|
|
|
217
|
+ @file_put_contents(storage_path('logs/lyh_3059_error.log'), var_export('结束'.$rs, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
218
|
+ DB::disconnect('custom_mysql');
|
|
215
|
}
|
219
|
}
|
|
216
|
|
220
|
|
|
217
|
/**
|
221
|
/**
|