When transferring money to a connected account on Stripe using this code
// // Create a PaymentIntent:
$method = \Stripe\PaymentMethod::create([
'type' => 'card',
'card' => [
'number' => '4242424242424242',
'exp_month' => 12,
'exp_year' => 2020,
'cvc' => '314',
],
]);
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $AMOUNT1,
'currency' => 'nzd',
'payment_method_types' => ['card'],
'payment_method' => $method->id,
'customer' => CUSTOMER_ID,
'transfer_group' => '{ORDER'.$_SESSION['order_id'].'}',
]);
// Create a Transfer to a connected account (later):
$transfer = \Stripe\Transfer::create([
'amount' => $AMOUNT2,
'currency' => 'nzd',
'destination' => $ACC_ID,
'transfer_group' => '{ORDER'.$_SESSION['order_id'].'}',
]);
The payment stores on the connected account's dashboard and says its completed but when it stores on my Payments tab it says that the payment is incomplete and that the buyer has not completed the payment
Prev1
Prev2
You need to confirm the payment intent, either by providing confirm=true at creation or by making a call to /confirm.
You're creating a transfer from your account to the connected one, which succeeds, and a payment that you never complete.
Related
For some reason, when you create a "Subscription Schedules" stripe, it has very odd behavior where instead of trying to charge the customer, it keeps the invoice in draft for 1 hour and then closes the invoice and charges the customer.
I already have the card in the customer. I wonder if there is any way I can force the first phase of the subscription to be charged immediately.
My code:
$phases = [
[
'items' => [
[
'price_data' => [
'currency' => 'usd',
'product' => $product->stripe_product_id,
'recurring' => [
'interval' => $payment_plan['frequency'],
],
'unit_amount' => $payment_plan['stripe_amount']
],
'quantity' => 1,
],
],
'iterations' => (int) $payment_plan['total_payments']
],
];
$subscription = $stripe->subscriptionSchedules->create([
'customer' => $customer->stripe_customer_id,
'start_date' => 'now',
'end_behavior' => 'cancel',
'phases' => $phases,
]);
If you want to create a subscription immediately, you can do that without a Subscription Schedule and then set the schedule for that existing subscription:
https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#existing-subscription
Alternatively, if creating with the schedule like you're doing, once the subscription/invoice is created (as a draft) you can use the API to finalize it manually to proceed with the payment:
https://stripe.com/docs/api/invoices/finalize
Here is the solution:
$subscription = $stripe->subscriptionSchedules->create([
'customer' => $customer->stripe_customer_id,
'start_date' => 'now',
'end_behavior' => 'cancel',
'phases' => $phases,
]);
// now the invoice is a draft so we go get this invoice
$invoice = $stripe->invoices->all([
'limit' => 3,
'status' => 'draft',
'subscription' => $subscription->subscription,
'customer' => $customer->stripe_customer_id,
]);
//get the most recent draft
$invoice = $invoice->data[0];
//finalize the invoice (but this don't generate the payment for some reason)
$stripe->invoices->finalizeInvoice(
$invoice->id, [
'auto_advance' => true
]
);
//finaly pay the invoice
$invoice = $stripe->invoices->pay($invoice->id,[
'payment_method' => $token
]);
I'm using Stripe for one-time payments and subscriptions.
To create a payment, I use Stripe Checkout:
\Stripe\Checkout\Session::create([
'customer' => 'cus_XXXXX',
'success_url' => '',
'cancel_url' => '',
'payment_method_types' => ['card'],
'mode' => ($isSubscription ? 'subscription' : 'payment'),
'line_items' => [...]
]);
header('Location: '.$checkout_session->url);
exit;
This code automatically create an invoice for subscription mode but not for one-time payments.
I've tried this to create a new invoice but how can I do to make it related to previous payment, closed and paid?
$stripe = new Stripe\StripeClient('xxx');
$stripe->invoiceItems->create([
'customer' => 'cus_XXXXX',
'amount' => '1000',
'currency' => 'eur',
'description' => 'Lorem ipsum...'
]);
$invoice = $stripe->invoices->create([
'customer' => 'cus_XXXXX',
]);
I found a way to create an invoice for each payment mark paid.
This, however, doesn't link them to a payment.
On the webhook checkout.session.completed do the following:
$stripe = new Stripe\StripeClient('xxx');
// Create invoice lines
$stripe->invoiceItems->create([
'customer' => 'cus_XXXXX',
'amount' => '1000',
'currency' => 'eur',
'description' => 'Lorem ipsum...'
]);
// Create invoice
$invoice = $stripe->invoices->create([
'customer' => 'cus_XXXXX',
]);
// Finalize and mark invoice paid outside of Stripe
$invoice->finalizeInvoice();
$invoice->pay(['paid_out_of_band' => true]);
I believe you are looking for this: https://stripe.com/docs/payments/checkout/post-payment-invoices
To enable invoice creation, set invoice_creation[enabled] to true when
creating a Checkout session.
I am using this code to create Stripe checkout:
$checkout_session = \Stripe\Checkout\Session::create([
'customer_email' => 'my_test_email#gmail.com',
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'usd',
'unit_amount' => 1000,
'product_data' => [
'name' => 'Balance top-up',
],
],
'quantity' => 1,
]],
'mode' => 'payment',
'client_reference_id' => $clientReferenceId,
'success_url' => 'https://example.com/user-deposit/?result=success',
'cancel_url' => 'https://example.com/user-deposit/?result=failed',
'metadata' => [
'user_id' => '1',
],
]);
Everything works fine, but if I try to pay with ApplePay from the mobile browser - I got such an error (although everything is fine with this card and the billing address is filled in in the Apple account settings):
What should I do? In fact, I don't want to ask my users for the billing address, could I use some stored info (like country and city) to pass to this API request, or perhaps I could somehow force Stripe to do not ask for billing/shipping addresses (I do not sell goods, just for top-up an internal balance in my service)?
I am creating a project using stripe and php. I am integrating the stripe and transfer the amount to the card.I am following the offical document of stripe and getting some error
$payout = \Stripe\Payout::create([
'amount' => 1000,
'currency' => 'usd',
'method' => 'instant',
'destination' => 'card_xyz',
]);
Getting Error:
No such external account: 19173966
https://stripe.com/docs/payouts
You need to include source_type in the request. See if the account already exists.
$payout = \Stripe\Payout::create([
'amount' => 1000,
'currency' => 'usd',
'method' => 'instant',
'destination' => 'card_xyz',
'source_type' => 'card',
]);
I am transferring fund from stripe account to connect account using payout api
my code is:
$payout = \Stripe\Payout::create([
'amount' => 500,
'currency' => 'aud',
'description' => 'first payout payment transfer on stripe',
'destination' => 'bank_id',
'method' => 'instant',
'source_type' => 'bank_account',
'statement_descriptor' => 'first payout payment transfer on stripe ',
]);
after hit this api show error:
Stripe\Exception\InvalidRequestException: No such external account:
ba_1G497bAoBoRegJgCC1jj2UE2 in file
/var/www/html/ultimateFitness/app/Stripe/lib/Exception/ApiErrorException.php
on line 38
Also i am follow stripe documentation:
https://stripe.com/docs/api/payouts/create
You need to make the call on behalf of the connected account — right now it gives an error because it's looking for the bank account on your Stripe account, not the connected one.
https://stripe.com/docs/connect/authentication
$payout = \Stripe\Payout::create([
'amount' => 500,
'currency' => 'aud',
'description' => 'first payout payment transfer on stripe',
'destination' => $bank_id,
'method' => 'instant',
'source_type' => 'bank_account',
'statement_descriptor' => 'first payout payment transfer on stripe ',
],
["stripe_account" => "{{CONNECTED_STRIPE_ACCOUNT_ID}}"]); // value like "acct_xxx"