GreenDropShip logo
GreenDropShip logo

All articles

API Integration: Magento and StripeUpdated a year ago

Below are the steps required to be able to integrate with our API for Order Management. Note, you would need to integrate with both Magento and Stripe.

1*** [USERNAME/PASSWORD - MEMBERS' CREDENTIALS]
2
3POST /V1/integration/customer/token
4HOST: https://members.greendropship.com/rest/default
5
6HEADERS:
7Content-Type: application/json
8
9PAYLOAD:
10{
11   "username": "USERNAME",
12   "password": "PASSWORD"
13}
14
15RESPONSE: "CUSTOMER_TOKEN"
1*** [CUSTOMER_TOKEN = RESPONSE POST /V1/integration/customer/token]
2
3POST /V1/carts/mine
4HOST: https://members.greendropship.com/rest/default
5
6HEADERS:
7Content-Type: application/json
8Authorization: Bearer CUSTOMER_TOKEN
9
10PAYLOAD: []
11
12RESPONSE: QUOTE_ID
1*** [CUSTOMER_TOKEN = RESPONSE POST /V1/integration/customer/token]
2*** [QUOTE ID = RESPONSE POST /V1/carts/mine]
3*** [SKU / QTY REQUIRED FOR CUSTOMER - SAMPLE KHFM00086520 x 1]
4
5POST /V1/carts/mine/items
6HOST: https://members.greendropship.com/rest/default
7
8HEADERS:
9Content-Type: application/json
10Authorization: Bearer CUSTOMER_TOKEN
11
12PAYLOAD:
13{
14   "cartItem": {
15      "sku": "SKU",
16      "qty": QTY,
17      "quote_id": "QUOTE_ID"
18   }
19}
20
21RESPONSE:
22{
23   "item_id": 355351,
24   "sku": "KHFM00086520",
25   "qty": 1,
26   "name": "BOBS RED MILL: Old Country Style Muesli Whole Grain Cereal, 18 oz",
27   "product_type": "simple",
28   "quote_id": "QUOTE_ID"
29}
1*** [CUSTOMER_TOKEN = RESPONSE POST /V1/integration/customer/token]
2
3Was used a sample address, need be submitted the shipping address of
4the customer of our member.
5
6From the response, can be selected which method should be used to
7ship this order.
8
9POST /V1/carts/mine/estimate-shipping-methods
10HOST: https://members.greendropship.com/rest/default
11
12HEADERS:
13Content-Type: application/json
14Authorization: Bearer CUSTOMER_TOKEN
15
16PAYLOAD:
17{
18   "address": {
19      "region_code": "CA",
20      "country_id": "US",
21      "street": [
22         "123 Oak Ave"
23      ],
24      "postcode": "10577",
25      "city": "Los Angeles",
26      "firstname": "Henry",
27      "lastname": "Aguilar",
28      "email": "[email protected]",
29      "telephone": "(222) 222-2222"
30   }
31}
32
33RESPONSE:
34[
35 {
36 "carrier_code": "mpmultishipping",
37 "method_code": "mpmultishipping",
38 "carrier_title": "Vendor",
39 "method_title": "MultiShipping",
40 "amount": 0,
41 "base_amount": 0,
42 "available": true,
43 "error_message": "",
44 "price_excl_tax": 0,
45 "price_incl_tax": 0
46 },
47 {
48 "available": true,
49 "amount": 0,
50 "carrier_code": "mpmultishipping",
51 "carrier_title": "Vendor",
52 "method_code": "mpmultishipping",
53 "method_title": "MultiShipping",
54 "sellerShipping": [
55 {
56 "seller_id": 4177,
57 "item_ids": "355351",
58 "products": "BOBS RED MILL: Old Country Style Muesli Whole Grain Cereal, 18 oz x 1",
59 "seller_name": "GreenDropShip",
60 "message": "(Flat rate shipping is based on cubic volume and total weight.)",
61 "methods": {
62 "webkulshipping_9": {
63 "method": "USPS/UPS - 3 days Transit Time (Shipping)",
64 "cost": 9.99,
65 "base_amount": 9.99,
66 "error": 0
67 },
68 "webkulshipping_73": {
69 "method": "FBA - Select ONLY if ordering FBA or WFS prep services. (Shipping)",
70 "cost": 0,
71 "base_amount": 0,
72 "error": 0
73 }
74 }
75 }
76 ]
77 }
78]
1*** [CUSTOMER_TOKEN = RESPONSE POST /V1/integration/customer/token]
2*** [ADDRESS INFORMATION > SHIPPING ADDRESS SAMPLE]
3*** [ADDRESS INFORMATION > BILLING ADDRESS SAMPLE]
4*** [SHIPPING_CARRIER_CODE = RESPONSE POST /V1/carts/mine/estimate-shipping-methods]
5*** [SHIPPING_METHOD_CODE = RESPONSE POST /V1/carts/mine/estimate-shipping-methods]
6
7Was used a sample address for shipping, need be submitted the shipping address
8of the customer of our member.
9
10Was used a sample address for billing, need be submitted the billing address
11of our member.
12
13Only valid mpmultishipping for SHIPPING_CARRIER_CODE and
14SHIPPING_METHOD_CODE.
15
16From the response, where exists the key sellerShipping some data needs to be
17extracted from the previous API call If only are being placed orders for
18items from vendor Green Drop Ship.
19
20MULTI_CUSTOMSHIP = If is not an FBA order use the field cost of the
21method "USPS/UPS - 3 days Transit Time (Shipping)". In this case, based on
22the sample is $9.99
23
24SELECTED_SHIPPING = JSON string with the following fields:
25
26  idx_vendor = Index key of the vendor
27  idx_method = Index key of the selected method
28
29  'sellerid' => ['sellerShipping'][idx_vendor]['seller_id'],
30  'itemid' => ['sellerShipping'][idx_vendor]['item_ids'],
31  'price' => ['sellerShipping'][idx_vendor]['methods'][idx_method ]['cost'],
32  'baseamount' => ['sellerShipping'][idx_vendor]['methods'][idx_method ]['base_amount'],
33  'code' => ['sellerShipping'][idx_vendor]['methods'][idx_method ],
34  'method' => ['sellerShipping'][idx_vendor]['methods'][idx_method ]['method']
35
36sample for SELECTED_SHIPPING:
37
38 {\"sellerid\":\"4177\",\"itemid\":\"355351\",\"price\":\"9.99\",\"baseamount\":\"9.99\",\"code\":\"webkulshipping_9\",\"method\":\"USPS/UPS - 3 days Transit Time (Shipping)\"}"
39
40POST /V1/carts/mine/shipping-information
41HOST: https://members.greendropship.com/rest/default
42
43HEADERS:
44Content-Type: application/json
45Authorization: Bearer CUSTOMER_TOKEN
46
47PAYLOAD:
48{
49   "addressInformation": {
50      "shipping_address": {
51         "region_code": "CA",
52         "country_id": "US",
53         "street": ["123 Oak Ave"],
54         "postcode": "10577",
55         "city": "Los Angeles",
56         "firstname": "Henry",
57         "lastname": "Aguilar",
58         "email": "[email protected]",
59         "telephone": "(222) 222-2222"
60      },
61      "billing_address": {
62         "region_code": "FL",
63         "country_id": "US",
64         "street": ["7807 NW 37TH STREET"],
65         "postcode": "33166",
66         "city": "Doral",
67         "firstname": "Allen",
68         "lastname": "Infante",
69         "email": "[email protected]",
70         "telephone": "(111) 111-1111"
71      },
72      "extension_attributes": {
73         "multi_customship": "MULTI_CUSTOMSHIP",
74         "selected_shipping": "SELECTED_SHIPPING",
75      },
76      "shipping_carrier_code": "SHIPPING_CARRIER_CODE",
77      "shipping_method_code": "SHIPPING_METHOD_CODE"
78   }
79}
80
81RESPONSE:
82{
83  "payment_methods": [
84    {
85      "code": "stripe_payments",
86      "title": "Credit Card"
87    }
88  ],
89  "totals": {}
90}
91
1*** [CUSTOMER_TOKEN = RESPONSE POST /V1/integration/customer/token]
2*** [STRIPE_TOKEN - NEED BE SUBMITTED THIS INFO FROM OUR MEMBER]
3*** [METHOD = RESPONSE POST /V1/carts/mine/shipping_information (payment_methods.code)]
4
5STRIPE_TOKEN format is pm_1EkcHALcxRajh5XXXXXXXXXX, you can
6get this from the last email received when placing orders.
7
8POST /V1/carts/mine/payment-information
9HOST: https://members.greendropship.com/rest/default
10
11HEADERS:
12Content-Type: application/json
13Authorization: Bearer CUSTOMER_TOKEN
14
15PAYLOAD:
16{
17   "paymentMethod": {
18      "method": "METHOD",
19      "additional_data": {
20         "token": "STRIPE_TOKEN"
21      }
22   }
23}
24
25RESPONSE: ENTITY_ID

 

If you want to use Store Credits:

 

GET /V1/carts/mine/aw-get-customer-store-credit

* (Retrieve customer Store Credit details)

GET /V1/carts/mine/aw-store-credit

* (Returns information for a Store Credit in a specified cart)

PUT /V1/carts/mine/apply-aw-store-credit

* (Add Store Credit to a specified cart)

DELETE /V1/carts/mine/remove-aw-store-credit

* (Remove Store Credit from a specified cart)

 

In the script before placing the order (POST /V1/carts/mine/payment-information), the store credit needs to be applied.

1*** [CUSTOMER_TOKEN = RESPONSE POST /V1/integration/customer/token]
2
3PUT /V1/carts/mine/apply-aw-store-credit
4HOST: https://members.greendropship.com/rest/default
5
6HEADERS:
7Content-Type: application/json
8Authorization: Bearer CUSTOMER_TOKEN
9
10RESPONSE: true
1*** [CUSTOMER_TOKEN = RESPONSE POST /V1/integration/customer/token]
2*** [METHOD = RESPONSE POST /V1/carts/mine/shipping_information]
3
4The only method valid is "free" if you are paying the 100% of the
5total amount with store credits
6
7POST /V1/carts/mine/payment-information
8HOST: https://members.greendropship.com/rest/default
9
10HEADERS:
11Content-Type: application/json
12Authorization: Bearer CUSTOMER_TOKEN
13
14PAYLOAD:
15{
16   "paymentMethod": {
17      "method": "free",
18      "additional_data": null
19   }
20}
21
22RESPONSE: ENTITY_ID

 

Was this article helpful?
Yes
No