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

前端 未结 5 1592
北海茫月
北海茫月 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: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
    )
    

提交回复
热议问题