How can I use Stripe to delay charging a customer until a physical item is shipped?

前端 未结 5 1555
北海茫月
北海茫月 2021-02-03 11:47

I\'m in the process of building an online marketplace which sells shippable goods. The site will be similar to Etsy, which will connect merchants with buyers.

I\'d like

相关标签:
5条回答
  • 2021-02-03 12:21

    <?php
    
    require_once('stripe-php/init.php');
    \Stripe\Stripe::setApiKey('your stripe key'); 
    $token  = $_POST['stripeToken'];
    
    $stripeinfo = \Stripe\Token::retrieve($token);
     
         $email = $stripeinfo->email;
       
       
       $customer = \Stripe\Customer::create(array(
        "source" => $token,
        "email" => $email)
    );
    
    ?>

    0 讨论(0)
  • 2021-02-03 12:27

    After further research, it seems there's no way to delay capturing a charge past the 7 day authorization window.

    But here's one way to delay a charge:

    1. Tokenize a credit card using the stripe.js library
    2. Create a new stripe customer passing in the token as the "card" param

    An example from the Stripe FAQ: https://support.stripe.com/questions/can-i-save-a-card-and-charge-it-later

    Note that the longer you wait between tokenizing a card and actually charging it, the more likely your charge will be declined for various reasons (expired card, lack of funds, fraud, etc). This also adds a layer of complexity (and lost sales) since you'll need to ask a buyer to resubmit payment info.

    I'd still like to confirm that a certain amount can be charged (like a "preauthorization"), but this lets me at least charge the card at a later date.

    0 讨论(0)
  • 2021-02-03 12:27

    Stripe release a delay method to place a hold without charging. https://stripe.com/docs/payments/capture-later

    0 讨论(0)
  • 2021-02-03 12:35

    Celery has built a service to help you do this with Stripe. They are very easy to use, but note that they charge 2% per transaction.

    0 讨论(0)
  • 2021-02-03 12:38

    actually you can save user token and pay later with tracking info

    # get the credit card details submitted by the form or app
    token = params[:stripeToken]
    
    # create a Customer
    customer = Stripe::Customer.create(
      card: token,
      description: 'description for payinguser@example.com',
      email: 'payinguser@example.com'
    )
    
    # charge the Customer instead of the card
    Stripe::Charge.create(
        amount: 1000, # in cents
        currency: 'usd',
        customer: customer.id
    )
    
    # save the customer ID in your database so you can use it later
    save_stripe_customer_id(user, customer.id)
    
    # later
    customer_id = get_stripe_customer_id(user)
    
    Stripe::Charge.create(
        amount: 1500, # $15.00 this time
        currency: 'usd',
        customer: customer_id
    )
    
    0 讨论(0)
提交回复
热议问题