Stripe - Manual payout - php

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

Related

Make payment with stripe from Card

I'm new to Stripe and payment integration in general.
I would like to implement a payment system in my application. I have already set the credit card input, which is also verified by creating a token of this type:
{
"card": {
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"cvc_check": "unchecked",
"dynamic_last4": null,
"exp_month": 12,
"exp_year": 2025,
"funding": "credit",
"id": "card_1HZFtCHAdtJCId9lZP626zJI",
"last4": "4242",
"name": null,
"object": "card",
"tokenization_method": null
},
"client_ip": "5.171.212.113",
"created": 1601989654,
"id": "tok_1HZFtCHAdtJCId9lxdU1jFVa",
"livemode": false,
"object": "token",
"type": "card",
"used": false
}
so far so good, what I should do is send this token to my php server (an external hosting without any particular library installed). Can anyone explain to me how to process the payment from back-end? I checked the documentation but none of them explain how to do it using a normal php hosting. I thank everyone in advance for taking the time!
Data Source: https://stripe.com/docs/api/
Considering you have already installed stripe you would follow these steps.
If not you should use composer to install it.
composer require stripe/stripe-php
1)Authentication
The Stripe API uses API keys to authenticate requests so you must auth first using your API keys to use anything. https://dashboard.stripe.com/login?redirect=/account/apikeys
$stripe = new \Stripe\StripeClient(INSERT_API_KEY_HERE);
2)Create a charge
You already got your card so you can charge it.
Edit: You can get all the data you need by making a request using the api. By the time you create a user in your app, you should also create a Customer using stripe and save their stripe-id in your database so you can access to their data.
Creating a customer
$customer = $stripe->customers->create(['description' => 'My First Test Customer',]);
// Save your customer ID using $customer->id
Charging the card
$stripe->charges->create([
'amount' => 2000,
'currency' => 'usd',
'source' => 'INSERT_CARD_ID',
'description' => 'My First Test Charge',
]);
Source:
A payment source to be charged. This can be the ID of a card (i.e., credit or debit card), a bank account, a source, a token, or a connected account. For certain sources—namely, cards, bank accounts, and attached sources—you must also pass the ID of the associated customer.
While #Juan has answered above using the Charges API, for an integration which supports Strong Customer Authentication I would recommend using the Payment Intents API.
You can read through the end-to-end guide for creating a payment which includes both client and server code snippets in a variety of languages (including PHP). This is the recommend pattern.
Since you already have a card_123 if you want to attempt payment without SCA support, you can actually go right to creating the payment:
\Stripe\PaymentIntent::create([
'amount' => 1234,
'currency' => 'usd',
// 'customer' => 'cus_567', // only if you've attached the card
'payment_method' => 'card_123',
'error_on_requires_action' => true,
'confirm' => true,
]);

Create charge using Stripe in Laravel working in test mode but not in live

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

How to get payer id from paypal via IOS MSDK2.x?

I have a question when using the Paypal IOS MSDK2.x in conjunction with Kount fraud checking.
Currently the MSDK2.x will return a payment confirmation in the delegate
"- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController didCompletePayment:(PayPalPayment *)completedPayment"
in this format of PayPalPayment class
{
"client": {
"environment": "sandbox",
"paypal_sdk_version": "2.0.0",
"platform": "iOS",
"product_name": "PayPal iOS SDK;"
},
"response": {
"create_time": "2014-02-12T22:29:49Z",
"id": "PAY-564191241M8701234KL57LXI",
"intent": "sale",
"state": "approved"
},
"response_type": "payment"
}
where the info "Payer Id" is not included.
To work with Konut, the Kount server needs the "Payer Id" to be provided/updated in the inquiry. This "Payer Id" can be obtained if the payment request is made via web form where the paypal server will return a URL of this format
"http://<return_url>?paymentId=PAY-6RV70583SB702805EKEYSZ6Y&token=EC-60U79048BN7719609&PayerID=7E7MGXCWTTKK2"
My question is anyone know how to get the "Payer Id" if the payment request is sent from mobile device that runs IOS MSDK2.x?
Thanks very much.
Actually I have solved this problem. Just had not got time to update it here.
The steps to do this are:
Use the payment id to get the security token from here
"https://api.paypal.com/v1/oauth2/token"
Use "POST" with your paypal private token.
Use the security token to to get the payer id.
https://api.paypal.com/v1/payments/payment/$your_payment_id"
You can use curl_setopt to do both steps on PHP. Hope this helps if anyone else has the same issue.
Thanks.

Google Wallet 500 Server Error

I got my subscriptions all working in the sandbox about 5 days ago, but a day after I finished testing it I started getting 500 server errors every time I try to test my subscriptions in sandbox and in production. I have not changed the code what so ever and my JWTs still decode perfectly.
Any ideas why this is happening? I've contacted Google many times but most of the people I get a hold of clearly have no idea what they are talking about...
Has anyone ever run into this issue before? Any input is appreciated!
The failing red line is the google sandbox code:
<script src="https://sandbox.google.com/checkout/inapp/lib/buy.js"></script>
POST:
[,"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxMTQ4MTc0NTgxNTIzNzcxMTY5OSIsImF1ZCI6Ikdvb2dsZSIsInR5cCI6Imdvb2dsZVwvcGF5bWVudHNcL2luYXBwXC9zdWJzY3JpcHRpb25cL3YxIiwiZXhwIjoxNDAyMjQ3NTMyLCJpYXQiOjE0MDIyNDM5MzIsInJlcXVlc3QiOnsibmFtZSI6IkF1dG9tYXRvbiBTY2hlZHVsZXIgU3Vic2NyaXB0aW9uIChQUk8pIiwiZGVzY3JpcHRpb24iOiJNb250aGx5IHN1YnNjcmlwdGlvbiB3aXRoIHVwIHRvIDUwIHVzZXJzLiIsImN1cnJlbmN5Q29kZSI6IlVTRCIsInNlbGxlckRhdGEiOiJ1c2VyX2lkOixzdWJzY3JpcHRpb25faWQ6MiIsImluaXRpYWxQYXltZW50Ijp7InBheW1lbnRUeXBlIjoiZnJlZV90cmlhbCJ9LCJyZWN1cnJlbmNlIjp7InByaWNlIjoiNjAuMDAiLCJjdXJyZW5jeUNvZGUiOiJVU0QiLCJmcmVxdWVuY3kiOiJtb250aGx5In19fQ.sju0xaOf9u3ufxow0XxWF4j-QUY0XgtF0A0d8g1rRiQ",,,1]
Response:
[,,4,"VTTMKJ"]
Based on above, this is the request object in your JWT payload:
"request": {
"name": "Automaton Scheduler Subscription (PRO)",
"description": "Monthly subscription with up to 50 users.",
"currencyCode": "USD",
"sellerData": "user_id:,subscription_id:2",
"initialPayment": {
"paymentType": "free_trial"
},
"recurrence": {
"price": "60.00",
"currencyCode": "USD",
"frequency": "monthly"
}
}
Note the docs regarding the structure and required fields in a subscription request. So:
There is no currencyCode in a subscription request
The above initialPayment object is missing required fields:
price
currencyCode
Hth....

Stripe connect and PHP / Magento

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

Categories