Code Monkey home page Code Monkey logo

api-checkout's Introduction

Arcadier

How to Use API calls to Checkout a Bespoke item

This guide is intended to assist users on the generic process of using our API calls to Checkout a Bespoke item. Make sure to pay close attention to all minor details as all the information you give and receive can be sensitive. The slightest change in detail can change the entire order of your checkout. Please take note that this document will be using Postman to call APIs, therefore your method of calling APIs may be different. All body paragraphs sent for API calls will be in JSON.

pre


Pre-Checkout - Add Item to Cart

For Buyers Only

Variables

The first step to checking out a Bespoke item would be adding that specific item to your cart. The necessary information that you need before calling the Pre-Checkout API would be:

  • {{your-marketplace} → Your marketplace domain
  • {{buyerID}} → the Buyer’s (your) user ID
  • {{buyertoken}} → the Buyer’s (your) token
  • The Item’s ID
    • Note that if an Item has any variance, this ID should be the ID of the specific variant of your item, NOT the generic item ID itself
  • Shipping Method’s ID
    • You can simply call another API “Get Shipping Methods” to obtain the ID
    • If you do not have one, you can also call another API “Create a shipping Method” to create one

Headers

For the authorization, you will need your Buyer’s token and allocate Authorization with the value as “Bearer {{buyertoken}}”.

1 header


Body

The Body of your API call should follow the following structure:

  • ItemDetail
    • ID: (The Item’s ID)
  • Quantity: Number of items you want
  • CartItemType: “delivery”
  • ShippingMethod
    • ID: (Shipping Method’s ID) Please follow the illustration below with your own information.

1body


URL

In order to call the actual API, you have to use the URL:

https://{{your-marketplace}}.arcadier.io/api/v2/users/{{buyerID}}/carts

Respectively, this is where you will place your marketplace domain and buyer’s user ID.


Response

The Response from the API Call will contain a lot of information regarding the addition of the item to your cart. However, please take note of the Cart Item ID, which should be the first ID variable you see.

1response


Checkout - Generate Invoice and Orders from Cart

For Buyers Only

Variables

After adding the item to your cart, it makes chronological sense for the next step to be checking out the cart. To do so, you will need the following variables:

  • {{your-marketplace} → Your marketplace domain
  • {{buyerID}} → the Buyer’s (your) user ID
  • {{buyertoken}} → the Buyer’s (your) token
  • The Cart Item ID
    • This is the ID that you should have gotten from the previous API call (Pre-Checkout)

Headers

For the authorization, you will need your Buyer’s token and allocate Authorization with the value as “Bearer {{buyertoken}}”.

2 header


Body

The body of this API call should contain all of the Cart Item IDs you want to check out. There can be multiple Cart Item IDs corresponding to a multi-item checkout. However, in this example, there is only one Cart Item ID, as we are only checking out one item, so that is the only thing that goes into the Body of this API call.

2body


URL

In order to call the actual API, you have to use the URL:

https://{{your-marketplace}}.arcadier.io/api/v2/users/{{buyerID}}/invoices/carts

Respectively, this is where you will place your marketplace domain and buyer’s user ID.


Response

As a result of this API call, an invoice will be generated with the specific payment parameters which will then be sent to the payment gateway for further actions. The response from the specific payment gateway will trigger the next step of the process, the Post-Checkout order details. However, take note of the Order ID (which you will use in the next step) and the Invoice number (which you will use in the last step).

2response


Post-Checkout - Edit Order Details

For Merchants Only, to Update Orders on their side after Receiving Money

Variables

After receiving a response from the payment gateway API, take note of the following variables as the next step is the post-checkout API to edit your order details:

  • {{your-marketplace} → Your marketplace domain
  • {{merchantID}} → the Merchant’s user ID
  • {{merchanttoken}} → the authorization token of the Merchant
  • The Order ID
    • This is the ID that you should have gotten from the previous API call (Checkout)
  • The Address ID
    • This is the ID of the Buyer’s address
    • You can simply call another API “User Address” to obtain the ID

Headers

For the authorization, you will need the Merchant’s token and allocate Authorization with the value as “Bearer {{merchanttoken}}”.

3 header


Body

The Body of your API call should follow the following structure:

  • FulfilmentStatus: “Acknowledged” if the item has not reached the buyer yet
    • “Delivered” if the item has reached the buyer
  • PaymentStatus: “Paid” if the buyer has paid
    • “Acknowledged” if the buyer has ordered and the seller has seen the order
    • “Processing” if the payment is being processed
    • “Waiting for Payment” if the buyer has not paid yet
      • No payment gateway (like Stripe)
      • Possibly COD (Cash on Delivery)
    • “Pending” if buyer has paid to the gateway but not yet received by seller
    • “Failed” if payment failed
    • “Refunded” if payment was refunded
  • Balance: Set to the amount of money you have NOT received yet for the item
    • For example, if the item cost $100 but you have received $40, this value should be 60
  • DeliveryToAddress
    • ID: The Address ID
  • CartItemType: “delivery” Please follow the illustration below with your own information

3body


URL

In order to call the actual API, you have to use the URL:

https://{{your-marketplace}}.arcadier.io/api/v2/merchants/{{merchantID}}/orders/{{orderID}}/

Respectively, this is where you will place your marketplace domain, and Merchant’s user ID, and order ID.


Response

The response that you’ll get from this API call will contain all of the payment details about the transaction. This is just for your information, you do not need to use this response for further API calls.


Post-Checkout - Update Payments for Invoice Number

For Admins Only

Variables

This API call is only for Admins to update payments for the invoice number (may possibly consist of multiple Order IDs). This step requires a lot of the variables from the previous API calls, so please take note of the following variables carefully:

  • {{your-marketplace} → Your marketplace domain
  • {{adminID}} → the Admin’s user ID
  • {{admintoken}} → the authorization token of the Admin
  • The Invoice ID
    • This is the ID that you should have gotten from the Checkout API call
    • Keep in mind, this is different than the Order ID
  • Buyer’s user ID
  • Merchant’s user ID
  • The Order ID

Headers

For the authorization, you will need the Admin’s token and allocate Authorization with the value as “Bearer {{admintoken}}”.

4 header


Body

The first few lines of the Body of your API call should follow the following structure:

  • InvoiceNo: The Invoice ID
  • Payer
    • ID: The Buyer’s user ID
  • Payee
    • ID: The Merchant’s user ID
  • Order
    • ID: The Order ID
  • Status: "Success" (read below) Please follow the illustration below with your own information

4body

The rest of the body is just information for the Admin to update their database. It will not directly affect the outcome or status of the transaction, however, the above parameters will. Interestingly, if you set the Status of the transaction to “Success” like the illustration below, then the “Total”, “Fee”, “DateTimeCreated” and “DateTimePaid” will be filled automatically in the response. Depending on the payment gateway you used, please fill out the rest of the code manually. The time set is in Unix Timestamp.


URL

In order to call the actual API, you have to use the URL:

https://{{your-marketplace}}.arcadier.io/api/v2/admins/{{adminID}}/invoices/{{invoiceID}}/

Respectively, this is where you will place your marketplace domain, Admin’s user ID, and the invoice ID.


Response

The entire response indicates the finishing information for the entire checkout. It will have details consisting of the buyer, merchant, invoice, order, marketplace, etc. You can feel free to take note of the response, however, none of the information here is new. Meaning you do not need these details for further API calls.

4response

api-checkout's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.