Я хочу перевести свои средства Strype на чужой банковский счет. Я пробую следующий подход.
// generate test bank account token
public function generateBankAccountToken()
{
Stripe::setApiKey(config('stripe.sk'));
try {
$token = Token::create([
'bank_account' => [
'country' => 'US',
'currency' => 'usd',
'account_holder_name' => 'Test User',
'account_holder_type' => 'individual',
'routing_number' => '110000000', // Test routing number
'account_number' => '000999999991', // Test account number
],
]);
return response()->json(['token' => $token]);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
// to redirect amount from stripe to bank account
public function initiateTransfer(Request $request)
{
$input = $request->validate([
'account' => ['required'],
'amount' => ['required', new CheckBalance],
]);
// set the stripe API token
Stripe::setApiKey(config('stripe.sk'));
try {
// Create a transfer to the recipient's bank account
$transfer = Transfer::create([
'amount' => 100,
'currency' => 'usd', // Currency code
'destination' => 'abtok_1PVXsvAzd6Qck0TGa8chJlfd', // Replace with recipient's Stripe account ID
'description' => 'Refund from balance', // Optional description
]);
// Redirect the user to the Stripe transfer page
return redirect()->away($transfer->destination_payment_url);
} catch (Exception $e) {
// Handle transfer failure
dd($e);
return back()->withError('Transfer could not be initiated: ' . $e->getMessage());
}
}
В файле маршрута:
Route::put('/recharge/initiate-Transfer', 'initiateTransfer')->name('strype.initiate.transfer');
Route::get('test/bank-account', 'generateBankAccountToken')->name('strype.test.bank');
После вызова маршрута strype.test.bank я получаю токен: btok_1PVXsvAzd6Qck0TGa8chJlfd.
Однако после применив токен к функции инициации, я получаю следующую ошибку.
Stripe\Exception\InvalidRequestException {#1605 ▼ // app\Http\Controllers\PaymentController\StripeController.php:156
#message: "No such destination: 'acct_1MQccXIQ2pUmxoSJ'"
#code: 0
.........................................
Подробнее здесь: https://stackoverflow.com/questions/786 ... nt-laravel
Перевод средств Strype на банковский счет Laravel ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение