FAC10 / fac-donation-app

A donation app for Founders & Coders!
https://fac-donation-app.herokuapp.com/
4 stars 0 forks source link

Stripe integration research #24

Open jessicasalmon opened 7 years ago

jessicasalmon commented 7 years ago

let's collate a readme for stripe integration. Please leave findings in comments, and then we can make it into a coherent document once we've successfully integrated stripe into our app

jessicasalmon commented 7 years ago

1 pomodoro dummy object representing the customer information that stripe will store for us:

customer object

{
  "id": "cus_Aat5sroWwNme5E",
  "object": "customer",
  "account_balance": 0,
  "created": 1493894172,
  "currency": null,
  "default_source": "card_1AFhJ2DelOQugZzAjA2kX48P",
  "delinquent": false,
  "description": "Mason White",
  "discount": null,
  "email": "mason.white.28@example.com",
  "livemode": false,
  "metadata": {},
  "shipping": null,
  "sources": {
    "object": "list",
    "data": [
      {
        "id": "card_1AFhJ2DelOQugZzAjA2kX48P",
        "object": "card",
        "address_city": null,
        "address_country": null,
        "address_line1": null,
        "address_line1_check": null,
        "address_line2": null,
        "address_state": null,
        "address_zip": "94301",
        "address_zip_check": "pass",
        "brand": "Visa",
        "country": "US",
        "customer": "cus_Aat5sroWwNme5E",
        "cvc_check": "pass",
        "dynamic_last4": null,
        "exp_month": 12,
        "exp_year": 2018,
        "fingerprint": "uaStcxNonTKyApaZ",
        "funding": "credit",
        "last4": "4242",
        "metadata": {},
        "name": null,
        "tokenization_method": null
      }
    ],
    "has_more": false,
    "total_count": 1,
    "url": "/v1/customers/cus_Aat5sroWwNme5E/sources"
  },
  "subscriptions": {
    "object": "list",
    "data": [],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_Aat5sroWwNme5E/subscriptions"
  }
}

one-time charge object

{
  "id": "ch_1AFhSpDelOQugZzAxgOfoLkH",
  "object": "charge",
  "amount": 2000,
  "amount_refunded": 0,
  "application": null,
  "application_fee": null,
  "balance_transaction": "txn_1AFhSpDelOQugZzAeL0oBu9I",
  "captured": true,
  "created": 1493894739,
  "currency": "gbp",
  "customer": "cus_Aat5sroWwNme5E",
  "description": null,
  "destination": null,
  "dispute": null,
  "failure_code": null,
  "failure_message": null,
  "fraud_details": {},
  "invoice": null,
  "livemode": false,
  "metadata": {},
  "on_behalf_of": null,
  "order": null,
  "outcome": {
    "network_status": "approved_by_network",
    "reason": null,
    "risk_level": "normal",
    "seller_message": "Payment complete.",
    "type": "authorized"
  },
  "paid": true,
  "receipt_email": null,
  "receipt_number": null,
  "refunded": false,
  "refunds": {
    "object": "list",
    "data": [],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/charges/ch_1AFhSpDelOQugZzAxgOfoLkH/refunds"
  },
  "review": null,
  "shipping": null,
  "source": {
    "id": "card_1AFhJ2DelOQugZzAjA2kX48P",
    "object": "card",
    "address_city": null,
    "address_country": null,
    "address_line1": null,
    "address_line1_check": null,
    "address_line2": null,
    "address_state": null,
    "address_zip": "94301",
    "address_zip_check": "pass",
    "brand": "Visa",
    "country": "US",
    "customer": "cus_Aat5sroWwNme5E",
    "cvc_check": null,
    "dynamic_last4": null,
    "exp_month": 12,
    "exp_year": 2018,
    "fingerprint": "uaStcxNonTKyApaZ",
    "funding": "credit",
    "last4": "4242",
    "metadata": {},
    "name": null,
    "tokenization_method": null
  },
  "source_transfer": null,
  "statement_descriptor": null,
  "status": "succeeded",
  "transfer_group": null
}

recurring charge/ subscription object

{
  "id": "diamond-infinite-707",
  "object": "plan",
  "amount": 999,
  "created": 1493895054,
  "currency": "gbp",
  "interval": "month",
  "interval_count": 1,
  "livemode": false,
  "metadata": {},
  "name": "Diamond Infinite",
  "statement_descriptor": null,
  "trial_period_days": null
}

payment process:

  1. customer enters card details (card information is sent directly to stripe, so sensitive information will never hit our server). We receive a token.
  2. Using this token, we could immediately perform a one-time charge. BUT, what we want to do is store this token against a user('customer') obj, so that we can user their payment method for repeat charges.
  3. now that we have this info, we can charge a customer anytime
  4. now that we have this info, we can create a 'plan' object (a way we refer to our recurring charge). Plans should have their own names (e.g. bronze plan, silver plan, gold plan)
  5. we link our customer object with our plan object. Stripe will automatically handle the recurring billing
joeylouise commented 7 years ago

We will need to use the stripe npm module

npm install --save stripe

jessicasalmon commented 7 years ago

email as unique identifier?