|
...
|
...
|
@@ -10,18 +10,20 @@ |
|
|
|
namespace App\Helper;
|
|
|
|
|
|
|
|
use App\Models\ExtentModule\ExtensionModuleValue;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class PayStripeApi
|
|
|
|
{
|
|
|
|
private $secretKey;
|
|
|
|
//币种对应支付方式
|
|
|
|
public $currency_types = [
|
|
|
|
'usd' => ['card', 'alipay', 'wechat_pay', 'cashapp', 'link', 'afterpay_clearpay'],
|
|
|
|
'usd' => ['card', 'cashapp', 'link', 'afterpay_clearpay'],
|
|
|
|
'eur' => ['card', 'ideal', 'giropay', 'sofort', 'bancontact', 'klarna', 'link'],
|
|
|
|
'gbp' => ['card', 'apple_pay', 'google_pay', 'klarna', 'link', 'afterpay_clearpay'],
|
|
|
|
'aud' => ['card', 'afterpay_clearpay', 'apple_pay', 'google_pay'],
|
|
|
|
'cad' => ['card', 'apple_pay', 'google_pay', 'link'],
|
|
|
|
'sgd' => ['card', 'grabpay', 'fpx', 'wechat_pay', 'apple_pay', 'google_pay'],
|
|
|
|
'sgd' => ['card', 'grabpay', 'fpx', 'google_pay'],
|
|
|
|
'jpy' => ['card', 'apple_pay', 'google_pay'],
|
|
|
|
'cny' => ['alipay', 'wechat_pay'],
|
|
|
|
'brl' => ['card', 'boleto', 'pix'],
|
|
...
|
...
|
@@ -81,13 +83,13 @@ class PayStripeApi |
|
|
|
* @method :post
|
|
|
|
* @time :2024/12/24 10:38
|
|
|
|
*/
|
|
|
|
public function createPaymentIntent($amount, $currency = 'usd', $paymentMethodTypes = 'card')
|
|
|
|
public function createPaymentIntent($amount, $currency = 'usd')
|
|
|
|
{
|
|
|
|
$url = "https://api.stripe.com/v1/payment_intents";
|
|
|
|
$data = [
|
|
|
|
'amount' => $amount,
|
|
|
|
'currency' => $currency,
|
|
|
|
'payment_method_types[]' => $paymentMethodTypes,
|
|
|
|
'payment_method_types' => $this->currency_types[$currency],
|
|
|
|
];
|
|
|
|
return $this->sendRequest($url, 'POST', $data);
|
|
|
|
}
|
|
...
|
...
|
@@ -176,7 +178,6 @@ class PayStripeApi |
|
|
|
break;
|
|
|
|
case 'payment_intent.payment_failed':
|
|
|
|
// 处理支付失败逻辑
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($eventData, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
$error = $eventData['last_payment_error'];
|
|
|
|
break;
|
|
|
|
case 'charge.refunded':
|
|
...
|
...
|
@@ -200,6 +201,8 @@ class PayStripeApi |
|
|
|
* @time :2024/12/25 14:43
|
|
|
|
*/
|
|
|
|
public static function getExtensionInfo($id,$eventData){
|
|
|
|
@file_put_contents(storage_path('logs/lyh_3059_error.log'), var_export('进入', true) . PHP_EOL, FILE_APPEND);
|
|
|
|
ProjectServer::useProject(3059);
|
|
|
|
$extensionModel = new ExtensionModuleValue();
|
|
|
|
$info = $extensionModel->read(['value'=>$id]);
|
|
|
|
if($info === false){
|
|
...
|
...
|
@@ -210,8 +213,9 @@ class PayStripeApi |
|
|
|
['uuid'=>$info['uuid'],'module_id'=>$info['module_id'],'field_id'=>6,'value'=>'success'],
|
|
|
|
['uuid'=>$info['uuid'],'module_id'=>$info['module_id'],'field_id'=>7,'value'=>json_encode($eventData)],
|
|
|
|
];
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
$moduleValueModel->insertAll($data);
|
|
|
|
$rs = $extensionModel->insertAll($data);
|
|
|
|
@file_put_contents(storage_path('logs/lyh_3059_error.log'), var_export('结束'.$rs, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|