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
Related
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 using Stripe Checkout API to direct a website user to make payment.
Is there a way to pass a shipping address to the hosted checkout page so it's gathered from the referrer rather then Stripe themselves?
function createSession()
{
require 'vendor/autoload.php';
\Stripe\Stripe::setApiKey('[API_KEY_REDACTED]');
$YOUR_DOMAIN = '[SITE_URL_REDACTED]';
// Calculate price
$price = 50;
$checkout_session = \Stripe\Checkout\Session::create([
'billing_address_collection' => 'required',
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'gbp',
'unit_amount' => $price,
'product_data' => [
'name' => 'Product'
],
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/success',
'cancel_url' => $YOUR_DOMAIN . '/cancel',
]);
return json_encode(['id' => $checkout_session->id]);
}
You can add the following line to make Stripe ask for a shipping address, but I want to pass this from the referrer instead.
'shipping_address_collection' => [
'allowed_countries' => ['US', 'CA'],
],
To do this you would create a Customer and provide their shipping address, then provide that existing Customer when creating the Checkout session:
$checkout_session = \Stripe\Checkout\Session::create([
'customer' => 'cus_123',
...
]);
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.
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',
]);