Любая помощь или предложения будут высоко оценены! Я пытаюсь вернуть деньги в PHP Laravel 5.6 с включенной Stripe Sandbox. Я использую таблицу, и в этой таблице у меня есть два текстовых поля для определения теста 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'
]);
}