salimsaid
salimsaid

Reputation: 3495

Shopify Custom payment gateway without using Hosted Payment SDK

Shopify mentions using their Hosted Payment SDK as their only way for implementing payment gateways for shopify. My requirement is a bit different. Here is my scenario

The customer checks out an order, then i have custom app (built by us) within shopify that customizes the checkout page and shows them a button that says "Make payment", when the user clicks on this button, they are sent out of shopify and brought to an external page that captures the order details passed during redirect, here the customer would pay for their order, after the payment is successful, the external app will call the shopify admin api and update payment status for this order, setting it to paid status, then the customer gets redirected back to shopify and the order is complete.

Using this flow, I won't have to use shopify's hosted payment SDK which requires approval and takes close to 30 for their team to get back to me.

I am new to shopify , would this be possible ? Is it possible to change order payment status using the shopify admin api ?

Upvotes: 3

Views: 1330

Answers (1)

Tomasz Ferfecki
Tomasz Ferfecki

Reputation: 1263

In Shopify Order Rest API you can use field

financial_status

For creating new payment create order with pending status. After payment is completed change it to paid status.

The status of payments associated with the order. Can only be set when the order is created.

Important!

That means You can only change financial_status value for order that is created with this field.

Valid values:

  • pending: The payments are pending. Payment might fail in this state. Check again to confirm whether the payments have been paid successfully.
  • authorized: The payments have been authorized.
  • partially_paid: The order have been partially paid.
  • paid: The payments have been paid.
  • partially_refunded: The payments have been partially refunded.
  • refunded: The payments have been refunded.
  • voided: The payments have been voided.

Example with updating order status to paid:

PUT /admin/api/2021-01/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "financial_status": "paid"
  }
}

You can read more on shopify Rest API Order reference page

Upvotes: 0

Related Questions