Git Product home page Git Product logo

Comments (3)

mraerino avatar mraerino commented on June 6, 2024

Vendor docs

Together with a customer we decided to try to support the synchronous flow first. The asynchronous one may follow later.

New payments flow

  • Client: Create a payment method and pass that to POST /orders/:order_id/payments
  • Server: Create a PaymentIntent with the payment method from the client - report back if the payment needs more actions (including the client secret for the payment intent)
  • Client: Completes additional action and calls POST /payments/:payment_id/confirm
  • Server: Responds with the result of checking if the transaction is completed, updates payment status on order

from gocommerce.

mraerino avatar mraerino commented on June 6, 2024

API docs for updated/new endpoints

POST /orders/:order_id/payments

Payload:

{
  "provider": "stripe",
  "stripe_payment_method_id": "<the id>"
}

Response: Transaction object
(state if 3D secure is pending)

{
  "id": "...", // transaction id
  "order_id": "...",
  "invoice_number": "...",
  "processor_id": "...",
  "user_id": "...",
  "amount": "...",
  "currency": "...",
  "status": "pending",
  "type": "...",
  "created_at": "...",
  "provider_metadata": {
    "payment_intent_secret": "<client secret>"
  }
}

POST /payments/:payment_id/confirm

(payment id from previous response)

Payload: none

Response:

{
  "id": "...",
  "order_id": "...",
  "invoice_number": "...",
  "processor_id": "...",
  "user_id": "...",
  "amount": "...",
  "currency": "...",
  "status": "paid",
  "type": "...",
  "created_at": "..."
}

from gocommerce.

mraerino avatar mraerino commented on June 6, 2024

Updates to the SDK (gocommerce.js)

  • GoCommerce.payment(payment_details)
  • GoCommerce.paymentConfirm(payment_id) new method

Example

const { status, provider_metadata, id: paymentId } = GoCommerce.payment({ stripe_payment_method_id: "..." })
if (status === "pending") {
  const { payment_intent_secret } = provider_metadata
  // do 3D secure
  try {
    GoCommerce.paymentConfirm(paymentId)
  }
}

from gocommerce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.