简体   繁体   中英

Stripe - Manual payout

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:

  1. 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).
  2. Render your service
  3. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM