Associate one-off Stripe payment token (tok_) with Customer object - php

Is it possible to associate a one-off Stripe charge/payment with a Stripe Customer profile but not save the card to the profile? I'd really like to organize my Customers and their purchases within the Stripe dashboard, but I can't see any way to do this. From what I can tell there are three ways to create a payment:
Using the source parameter and no customer parameter. The source parameter in this instance starts with tok_
Using the customer parameter, which will use the default card on file.
Using the customer and source parameters, where source is the card ID associated with the customer starting with card_.
I've looked through the docs and can't see anything that alludes to being able to create a payment using customer and a tok_ source. Am I missing something here?

This is not supported by Stripe at the moment. You can still do this though with a few steps:
You create a card token
You add the card to a customer
You charge that card
You delete the card from the customer
This ensures that you don't save the card but still have the charge associated with the right customer.

Related

Braintree PHP How To Get Nonce Without DropIn for Vaulting

For our use case, we have an existing form that captures the customer's credit card information. To smooth out the transition from one payment processor to the next since we're not sure when that will happen, we would like to vault the payment method in Braintree without charging the card but keep our existing form.
I see how to vault the nonce that we receive from the Drop-In UI, and I was able to find an answer on SO that described how to pass the payment information directly to Braintree and charging it, however, I have had no luck in finding a way to just pass the card information to braintree for the purposes of vaulting the payment method (with or without the intermediate step of receiving a nonce).
EDIT:
I've discovered the $gateway->customer()->create() and $gateway->creditCard()->create() functions, however, of the various 'unique identifiers' returned from the credit card create call, none of them appear to be vaultable.
It was buried a bit in the documentation, but I was able to do this with an intermediate step:
create customer $gateway->customer()->create(...)
create credit card $gateway->creditCard()->create(...)
take the token from the previous call and pass it to $gateway->paymentMethodNonce()->create(..)
then take the customer id and the newly created nonce and passed them to $gateway->paymentMethod()->create(...)
the necessary vault token was stored in the results object $result->paymentMethod->graphQLId

Save card details while doing stripe payment

Hi i have been using stripe for the first time in my project where i ask user to provide their Credit card details for payment & i generate stripe token and charge the customer. I have provided a checkbox where customer can save the card details for future transactions & the requirement by the client is that if checkbox is checked, the details have to be saved once the payment successfully done. I am only getting the stripeToken in the processing via POST method and not the card details. Is it possible to get the card details back from the stripeToken in programming way or what can be an equivalent & convenient option to do it?
I tried adding the name attribute to the fields required by stripe for the token generation but in the form POST it is coming empty.
Stripe Only provides the Last 4 Digits of the card .
You can save the CustomerId provided by the Stripe API that can be used later for payments,
When the checkbox is checked you can use the token to create a new customer (or update if it already exist ).
Into the link of #vher2 you can find an example to follow.
EDIT:
Inside the token generated from Stripe.js do you have all the information you need. See the Example Response into Api Stripe of token creation.

How do I create a customer on stripe without enter card information

there I would like to create a customer on stripe without the user entering their card information to begin with. When a user signs-up to my website, i would like them to also have an account created with stripe. I want information such as address to be stored on stripe from signing up on my website. So when the user does want to purchase an item the information can then be retrieved from stripe. How can I do this.
Stripe is for processing payments. It isn't a customer management platform.
If you want to store user information like addresses prior to taking payments through Stripe, you'll need to store them yourself.

Stripe : Specify Specific Card for Subscription

I have set up subscription based website that allows people to have multiple subscriptions. I decided to go with Stripe for payment and card processing. It took very little time to get it integrated into my Symfony2 project. I was able to create subscriptions, customers, and add cards within a couple of hours. Then I ran into an issue. If a customer has multiple cards, I wanted to be able to allow them to choose which card they wanted to use when they create a new subscription. It sounded easy. After 2 days and about 30 hours of combing through their documentation I have to say that I cannot figure out how to get this to work.
The way I have this set up is that when the customer creates a card I store the "card id" in my database along with the brand. This just makes it easy to load details on the server side when the page is being requested. The customer creating the new subscription sees their cards and choose which one they want to use for the new subscription. This is passed to my php script via AJAX to create the new subscription. However, when I try to use a specific card, I am getting a 400 error indicating that the "card id" is not a token. I know that it is not a token since the token was used to add the card to the customer account but how in the world do I specify the exact card that the customer wants to use?
NOTE: Using an a new token creates another instance of the card.Not an option.
PHP:
require_once('../stripe-php/init.php');
//Set Secret API Key
\Stripe\Stripe::setApiKey("sk_test_XXXXXXXXXXXXXXXXXXXXX");
//Retrieve Customer
$cu = \Stripe\Customer::retrieve($_POST['customer_id']);
//Create Subscription using saved customer "card id"
$createSubscription = $cu->subscriptions->create(array("plan" => $_POST['sub_option'], "source" => $card));
POSTED TO STRIPE:
plan: "500-2016"
source: "card_xxxxxxxxxxxxxxxxxxxxx"
STRIPE ERROR: TYPE 400
error:
type: "invalid_request_error"
message: "No such token: card_xxxxxxxxxxxxxxxxxxxxxxx"
param: "source"
I got a reply from Stripe support on this: it is not possible for one Customer to have subscriptions with different payment sources. All invoices for subscriptions are always billed to the current default_source for the Customer. So if you change the default as Giles Bennett suggested, you'll be changing it for all subscriptions, regardless of what the default was at time of creation.
If you need one user to have subscriptions with more than one source, you need to create multiple stripe Customer objects for that user, with a different default_source for each.
Since I have not received any input from SO or Stripe, I have somewhat came to the conclusion that this cannot be done. I found a similar question on a different forum that ended with the results being - No Response From Stripe - and that this cannot be done. Though the Stripe documentation does not hit on this subject it does appear that a Subscription can only be charged to the default card. There is no "Card" object for subscriptions as there is for a "Charge".
I realise this thread is quite old, but having come across it whilst trying to answer the same question myself, this solution may be of use to those who come along afterwards.
The Stripe API says that the "source" parameter for the API call to create a new subscription is optional - if ommitted, then it will default to the customer's default card. If included, then it can only be a token (ie. a new card) or a dictionary entry (again, for a new card, just not tokenised).
The solutionĀ could be to update the customer's default source first. Using Cartalyst through Laravel, as we are :
$customer = Stripe::customers()->update( "customer_id", [
'default_source' => "card_id"
]);
You can then proceed to add your subscription as normal - the newly-defaulted card will be assigned to it. If needs be (depending on your application) then you may also wish to save the previous default card ID to a variable first, to then allow you to set it back to being the default card after your new subscription.
I hope that helps.

Two different Payment Gateway for one payment

I'm building functionality in which product payment is divided into two parts -
1. service charge
2. actual payment
service charge payment will be done thr' stripe api (as client wants this gateway)
actual payment will be done thr' any type of gateway as per user selection.
But, crucial part is, both parts of payment should be done on one click.
On one click, it should go to stripe and other gateway that user has selected.
Can it be possible?
If yes, what will happen in the case where one of the two parts of payments is successful and other one failes.
Where can I redirect success url for both types of payments? on same page or another page?
As card details will be given only once by user in one form and submitted, can these details remain secure while processing of two transactions?
I have thoroughly searched for this, but can't find answer.
Thanks in advance.
Assuming this is a credit card payment only (and not a wallet such as PayPal or WebMoney, etc) all you need to do is store the credit-card details at your servers. Just make sure you are PCI compliant for that.
In this case, you will charge the service fee via stripe and the actual payment via the 2nd payment gateway. Just make sure you refund one if the other failed. Also ensure that the user is well aware that he will see TWO charges on his card. I would advise showing that nicely in the invoice page.
So it's not that complex of a flow for stored credit cards, but if you lack the credit card data and let the user pick an online payment option such as PayPal, then you'll need to ensure this online payment is successfully completed before charging the service fee via stripe.

Categories