juspay_expresscheckout v0.1.0 Juspay.Orders

Represents an order placed for your service.

Summary

Functions

Create an order that is a representation of your shopping cart. Order contains important information like amount, customer details, shipping address, billing address etc. Payment will be initiated on the order

List the orders that were created. By default, the orders are listed in the reverse chronological order (starting from the order that was most recently created)

Create a refund for a payment

Retreive the information associated with a perticular order_id

Update an order that has already been created. Only amount, address and udf fields can be updated. Address fields can be optionally sent as explained in the /order/create API

Functions

create(parameters)

Specs

create(list) :: map
create(map) :: map

Create an order that is a representation of your shopping cart. Order contains important information like amount, customer details, shipping address, billing address etc. Payment will be initiated on the order.

Note: You can also send custom data in the following fields: udf1, udf2, …, udf10.

Examples

  # input in the form of map

  iex> Juspay.Orders.create(%{:order_id => "142315694476", :amount => 90.30,:currency => "INR",:customer_id => "guest",
                       :customer_email => "custome32@mail.com", :customer_phone => "9985115522",:product_id => "prod-141833",
                       :return_url => "http://shop.merchant.com/pay/handleResponse",:description => "Sample description",
                       :billing_address_first_name => "firstname",:billing_address_last_name => "lastname",
                       :billing_address_line1 => "Line1", :billing_address_line2 => "Line2", :billing_address_line3 => "Line3",
                       :billing_address_city => "Chennai", :billing_address_state => "TamilNadu", :billing_address_country => "India",
                       :billing_address_postal_code => "600020", :billing_address_phone => "9988775566", :billing_address_country_code_iso => "IND",
                       :shipping_address_first_name => "firstname", :shipping_address_last_name => "lastname",
                       :shipping_address_line1 => "Line1", :shipping_address_line2 => "Line2",shipping_address_line3 => "Line3",
                       :shipping_address_city => "Chennai", :shipping_address_state => "TamilNadu", :shipping_address_postal_code => "600020",
                       :shipping_address_phone => "9962881912", :shipping_address_country_code_iso => "IND", :shipping_address_country => "Ind"
                      })

  # response

   %{
      "amount" => 90.3, "amount_refunded" => 0, "currency" => "INR",
      "customer_email" => "custome32@mail.com", "customer_id" => "guest",
      "customer_phone" => "9985115522", "merchant_id" => "Srene",
      "order_id" => "142315694476", "product_id" => "", "refunded" => false,
      "return_url" => "http://shop.merchant.com/payments/handleResponse",
      "status" => "NEW", "status_id" => 10, "udf1" => "", "udf10" => "",
      "udf2" => "", "udf3" => "", "udf4" => "", "udf5" => "", "udf6" => "",
      "udf7" => "", "udf8" => "", "udf9" => ""
    }
list()

Specs

list :: list
list :: list

List the orders that were created. By default, the orders are listed in the reverse chronological order (starting from the order that was most recently created)

Examples

  # Example input request

  iex> Juspay.Orders.list()

  # response

  %{ "count" => 10,
      "list" => [
                  %{"amount" => 90, "amount_refunded" => 0, "currency" => "INR",
                   "customer_email" => "custovmer@mail.com", "customer_id" => "guest_101",
                   "customer_phone" => "9908665522", "merchant_id" => "Srene",
                   "order_id" => "1418304477", "product_id" => "", "refunded" => false,
                   "return_url" => "http://shop.merchant.com/payments/handleResponse",
                   "status" => "NEW", "status_id" => 10, "udf1" => "", "udf10" => "",
                   "udf2" => "", "udf3" => "", "udf4" => "", "udf5" => "", "udf6" => "",
                   "udf7" => "", "udf8" => "", "udf9" => ""},

                 %{"amount" => 90, "amount_refunded" => 0, "currency" => "INR",
                   "customer_email" => "custovmer@mail.com", "customer_id" => "guest_101",
                   "customer_phone" => "9908665522", "merchant_id" => "Srene",
                   "order_id" => "1418304471", "product_id" => "", "refunded" => false,
                   "return_url" => "http://shop.merchant.com/payments/handleResponse",
                   "status" => "NEW", "status_id" => 10, "udf1" => "", "udf10" => "",
                   "udf2" => "", "udf3" => "", "udf4" => "", "udf5" => "", "udf6" => "",
                   "udf7" => "", "udf8" => "", "udf9" => ""},

                   .... ]
   }
refund(parameters)

Specs

refund(list | map) :: map

Create a refund for a payment.

Examples

  # input in the form of list

  iex> Juspay.Orders.refund([unique_request_id: '99',
                      order_id: '1465833326',
                      amount: 10])

  # input in the form of map (works with both string keyed map and atom keyed map)

  iex> Juspay.Orders.refund(%{ :unique_request_id => '99',
                        :order_id => '1465833326',
                        :amount => 10})

  # response

  %{
    "gateway_id" => 100,
    "status" => "CHARGED",
    "customer_email" => "user@gmail.com",
    "txn_id" => "txn-1465833326-1",
    "refunds" => [
                  %{
                      "status" => "SUCCESS",
                      "amount" => 10,
                      "created" => "2016-06-13T15:19:34Z"
                    },
                  ],
    "amount_refunded" => 10,
    "order_id" => "1465833326",
    "refunded" => false,
    "status_id" => 21,
    "bank_error_code" => "0",
    "bank_error_message" => "Payment Successful",
    "gateway_response" => %{
                            "epg_txn_id" => "1465831091168",
                            "auth_id_code" => "834050",
                            "resp_code" => "0",
                            "txn_id" => "txn-1465833326-1",
                            "resp_message" => "Payment Successful",
                            },
    "currency" => "INR",
    "amount" => 1000,
    "merchant_id" => "shop",
    "customer_id" => "shop_user_101",
    "card" => %{
      "isin" => "424242",
      "brand" => "VISA",
      "type" =>"CREDIT",
      "fingerprint" => "3rfeetv0blcc6bkroo4rvkjk62",
    }
  }
status(parameters)

Specs

status(list) :: map
status(map) :: map

Retreive the information associated with a perticular order_id

Examples

  # input in the form of list

  iex> Juspay.Orders.status(["order_id": "145678234" })

  # input in the form of map (works with both string keyed map and atom keyed map)

  iex> Juspay.Orders.status(%{ "order_id" => "145678234" }) or Juspay.Orders.status(%{ :order_id => "145678234" })

  # response

  %{
    "status" => "NEW",
    "amount_refunded" => 0,
    "status_id" => 10,
    "order_id" => "145678234",
    "refunded" => false,
    "currency" => "INR",
    "amount" => 1000,
    "merchant_id" => "shreyas"
   }
update(parameters)

Specs

update(list | map) :: map

Update an order that has already been created. Only amount, address and udf fields can be updated. Address fields can be optionally sent as explained in the /order/create API.

Examples

  # input in the form of list

  iex> Juspay.Orders.update( [order_id: "142315694476", amount: 100.30])

  # input in the form of map (works with both string keyed map and atom keyed map)

  iex> Juspay.Orders.update(%{ "order_id" => "142315694476", "amount" => 100.30 })

  %{
      "amount" => 100.3, "amount_refunded" => 0, "currency" => "INR",
      "customer_email" => "custome32@mail.com", "customer_id" => "guest",
      "customer_phone" => "9985115522", "merchant_id" => "Srene",
      "order_id" => "142315694476", "product_id" => "", "refunded" => false,
      "return_url" => "http://shop.merchant.com/payments/handleResponse",
      "status" => "NEW", "status_id" => 10, "udf1" => "", "udf10" => "",
      "udf2" => "", "udf3" => "", "udf4" => "", "udf5" => "", "udf6" => "",
      "udf7" => "", "udf8" => "", "udf9" => ""
    }