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
Related
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.
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
In my application i'm holding some amount in user's custom account for a specific reason by setting "Payout schedule" as "Manual". This lets me hold the payout in custom acccount to a maximum of 90 days. And a user can realease the payment to the external account in certain scenerios even before 90 days.
Now my Question is, As Stripe takes 2 to 7 days in rolling out the payment so i can only release the payment after the processing gets completed.
How May i get to know about that? How would i know if the tranactions is in pending state and then How to know if it gets available for payout in bank account?
Is there any way to achieve it? Please let me know as im new to stripe.
Any help would be highly appreciated.
Are you talking about Auth and Capture? Auth is when you make sure that the user's bank ALLOWS the user to make the transaction. Then, once the payment is Authorized, you then capture it, and the funds are transferred to Stripe.
Example: You are selling a service, such as Web Development, for $5000. You want to make sure that the person has the money first. You also want to make sure that the person who has the money doesn't spend it while you are rendering your service for them.
The way you would go about this is to:
Auth the payment through Stripe. You Auth the payment, and it goes into Pending in the person's bank account (they don't have access to spend that money any longer).
Render your service
Capture the payment. The money is deducted from their account and added to your Stripe account.
The way through Stripe's API to do this is: Auth
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
// Token is created using Checkout or Elements!
// Get the payment token ID submitted by the form:
$token = $_POST['stripeToken'];
// Charge the user's card:
$charge = \Stripe\Charge::create(array(
"amount" => 999,
"currency" => "usd",
"description" => "Example charge",
"capture" => false,
"source" => $token,
));
Render your service... Then Capture
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
$charge = \Stripe\Charge::retrieve("ch_1A9eP02eZvKYlo2CkibleoVM");
$charge->capture();
When you create the charge it will return an ID in the JSON results and whether or not it's been captured. If you want to check up to see if the Auth was successful, first save the ID in the response to the charge... The response will look something like this...
Stripe\Charge JSON: {
"id": "ch_1CCjK02eZvKYlo2C85c1GGmL",
"object": "charge",
"amount": 2000,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"balance_transaction": "txn_19XJJ02eZvKYlo2ClwuJ1rbA",
"captured": false,
......... more ........
},
To check on the charge, to see if it has been Authorized, you can do something like this...
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
\Stripe\Charge::retrieve("ch_1CCjK02eZvKYlo2C85c1GGmL");
And the response will be something like ...
Stripe\Charge JSON: {
"id": "ch_1CCjK02eZvKYlo2C85c1GGmL",
"object": "charge",
"amount": 2000,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"balance_transaction": "txn_19XJJ02eZvKYlo2ClwuJ1rbA",
"captured": true,
"created": 1522739568,
....more....
"outcome": {
"network_status": "approved_by_network",
"reason": null,
"risk_level": "normal",
"seller_message": "Payment complete.",
"type": "authorized" // AUTHORIZED
Then you charge. Done.
https://stripe.com/docs/charges
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