How to add the payment transaction status in order placed by using Demandware OCAPI? - api

I'm developing API for the mobile app of e-commerce website which is on Demandware. I am using the OCAPI 18.8 to place an order and send the payment details to third-party payment processor which is Vantiv. I get the transaction ID and response code from Vantiv and want to update my order to store these payment transaction details into my order. But I could not find any resource in OCAPI which let me add the transaction Id and response code received from Vantiv. Below is the order which I have placed through OCAPI:
{
"_v": "18.8",
"_type": "order",
"_resource_state": "xyz",
"adjusted_merchandize_total_tax": 0,
"adjusted_shipping_total_tax": 0,
"billing_address": {
"_type": "order_address",
"city": "Boston",
"country_code": "US",
"first_name": "John",
"full_name": "John Martin",
"id": "xyz",
"last_name": "Martin"
},
"channel_type": "storefront",
"confirmation_status": "not_confirmed",
"created_by": "Customer",
"creation_date": "2018-11-20T10:37:58.055Z",
"currency": "USD",
"customer_info": {
"_type": "customer_info",
"customer_id": "xyz",
"customer_name": "Ammar Shahbaz",
"customer_no": "xyz"
},
"customer_name": "Ammar Shahbaz",
"export_status": "not_exported",
"last_modified": "2018-11-20T10:37:58.376Z",
"merchandize_total_tax": 0,
"notes": {
"_type": "simple_link",
"link": "link"
},
"order_no": "123",
"order_token": "xyz",
"order_total": 299.8,
"payment_instruments": [
{
"_type": "order_payment_instrument",
"amount": 299.8,
"payment_card": {
"_type": "payment_card",
"card_type": "Visa",
"credit_card_expired": false,
"expiration_month": 1,
"expiration_year": 2021,
"holder": "John Doe",
"masked_number": "************4240",
"number_last_digits": "4240"
},
"payment_instrument_id": "xyz",
"payment_method_id": "CREDIT_CARD"
}
],
"payment_status": "not_paid",
"product_items": [
{
"_type": "product_item",
"adjusted_tax": 0,
"base_price": 149.9,
"bonus_product_line_item": false,
"gift": false,
"item_id": "xyz",
"item_text": "Long Sleeve Sequin Shift Dress",
"price": 299.8,
"price_after_item_discount": 299.8,
"price_after_order_discount": 299.8,
"product_id": "xyz",
"product_name": "Dress",
"quantity": 2,
"shipment_id": "xyz",
"tax": 0,
"tax_basis": 299.8,
"tax_class_id": "xyz",
"tax_rate": 0,
"c_cost": 25.17,
"c_finalSale": false,
"c_outlet": false,
"c_taxClassID": "xyz"
}
],
"product_sub_total": 299.8,
"product_total": 299.8,
"shipments": [
{
"_type": "shipment",
"adjusted_merchandize_total_tax": 0,
"adjusted_shipping_total_tax": 0,
"gift": false,
"merchandize_total_tax": 0,
"product_sub_total": 299.8,
"product_total": 299.8,
"shipment_id": "xyz",
"shipment_total": 299.8,
"shipping_address": {
"_type": "order_address",
"city": "Boston",
"country_code": "US",
"first_name": "John",
"full_name": "John Martin",
"id": "xyz",
"last_name": "Martin"
},
"shipping_method": {
"_type": "shipping_method",
"description": "Order received within 5-8 business days",
"id": "xyz",
"name": "Standard",
"price": 0,
"shipping_promotions": [
{
"_type": "shipping_promotion",
"callout_msg": "Free shipping on U.S. orders of $125+",
"link": "link",
"promotion_id": "xyz",
"promotion_name": "Free Shipping With $125 Purchase"
}
],
"c_BxFlatrateFlag": false,
"c_IsBorderlinxMethod": false
},
"shipping_status": "not_shipped",
"shipping_total": 0,
"shipping_total_tax": 0,
"tax_total": 0
}
],
"shipping_items": [
{
"_type": "shipping_item",
"adjusted_tax": 0,
"base_price": 0,
"item_id": "xyz",
"item_text": "Shipping",
"price": 0,
"price_after_item_discount": 0,
"shipment_id": "xyz",
"tax": 0,
"tax_basis": 0,
"tax_class_id": "xyz",
"tax_rate": 0
}
],
"shipping_status": "not_shipped",
"shipping_total": 0,
"shipping_total_tax": 0,
"site_id": "site name",
"status": "created",
"taxation": "net",
"tax_total": 0
}
I have tried this resource
Patch /orders/{order_no}/payment_instruments/{payment_instrument_id}
{
"amount" : 299.8,
"payment_card" : {
"number":"424459xxxxxx4240",
"security_code":"121",
"holder":"John Martin",
"card_type":"Visa",
"expiration_month":1,
"expiration_year":2021
},
"payment_method_id" : "CREDIT_CARD",
"c_PaymentProcessor": "VANTIV_CREDIT",
"c_paymentTransaction": {
"custom": {
"litleAFTresponse": "Approved",
"litleAFTTxnId": "8283868xxx8288282"
}
}
}
to update my order but no success.
Please let me know if you have any suggestion. Thanks.

If you have payment auth occurring outside of commerce cloud for some reason, you may be able to handle things in custom request document attributes. Note that there's an option to skip 'authorization' in CC by the skip_authorization parameter. eg:
POST /shop/v19_3/orders/00000027/payment_instruments?skip_authorization=true HTTP/1.1
Host: example.com
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX
Content-Type: application/json
{
"amount": 49.99,
"payment_method_id": "MY_PAYMENT_METHOD",
"c_payment_token": "tokenvaluehere==",
"c_payment_status": "payment_status"
}
Then within your dw.ocapi.shop.order.payment_instrument.afterPOST you could add attributes to the Order's PaymentInstrument via the B2C API methods which are accessible via the callback's order parameter.
You'll want to check in the beforePOST hook to ensure that the c_payment_status param is an acceptable value and if not return a Status.ERROR type of status object. Then you can actually save the properties in the afterPOST hook where the objects you'll need are already created.
For example:
exports.paymentInstrumentAfterPOST = function(order, paymentInstrumentRequest) {
const PaymentTransaction = require('dw/order/PaymentTransaction');
const Status = require('dw/system/Status');
const Transaction = require('dw/system/Transaction');
let methodId = paymentInstrumentRequest.payment_method_id;
let instruments = order.getPaymentInstruments(methodId);
let instrument = instruments[0]; // FIXME you should actually iterate over this instead; just for demo
let paymentTransaction = instrument.getPaymentTransaction();
Transaction.begin();
paymentTransaction.setTransactionID(paymentInstrumentRequest.c_payment_token);
paymentTransaction.setType(PaymentTransaction.TYPE_AUTH);
Transaction.commit();
return new Status(Status.OK);
}
For more info on customizing the payment flow, see the Orders resource documentation
Disclaimer this is all code written free-hand in StackOverflow's answer form. I have not validated that this will actually run, but I hope it provides direction.

Internally in commerce cloud the below method call sets the transaction id: paymentInstrument.paymentTransaction.setTransactionID(anTransactionId) so your assumption is correct. This field is however not exposed in the shop API. From the documentation is is clear that the authorization of the payment should be triggered by commerce cloud. this is a security constraint. It is possible to customize the API to circumvent this limitation.

The platform itself has some internal workflows that you must follow step by step to complete an order via OCAPI Rest Api. You should follow the step by step workflow or if you don't find it ask your DW architect to guide you.

As of today, the platform provides a better way to handle this requirement. Under DATA API Endpoints you have now several entires to update overall order status, payment, shipment, or even shipping address. More details under official release notes:
You can now use Data API endpoints to update orders in server-to-server use cases, such as when an order management system or payment provider initiates a change.
Use new PUT commands to update the different types of order statuses.
PUT /sites/{site_id}/orders/{order_no}/confirmation_status
PUT /sites/{site_id}/orders/{order_no}/export_status
PUT /sites/{site_id}/orders/{order_no}/external_status
PUT /sites/{site_id}/orders/{order_no}/payment_status
PUT /sites/{site_id}/orders/{order_no}/shipping_status
PUT /sites/{site_id}/orders/{order_no}/status
Use a new PUT command to update an order’s shipping address.
PUT /sites/{site_id}/orders/{order_no}/shipments/{shipment_id}/shipping_address
Use new PATCH commands to update order and payment attributes.
PATCH /sites/{site_id}/orders/{order_no}
PATCH /sites/{site_id}/orders/{order_no}/payment_instruments/{payment_instrument_id}
PATCH /sites/{site_id}/orders/{order_no}/payment_instruments/{payment_instrument_id}/transaction
source: https://help.salesforce.com/articleView?id=sf.b2c_20_2_W6833203_ocapi_order_update_endpoints_as.htm&type=5

Related

Sandbox access token not working [Easyship]

We have to try to integrate Easyship courier API. And We are facing the below issue.
{
"rates": [],
"messages": [
"Sorry, we couldn't find any shipping solutions based on the information provided."
]
}
For more information, I have shared the request parameter and API response.
API URL:- https://api.easyship.com/v2/rates
Request Parameter:
{
"origin_address": {
"postal_code": "91601",
"city": "Los Ángeles",
"state": "CA",
"country_alpha2": "US"
},
"destination_address": {
"postal_code": "95140",
"city": "Mount Hamilton",
"state": "CA",
"country_alpha2": "US"
},
"parcels": [
{
"total_actual_weight": 5,
"items": [
{
"quantity": 1,
"category": "mobile_phones",
"dimensions": {
"width": 10,
"height": 10,
"length": 25
},
"description": "Apple iPad",
"actual_weight": 5,
"declared_currency": "USD",
"declared_customs_value": 49500.55
}
]
}
]
}
Response Parameter:
{
"status": "failure",
"errors": [
"Sorry, we couldn't find any shipping solutions based on the information provided."
],
"request_id": "545b5f76a41e2994a13f384559dee625",
"timestamp": "2022-10-12T10:09:21.272Z"
}
Note:
This request parameter works with the production access token.
We have applied all possible solutions for this issue but didn't find anything.
Also we don't want to use the production access token because we are in the developing stage. so please please provide working with a sandbox solution.

How to add query parameters in Zoom API (GET) request?

I'm trying to get all meeting recordings saved in the cloud in a date range using using the following API:
https://marketplace.zoom.us/docs/api-reference/zoom-api/cloud-recording/recordingslist
This is the API response I'm getting in postman.
{
"from": "2021-06-01",
"to": "2021-06-02",
"page_count": 1,
"page_size": 30,
"total_records": 1,
"next_page_token": "",
"meetings": [
{
"topic": "Meeting Room",
"type": 4,
"start_time": "2021-06-02T10:00:47Z",
"timezone": "Asia/Calcutta",
"duration": 0,
"total_size": 0,
"recording_count": 0,
"recording_files": [
{
"recording_start": "2021-06-02T10:02:39Z",
"recording_end": "2021-06-02T10:05:29Z",
"file_type": "MP4",
"file_extension": "MP4",
"file_size": 3181252,
"status": "completed",
"recording_type": "shared_screen_with_speaker_view"
},
{
"recording_start": "2021-06-02T10:02:39Z",
"recording_end": "2021-06-02T10:05:29Z",
"file_type": "M4A",
"file_extension": "M4A",
"file_size": 2694678,
"status": "completed",
"recording_type": "audio_only"
}
]
}
]
}
I am unable to get all the recordings of the desired time range. The "from" and "to" parameters are not changing even after trying the below query.
https://api.zoom.us/v2//users/me/recordings?from="2020-07-01"&to="2021-06-01"
In postman use this API
https://api.zoom.us/v2/users/{{user id}}/recordings?from=2022-01-01&meeting_id={{meeting id}}
Thanks to #ajaidanial

BigCommerce customer attributes from client/store

Can I retrieve the customer's
There is a current-customer API - https://developer.bigcommerce.com/api-docs/customers/current-customer-api, but it only returns the following bits about a customer.
"customer": {
"id": 4927,
"email": "john.doe#gmail.com",
"group_id": "6"
}
I'd really to have the ability to get all the data from
https://developer.bigcommerce.com/api-reference/customer-subscribers/v3-customers-api/customer-attributes/customersattributesget as a property of the payload for current-customer-api
/customer/current.jwt?app_client_id={appClientId}&attribute-ids:in=1,2,3
"customer": {
"id": 4927,
"email": "john.doe#gmail.com",
"group_id": "6"
"attributes": [
{
"id": 1,
"name": "Age",
"type": "string",
"date_created": "2018-11-13T21:42:06Z",
"date_modified": "2018-11-14T16:46:23Z"
},
{
"id": 2,
"name": "Shoe Size",
"type": "number",
"date_created": "2018-11-14T16:34:57Z",
"date_modified": "2018-11-14T16:34:57Z"
},
{
"id": 3,
"name": "Date Joined",
"type": "date",
"date_created": "2019-02-19T19:13:21Z",
"date_modified": "2019-02-19T19:13:21Z"
}
]
}
This is an interesting feature request. The purpose of the current customer API is to verify the identity of a logged in customer in a secure way, which is why the payload is so minimal (with the understanding that you would likely be making a request for the full customer record based on the id returned).
We are planning to surface customer attribute data on the storefront though, which sounds like it would solve for your use case. We'll be adding Handlebars support soon, and we've got a storefront GraphQL API in the works as well. You can read more in our blog post here:
https://medium.com/bigcommerce-developer-blog/customize-and-extend-your-customer-data-with-the-new-bigcommerce-v3-customers-api-8609903e102a

Zoho Inventory API json

When I run a test GET call in postman I get back the following json
"code": 0,
"message": "success",
"packages": [
{
"package_id": "1041677000009727045",
"salesorder_id": "1041677000009727003",
"shipment_id": "",
"customer_id": "1041677000007872931",
"customer_name": "TEST",
"status": "not_shipped",
"package_number": "PKG-00005",
"tracking_number": "",
"is_tracking_enabled": false,
"shipping_charge": 0,
"date": "2019-02-26",
"quantity": 1,
"salesorder_number": "SO-00023",
"created_time": "2019-02-26T16:13:11-0500",
"delivery_method": "",
"last_modified_time": "2019-02-26T16:13:11-0500",
"shipment_date": "",
"is_carrier_shipment": false,
"associated_packages_count": 0
},
],
"page_context": {
"page": 1,
"per_page": 200,
"has_more_page": false,
"report_name": "zom.common.Packages",
"applied_filter": "Status.All",
"custom_fields": [],
"sort_column": "created_time",
"sort_order": "D"
}
}
My issue is that the API request does not show line_items as shown in the documentation (https://www.zoho.com/inventory/api/v1/#Packages).
Does anyone know if the line_items exist but it just can't be seen as a json (e.g. I can update them but postman just cant view them?)
Had a support ticket in with Zoho but they haven't replied.
Try retrieving one package with the postman version of:
curl https://inventory.zoho.com/api/v1/packages/{package_id}
It should display the line_items per this documentation:
https://www.zoho.com/inventory/api/v1/packages/#retrieving-a-package

How to get the admin/creator of a repository using Github REST API v3

I want to get the details of the person who created the repository using Github API. I got the repositories in my organization using:
https://github.example.com/api/v3/search/repositories?q=org:<name>
I got a list of 30 repositories within the organization with details in the following manner:
{
"total_count": 40,
"incomplete_results": false,
"items": [
{
"id": 3081286,
"node_id": "MDEwOlJlcG9zaXRvcnkzMDgxMjg2",
"name": "Tetris",
"full_name": "dtrupenn/Tetris",
"owner": {
"login": "dtrupenn",
"id": 872147,
"node_id": "MDQ6VXNlcjg3MjE0Nw==",
"avatar_url": "https://secure.gravatar.com/avatar/e7956084e75f239de85d3a31bc172ace?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
"gravatar_id": "",
"url": "https://api.github.com/users/dtrupenn",
"received_events_url": "https://api.github.com/users/dtrupenn/received_events",
"type": "User"
},
"private": false,
"html_url": "https://github.com/dtrupenn/Tetris",
"description": "A C implementation of Tetris using Pennsim through LC4",
"fork": false,
"url": "https://api.github.com/repos/dtrupenn/Tetris",
"created_at": "2012-01-01T00:31:50Z",
"updated_at": "2013-01-05T17:58:47Z",
"pushed_at": "2012-01-01T00:37:02Z",
"homepage": "",
"size": 524,
"stargazers_count": 1,
"watchers_count": 1,
"language": "Assembly",
"forks_count": 0,
"open_issues_count": 0,
"master_branch": "master",
"default_branch": "master",
"score": 10.309712
}
]
}
The problem I have right now is that the owner's id is always the same and it's equal to the organization name. I want the details of the creators. Is there any way I could do that? I tried searching everywhere, but I couldn't find any solution.