【发布时间】:2020-07-19 09:26:29
【问题描述】:
任何帮助或建议将不胜感激! 我正在尝试在启用 Stripe Sandbox 的 PHP Laravel 5.6 中退款。 我正在使用一个表,在该表中我有两个文本字段来定义 Stripe 测试和实时键。
这是我在 PHP Laravel 中的服务代码:
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, SparkPost and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'us-east-1',
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => config('settings.stripe_sandbox_enabled') ? config('settings.stripe_test_key_pk') : config('settings.stripe_live_key_pk'),
'secret' => config('settings.stripe_sandbox_enabled') ? config('settings.stripe_test_key_sk') : config('stripe_live_key_sk'),
],
];
这是我的刀片文件中通过 Stripe 发出退款的代码行:
//issue refund
$invoice = $booking->invoice()->first();
if($invoice['payment_method'] == __('app.credit_card'))
{
try {
//refund via stripe
if($booking->invoice->is_partial == 1){
if($booking->invoice->amount_left != 0){
// print_r($booking->invoice->transaction_id);
// exit();
Stripe::refunds()->create($booking->invoice->transaction_id, $booking->invoice->first_payment, [
'reason' => 'requested_by_customer'
]);
}
else{
$transaction_ids = explode(',', $booking->invoice->transaction_id);
Stripe::refunds()->create($transaction_ids[0], $booking->invoice->first_payment, [
'reason' => 'requested_by_customer'
]);
Stripe::refunds()->create($transaction_ids[1], $booking->invoice->second_payment, [
'reason' => 'requested_by_customer'
]);
}
}
else{
Stripe::refunds()->create($booking->invoice->transaction_id, $booking->invoice->amount , [
'reason' => 'requested_by_customer'
]);
}
【问题讨论】:
标签: php laravel laravel-5 stripe-payments