I am having an issue that Stripe will count a new customer even if the card is declined. I have not figured out a way to prevent Stripe from counting these users in their Dashboard. (Technically it is a NEW customer, but they have no active subscription or charge on their card.)
However, my web application handles these just fine and it just asks the user to put in their credit card information again due to a declined credit card.
try{
$cusresp = \Stripe\Customer::create(array(
"description" => "Customer $membertbl[email], $membertbl[name]",
"email" => $membertbl[email],
"source" => $striptoken // obtained with Stripe.js
));
}
If this response has no catch exceptions, I then use create subscription and proceed normally.
Even if I go to the dashboard and delete this customer, the Stripe Dashboard still counts them.
Related
I am trying to use stripe Direct Charges and it's working when user user new card (with token id).
Problem: When trying with save customer id and save card id. When i am trying to charge with custom-id and source=> save card id It's giving error customer not exist. But Both customer and card id exist.
$charge = \Stripe\Charge::create([
"customer" => $userdata->stripe_id,
"amount" => $amount,
"currency" => "usd",
"source" => $findcard['card_id'],
"application_fee" => $fee,
], ["stripe_account" => $talent_stripeid]);
Error: No such customer: cus_EOwmc6nVmU7oNu
I was getting the same error and when reached out to Stripe support got the following answer which helped me to solve the issue:
The error you are running into is happening because the customer
object is on the platform account, but when you add the
"Stripe-account" parameter to your charge request, you're moving the
command to the connected account, and so can't reach the customer
object.
To make the customer available, you'll need to share the customer to
the connected account. You'll basically create a token or source from
the customer object on your platform, and then share that with the
connected account, to process a payment, or to save locally, so the
connected account can use it directly.
https://stripe.com/docs/connect/shared-customers
Alternatively, you can keep the customer information on your platform
account and perform Destination charges, just sending to the connected
account "their share" of the proceeds:
https://stripe.com/docs/connect/destination-charges
I was wondering for a bit of clarification and help regarding Stripe.
Basically, I have the following:
//get the card token from the stripe request
$customerTok = request('stripeToken');
//create the customer with this token
$customer = \Stripe\Customer::create(array(
"email" => \Auth::user()->email,
"source" => $customerTok,
));
Where customerTok is the bank token passed by Stripe.js (entering their card number, cvc and exp date), and I'm creating the customer in my Stripe Dashboard.
$cardTok = \Stripe\Token::create(array(
"card"=>$customer->sources->retrieve(default_source),
));`
Then I grab a token for their card? (I think this is wrong but this is the principle?)
I now need to make them into a connect managed account (I need users to be able to pay each other, like eBay)
$account = \Stripe\Account::create(
array(
"country" => "GB",
"managed" => true,
"external_account"=>$customer->id,
));
Obviously this isn't production ready code, I'm just trying to understand the flow and if I'm understanding this correctly.. Can anyone explain why this isn't working right now and what I'm getting wrong?
Thanks,
Generally, you cannot retokenize payment information from saved customers (outside of specific scenarios).
Note also that Stripe can only do payouts to debit cards (not credit cards), and only in the US. In all other countries, Stripe can only do payouts to bank accounts.
If your platform's users are both buyers and sellers, you will need to create two different resources for each of them:
a customer object to act as a payment source (when the user buys something)
an account object to act as a payment destination (when a user sells something)
I recommend that you reach out to Stripe's support at https://support.stripe.com/email to explain your business model so that you can receive personalized advice for your integration.
Using the Stripe API, Creating a new user on a paid plan with a trial period doesn't seem to work without a credit card token.
I am using the PHP SDK and doing the following:
$customer = \Stripe\Customer::create(array(
"source" => NULL,
"plan" => 'PROFESSIONAL',
"email" => $email_address,
"trial_end" => $unix_timestamp
);
Which returns the error:
Error: Invalid source object: must be a dictionary or a non-empty string.
There are two reasons I think this should work, which is why I think I am doing something wrong.
Adding trial_end adds a trial to the subscription, so no payment is needed which means it doesn't need a Credit Card at that point in time.
Using the Stripe online Portal, you can create a user on a paid subscription, and also move existing users on to a paid subscription without the need for a Credit Card, when you specify a trial period. If you can do it in the portal, why can't you do it via the API?
Is there something I have missed in the Documentation to allow me to do this?
Just tried the following which worked.
$customer = \Stripe\Customer::create(array(
"plan" => 'PROFESSIONAL',
"email" => $email_address,
"trial_end" => $unix_timestamp
);
Basically I just removed the source key/value completely. It then created the user on the paid plan with the trial.
Odd behaviour as when you create a user on a FREE plan, you can have the source key there with a value of NULL and it works. Also not documented as far as I can see.
Follow these step
Create a customer using
\Stripe\Customer::create(array(
"description" => $descriptions,
"email" => $email
));
Store the returned customer ID from stripe
Now subscribe the customer for that plan
$customer = \Stripe\Customer::retrieve($customer_id);
$subscriptions = $customer->subscriptions->create(array("plan" => $plan_id));
Please make sure plan is already created on stripe.
I'm trying to implement payments with Stripe, i'm using Stripe connect.
I'm reading documentation for "Charging through the platform" and it says:
\Stripe\Stripe::setApiKey(PLATFORM_SECRET_KEY);
\Stripe\Charge::create(array(
'amount' => 1000,
'currency' => 'gbp',
'source' => {TOKEN},
'destination' => {CONNECTED_STRIPE_ACCOUNT_ID}
));
I have the PLATFORM_SECRET_KEY, and the CONNECTED_STRIPE_ACCOUNT_ID (Obtained from oauth flow with stripe connect), but what is the needed TOKEN?
I have readed that a token can be obtained from a "stripe form", but what is the point to "connect" the stripe account if i need to request card data to my users?
Do I missed something from the flow?
Is there a way to create a token from the user account?
Do i need to create a customer?
Note: I'm newbie with stripe payments.
Stripe Connect is used to create charges on behalf of your users. Let's say you're a marketplace for example, you allow John to sell lamps online. Then, Alice comes and wants to buy a lamp from John on your website. You use the code you mentioned before to charge Alice and send the funds to John's account directly.
It looks like what you want here though is to charge Alice for yourself instead. Alice doesn't need a Stripe account in that case. You need to collect Alice's card details using Stripe Checkout or building your own form using Stripe.js. This will give your a card token tok_XXX that you then send to your server where you use it to create a charge through the API as explained in the charges tutorial.
I want to use STRIPE PHP API for creating payments to customers and for that i have found the code to create the customers but not for to create payment for them.
Code to create customers:
https://stripe.com/docs/api#create_customer
require_once('./lib/Stripe.php');
Stripe::setApiKey("sk_test_k9NE13Q2LjsIvYTNQHiP5C5H");
Stripe_Customer::create(
array( "description" => "Customer for test#example.com",
"card" => "tok_1509ycG2gfbJDdl3oYWMe6yq" // obtained with Stripe.js
));
My Scenario is : I have some products and customers comes to my site and purchase the product but some of the customers will come from the affiliate banner and we need to pay some commission amount to the affiliate customers.
So, for such scenario i have to create customers and create payment for them and i have found PHP API code for creating the customers but not for the creating payment to that customers.
As I understand, you should use Stripe managed accounts for your customers to make Payouts.
https://stripe.com/docs/connect/managed-accounts
https://stripe.com/docs/connect/payouts
You'll need to collect additional customer verification data to make payouts to managed accounts:
https://stripe.com/docs/connect/identity-verification
https://stripe.com/docs/connect/updating-accounts#account-verification
https://stripe.com/docs/connect/required-verification-information
https://stripe.com/docs/connect/testing-verification
I think your problem here is that you're misunderstanding the customer option in the stripe dashboard.
A typical use would be you register a customer and once you've done that you can charge their card as required, i.e., they are still sending you money, which I believe isn't what you want.
Two options I can see for you.
It's possible to transfer money from your Stipe account to a 3rd party bank account or credit card. See stripe transfers and also this FAQ
Alternatively there is a now Stripe Connect which might just be the ticket for you.
Good luck!