My requirement is to pay out money directly to the user, users will provide their bank account and money will be directly transferred to their given bank account number.
Bank details will be provided by the user and it's not fixed every time. so I cant manually add a bank account to stripe.
in this context, I am using TokenBankAccountOptions in stripe and written the following code for bank account create.
var options = new TokenCreateOptions
{
BankAccount = new TokenBankAccountOptions
{
Country = "US",
Currency = "usd",
AccountHolderName = "Jenny Rosen",
AccountHolderType = "individual",
RoutingNumber = "110000000",
AccountNumber = "000123456789",
},
};
var service = new TokenService();
Token striptoken = await service.CreateAsync(options);
await Transfer(striptoken.Id);
Now I want to transfer or payout money to a given bank account but the stripe not taking any bank details in payout options or transfer options.
As #sinanspd mentioned, you need to use Stripe Connect for this, and I'd also recommend checking with Support to make sure your use case is supported.
Related
With the Stripe API, I can list the active subscriptions for a particular customer using the List subsriptions endpoint. However, I give customers the option to make a one-time purchase of my product (for lifetime access).
Given a customer_id, how can I see if they ever purchased the lifetime access to my product.
It seems that searching for succeeded PaymentIntents is the straight way:
let custId = 'cus_xxxxxxxxxxxxxx';
let lifeTimePrice = 7500;
const paymentIntent = await stripe.paymentIntents.search({
query: 'status:\'succeeded\' AND customer:\'' + custId + '\' AND amount:\'' + lifeTimePrice + '\'',
});
I have a case where I should check the Stripe Payouts API if a new Stripe Payout received at my bank account. The statement text at the bank is in this format:
STRIPE Y1O2A2
or
STRIPE A7O4X2
It is "STRIPE" + a random string.
The Stripe Payouts API result object has a field called "statement_descriptor", but it is empty. I don't know how to assign the the payout received at my bank to a result of the payout API.
Any ideas or suggestions?
Thanks to the advice of #karllekko's command in my question I solved it this way:
$date_money_arrived_at_bank = strtotime('2020-08-31 02:00:00');
$amount_arrived_at_bank_in_cents = 2939;
$x = $stripe->payouts->all(
[
'status' => 'paid',
'arrival_date' => $date_money_arrived_at_bank
]
);
if($x->date[0]->amount == $amount_arrived_at_bank_in_cents) {
// this is your payout
}
I'm am in CET time so I had to set the time UTC+2.
EDIT: This don't work if you have 2 payouts at the same day with the same amount.
As the title says, I am trying to make a payment using a one-time source (credit card) that is not being saved in the customer's profile. I still want to be able to record that charge on the customer's profile on Stripe.
According to the docs, this can be done by passing the customer's id in customer key in the payload sent to Stripe.customers.createCharge. However, on doing that, I receive an error stating the card is not linked with the customer (which obviously is not, and I don't want it to be).
Customer cus_*** does not have card with ID tok_visa
To get around this, temporarily I have applied the fix mentioned in this answer which basically involves creating a temporary card for the payment and then deleting it.
I was wondering how does the API not work when it is clearly documented otherwise, hope someone experienced with Stripe chimes in on the same.
Here is the code I'm trying to get to run:
await stripeService.charges.create({
source: token, // temporary token received from Checkout
customer: user.stripeCustomerId, // the Stripe customer ID from my database
amount,
currency: 'usd',
description: 'Test charge'
});
The single-use sources document that you link to explicitly only works with Sources, but tok_visa will create a Card object instead. I believe that's why you get the error.
If you try the code with a Source(it has an ID like 'src_xxx') that you obtain through Elements/Checkout on your frontend with, for example, createSource, it will succeed, I've just tested it. You can also test with this code :
const src = await stripe.sources.create({
type : "card",
token : "tok_visa"
});
const charge = await stripe.charges.create({
source : src.id,
customer : "cus_xxxx",
amount : 1000,
currency : "usd"
});
I was able to achieve this by creating the source first followed by the charge where you specify the customerId and sourceId as below:
//Create the source first
var options = new SourceCreateOptions
{
Type = SourceType.Card,
Card = new CreditCardOptions
{
Number = Number,
ExpYear = ExpYear,
ExpMonth = ExpMonth,
Cvc = Cvc
},
Currency = "gbp"
};
var serviceSource = new SourceService();
Source source = serviceSource.Create(options);
//Now do the payment
var optionsCharge = new ChargeCreateOptions
{
Amount = 500,
Currency = "gbp",
Description = "Your description",
SourceId = source.Id,
CustomerId = "yourcustomerid"
};
var service = new ChargeService();
service.Create(optionsCharge);
result = "success";
I'm implementing Stripe in my ASP.NET Core app using Checkout.
I know how to get a token for charging a credit card using Checkout but where do I get the token to create a customer?
In the documentation, I see that I need to get a token to create a customer but not sure where that token comes from.
https://stripe.com/docs/api/dotnet#create_customer
As far as I know, a token can be used only once so it cannot be the same token I get before charging a credit card.
As I am referencing here from stripe document
When you collect a customer's payment information, a Stripe token is created. This token can only be used once, but that doesn't mean you have to request your customer's card details for every payment.
Stripe provides a Customer object that makes it easy to save this—and
other—information for later use. You can use Customer objects for
creating subscriptions or future one-off charges.
What you have to exactly do is Create a customer you have got while taking
card details from the customer and charge that customer.
Do it using following code snippet, in this way you will create a customer and charge using a single token
StripeConfiguration.SetApiKey(secret_key_of_your_account);
var token = model.Token; // Using ASP.NET MVC
var customers = new StripeCustomerService();
var charges = new StripeChargeService();
var customer = customers.Create(new StripeCustomerCreateOptions {
Email = "paying.user#example.com",
SourceToken = token
});
// YOUR CODE: Save the customer ID and other info in a database for later.
// YOUR CODE (LATER): When it's time to charge the customer again, retrieve the customer ID.
var charge = charges.Create(new StripeChargeCreateOptions {
Amount = 1500, // $15.00 this time
Currency = "usd",
CustomerId = customer.Id
});
read the referenced document for more details
\Stripe\Stripe::setApiKey("----");
\Stripe\Stripe::setApiKey(".................");
$token= \Stripe\Token::create(array(
"card" => array(
"number" => "4242424242424242",
"exp_month" => 1,
"exp_year" => 2019,
"cvc" => "314"
)
));
$request['stripe_token'] =$token['id'];
// When Contact person have not Stripe Customer id then we have to do the following process.
try {
$customer = \Stripe\Customer::create([
"description" => "Customer for ".$contactDetails['email'],
"source" => $request['stripe_token'] // obtained with Stripe.js
]);
// update its customerid in the contact table
// Create Customer then save its id in table and use the customer id when you are verifiying the customer token
$result= \Stripe\Charge::create(array(
"amount" => $request['amount'],
"currency" => $request['currency'],
"customer" => $customer
));
$status = $result['succeeded'];
if($result['status'] == "succeeded"){
$success = 'Your payment was successful.';
$all['payment_done'] = "1";
$FinalArray = array('status'=>'true','message'=>'Your payment done successful.','result'=>$all);
}else{
$FinalArray = array('status'=>'fail','message'=>'Your Token is not generated successfully','result'=>[]);
}
}
catch (Exception $e) {
$error = $e->getMessage();
$all['payment_done'] = "0";
$FinalArray = array('status'=>'false','message'=>'The Stripe token id is not correctly','result'=>$all);
}
Does anyone know how to transfer to a bank account using Stripe API?
In the Stripe Reference it looks very simple: https://stripe.com/docs/api/python#create_transfer
stripe.Transfer.create(
amount=400,
currency="usd",
destination="acct_19MKfXGyOv0GIG6Z",
description="Transfer for test#example.com"
)
I don't understand where the destination id comes from. How can I get the destination id of a bank account?
Thanks
There are two types of transfers with Stripe:
internal transfers, from a Stripe platform account to one of its connected accounts. This is known as a "special-case transfer".
external transfers, from a Stripe account to its associated bank account.
If you only have a single bank account for a given currency, you can use the special value "default_for_currency" for the destination parameter.
E.g. if you run this code:
stripe.Transfer.create(
amount=400,
currency="usd",
destination="default_for_currency",
description="Transfer for test#example.com"
)
then $4.00 would be sent to your USD bank account.
EDIT: On newer API versions (>= 2017-04-06), "internal transfers" are now simply known as "transfers", and "external transfers" are now known as "payouts". Cf. this doc page for more information.
I have to use the below code in my existing project
Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
// Create a Charge:
$charge = \Stripe\Charge::create([
'amount' => 1300,
'currency' => 'GBP',
'customer' => 'cus_FM5OdvqpYD7AbR', // customer id
'transfer_group' => date('y-m-d_h:i:s'),
'transfer_data' => [
'destination' => 'acct_1EuyLUIpWjdwbl8y', // destination id
'amount' => 700
]
]);
dd($charge);
https://stripe.com/docs/connect/custom-accounts
this above link will let you know how to get bank account id
stripe.accounts.create({
country: "US",
type: "custom"
}).then(function(acct) {
// asynchronously called
});
you can get
this code will give acc. id in response that you can use in destination.