Pay out using stripe with card - php

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',
]);

Related

How to Create Stripe PaymentIntent in PHP Codeigniter

Message: Call to private method Stripe\ApiResource: :_validateParams() from context 'Stripe\PaymentIntent'
require_once('application/libraries/stripe/init.php');
\Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
\Stripe\PaymentIntent::create([
'payment_method_types' => ['card'],
'amount' => 1099,
'currency' => 'usd',
'customer' => '{{CUSTOMER_ID}}',
'payment_method' => '{{CARD_ID}}',
]);
As pre stripe documents, stripe use StripeClient() to set the apikey.
Replace
\Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
with
\Stripe\StripeClient("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
Source

Stripe API and ApplePay "Billing Address Invalid" issue

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)?

Paypal Checkout SDK - immediate payment

I need to use Paypal checkout in order to accept immediate payment on my Laravel website, and I switched from old Paypal PHP SDK to the new Paypal checkout SDK to support API V2.
I followed the samples codes that provided in the new SDK, I have to create all workflow on my server, so I created an order with intent=CAPTURE with other required fields.
$request = new OrdersCreateRequest();
$request->headers["prefer"] = "return=representation";
$request->body = $this->buildMinimumRequestBody(...);
$response = $this->client->execute($request);
// redirect the user to approval link.
Order body:
return array(
'intent' => 'CAPTURE',
'application_context' =>
array(
'return_url' => 'https://example.com/return',
'cancel_url' => 'https://example.com/cancel',
'locale' => 'en-US',
'user_action' => 'PAY_NOW',
'shipping_preference'=> 'NO_SHIPPING'
),
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'USD',
'value' => 12,
'breakdown' =>
array(
'item_total' =>
array(
'currency_code' => 'USD',
'value' => 10,
),
'tax_total' =>
array(
'currency_code' => 'USD',
'value' => 2,
),
),
),
),
),
);
After the user redirected to approval URL and approving it, I execute the payment like below:
$response = $this->client->execute(new OrdersCaptureRequest($payment_id));
Below is the response after executing the payment.
Order and Payment response
So after directing the user to the approval page, then after approving the payment, then executing the order, I got the above result in the attached screenshot which shows the Order status is completed but the payment status is still "pending" and the reason is "PENDING_REVIEW", so I would like to ask if there is any error or something missed to make the payment immediately without waiting for review with an example.
Thanks.

Stripe saying 'Payment not completed' Stripe connect php

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.

No such external account and my Stripe Payout not working using php?

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"

Categories