I am trying to transfer amount from 1 stripe account to another stripe account but I am getting this error "No such destination:".
I tried to add different client ids. But it isn't working.
\Stripe\Stripe::setApiKey('APP Key');
$transfer = \Stripe\Transfer::create([
"amount" => 400,
"currency" => "usd",
"destination" => "ca_FtG3t5**********",
"transfer_group" => "ORDER_95"
]);
return $transfer;
I want this to transfer amount to other stripe account.
"No such destination" means the account you are trying to transfer to does not exist, or is not connected to your account.
Most Stripe accounts are in the format of acct_xxxyyyzzz, the id you have here ca_xxxyyyyzz does not look like an Stripe account id. Find the accounts connected to yours here.
Related
Hope somebody can help me with this one.
I am clueless right now.
I just started stripe for the first time.
Looks like an amazing service.
Have created a test application and started testing.
Everything works as it should.
Now after signing up, I want to go live.
Here is where the problem occurs.
Somehow, it keeps saying no such token, when I can see the token standing in the stripe account. The id of the account and our database is completely the same.
Stripe::setApiKey('[our live token]');
/*
* create new customer
*/
$results = \Stripe\Charge::create([
"amount" => '10',
"currency" => "jpy",
"source" => $getCommission->unique_id,
"description" => "test charge"
]);
Anybody has ever experienced this?
It keeps saying the following
No such token: cus_EuguGZgeDoCxBj
Help is highly appriciated.
Wesley
You are providing customer id instead of source token.
Source Token :
Source token is token which is used for referenced of your cards. Generated from Stripe.js
\Stripe\Stripe::setApiKey("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
\Stripe\Charge::create([
"amount" => 2000,
"currency" => "usd",
"source" => "tok_amex", // obtained with Stripe.js
"description" => "Charge for jenny.rosen#example.com"
]);
How to get Default Source :
Get Stripe Customer
Get default source on the Behalf of that customer
\Stripe\Stripe::setApiKey("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
$customer = \Stripe\Customer::retrieve('cus_EkSwM3JX7f0ueA');
$customer->default_source; // use this as source token
Use default source as source token
For my shopping site I have a fairy simple stripe implementation on the frontend where user hits "pay through stripe" button fills in CC details in a popup and hits proceed. If all goes well I get a token as $_POST['stripeToken'] which I process like below (for web payments)
try
{
$stripe = new Stripe();
$stripe = Stripe::make();
$customer = $stripe->customers()->create([
'email' => $_POST['email_id'],
'source' => $_POST['stripeToken']
]);
$charge = $stripe->charges()->create([
'customer' => $customer['id'],
'amount' => $total_amount, // note this is calculated again on server to prevent fraud
'currency' => 'sgd'
]);
}
catch (\Cartalyst\Stripe\Exception\CardErrorException $e)
{
return view('front.payment_error')->with('message', $e->getMessage());
}
Thing is we cannot rely on $total_amount coming from frontend form submission as user can easily spoof this amount and pay just $1 in stripe and get a token and spoof $total_amount to 1 thus getting products at whatever price he wants ,that's why I need to calculate his `$total_amount again on the server (from his cart) and use that to process stripe on the server.If that amount doesn't match what the token stands for , stripe would automatically raise an exception and prevent fraud.
So far good.. but the problem comes when dealing with API , mobile app will process stripe using their own libs. on the client side they would just send the final (for recording in db) but obviously I cannot use it to charge since that is already done on the mobile.Since these days it's very easy to change app behaviour (by patching apks) or craft custom HTTP request (postman) , server check is a must in case of payments.
So my question is how can I verify from the token the actual amount user paid
ie. reverse convert stripeToken => actual paid amount
Update:
This is what I am looking in case of Stripe
https://developer.paypal.com/docs/integration/mobile/verify-mobile-payment/
I have hosted my PHP application and everything is working fine except for the Stripe Payment integration in it.
Can someone suggest what could be the error?
require_once('../../Stripe/init.php');
\Stripe\Stripe::setApiKey('sk_test_************');
$e="";
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = \Stripe\Charge::create(array(
"amount" => $stripe_amount, // amount in cents, again
"currency" => "cad",
"source" => $token,
"description" => "Buy Gift Card"
));
} catch(\Stripe\Error\Card $e) {
$e = "Your card has been declined, please enter a valid card";
}
It's working fine on my local machine, but on my hosting it gives me this error:
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
I am facing following problem while doing stripe payment.
Uncaught exception 'Stripe\Error\Authentication' with message 'Only Stripe Connect platforms can work with other accounts. If you specified a client_id parameter, make sure it's correct
I am using the php code below:
$charge = \Stripe\Charge::create(
array(
"amount" => $amount*100, // amount in cents
"currency" => $currency, // usd
"source" => $token,
"description" => $description,
"application_fee" => 123 // amount in cents
),
array("stripe_account" => 'cus_7Gt1CAXXXXXX') // CONNECTED_STRIPE_ACCOUNT_ID
);
And another question is that from where I can get CONNECTED_STRIPE_ACCOUNT_ID like that acct_12QkqYGSOD4XXXXXX. if possible please send code or screenshot or location to get these account id.
Can anyone please help to solve that problem?
You have to create 'Connect with Stripe' button in your app which will redirect user to fill form to authorize your app.
After Clicking on Authorize button(by user,after filling form properly), it will redirect to 'Redirect URI(redirect URI is that URI which you fill in Platform Setting)'.
After redirection stripe will add scope and authorization code to your URI
for eg. your URI: www.yoursite.com
you will get www.yoursite.com?scope=read_write&authorization_code=AUTHORIZATION_CODE
After That follow----> https://stackoverflow.com/a/34714859/5467417
I use Inchoo's extension for connecting Magento and Stripe payment. Inchoo component is simple and it is based on https://github.com/stripe/stripe-php. When I use it for test payments it works as it should be.
But I need stripe connect because of 'application_fee' and I now have problem.
According tutorial stripe.com/docs/connect/oauth I use https://gist.github.com/afeng/3507366
and everything still works great.
According stripe.com/docs/connect/collecting-fees :
We have following code -
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
$charge = Stripe_Charge::create(array(
"amount" => 1000, // amount in cents
"currency" => "usd",
"card" => $token,
"description" => "payinguser#example.com"),
"application_fee" => 123 // amount in cents
),
**ACCESS_TOKEN** // user's access token from the Stripe Connect flow
);
But ACCESS_TOKEN is problem, because I use the one that I get in previous step 'stripe.com/docs/connect/oauth'
and get error:
OAuth based requests must use card tokens from Stripe.js, but card details were directly provided.
Why and where I should use Stripe.js? Everything works great until 'ACCESS_TOKEN' is requested and it says :
// user's access token from the Stripe Connect flow - I already have ACCESS_TOKEN
from
(stripe.com/docs/connect/oauth)
{
"token_type": "bearer",
"stripe_publishable_key": PUBLISHABLE_KEY,
"scope": "read_write",
"livemode": "false",
"stripe_user_id": USER_ID,
"refresh_token": REFRESH_TOKEN,
"access_token": ACCESS_TOKEN
}
problem w