Skip to content

rahultiwari91/shopify-java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shopify Java SDK

Shopify Java SDK for Orders and Gift Cards.

Generate the JAR from this repository then include it in your project libs folder. Now, follow the below steps to use the generated Jar in your project:

Property File Configuration

The following properties will be used to create the Shopify API Context:

accessToken=
apiVersion=2024-07
username=
password=
shopSubdomain=

API Call Example

How to create a Gift Card in Shopify?

  1. Set Gift Card Object

    // Set Gift Card Object
    GiftCard giftCard = new GiftCard();
    giftCard.setCode("12345678901234");
    giftCard.setNote("Not for gift card");
    giftCard.setInitialValue("10.00");
    giftCard.setBalance("10.00");
  2. Create Gift Card Request

    // Create Gift Card Request
    GiftCardRequest giftCardRequest = new GiftCardRequest();
    giftCardRequest.setGiftCard(giftCard);
  3. Create API Context

    // Create API Context
    ApiContext apiContext = new ApiContext();
    apiContext.setUsername("username");
    apiContext.setPassword("password");
    apiContext.setShopSubdomain("shopSubdomain");
    apiContext.setApiVersion("apiVersion");
  4. Gift Card API Resource

    // Gift Card API Resource
    GiftCardResource cardResource = new GiftCardResource(apiContext);
    try {
        // Execute the request
        GiftCardResponse cardResponse = cardResource.createGiftCard(giftCardRequest);
        System.out.println("GiftCard created");
    } catch (Exception e) {
        System.out.println("Error: " + e.getMessage());
    }

This example demonstrates how to create a Gift Card in Shopify using the Shopify Java SDK. Adjust username, password, shopSubdomain, and apiVersion with your actual Shopify API credentials. The GiftCard object is set with its properties, and then a GiftCardRequest is created. The API context is configured with the necessary credentials, and the Gift Card API Resource is used to execute the request and handle the response.

About

Shopify Java Sdk for Orders and Gift Card

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages