Magento Webhook Order Status Update - php

I would like to figure out if I can use webhooks with Magento and AfterShip to update the order status to "Delivered" (new order status to be created) after the package has been marked as delivered from the tracking information.
Aftership has a webhook system they use and Magento seems to be open to integration but I don't know anything on this subject.
I would like to do something like this:
1) Order is marked as "shipped" (default 'complete' status with new label) after order has left our facility
2) AfterShip tracks package and sends emails along the way
3) AfterShip sends email about delivery of package & sends "webhook order status update" to matched Order ID
4) Order Status in Magento is changed/put at "Delivered"
Thanks again to anyone who can offer information or help!

When you input the tracking number in magneto, aftership will get the tracking number from your system every 3 hrs.
This setting and message content is set in AfterShip.com after login.
You need to code a webhook script at your server side, say, using PHP.
When the package is "Delivered", aftership will fire the webhook and post the tracking info to your webhook endpoint. Your webhook script should receive the tracking update (with the order ID).
By using 3, your webhook know which ORDER ID need to be changed to "Delivered"
I hope this is what you want to know.

Related

PayPal API refunds through PayPal plugin on WordPress / WooCommerce

I am currently using the current PayPal plugin https://wordpress.org/plugins/woocommerce-paypal-payments/
I have used the PayPal API to render more than one PayPal button on a page as the above plugin does not allow you to do this.
After the PayPal transaction is approved, it runs a PHP function that creates a WooCommerce order and fills in the data from the PayPal transaction such as the refund ID and setting the correct payment gateway etc. This all goes through great, but when it comes to refunding with the above plugin it fails.
I have compared the CSV files from both the API implementation and standard checkout process and both seem to be bringing in the same data.
I have done a bit of research and it seems that if an order is placed through checkout with the plugin, it creates its own order id, which may link back to the correct refund ID from the transaction. I have contacted their plugin support, but they have been unable to tell me.
Any help on this issue would be greatly appreciated!
When that plugin creates an order, an invoice_id and custom_id are set on these lines in the code.
The invoice ID is later used when doing a refund.
If you backtrack through that code doing the refund, it first makes use of a GET API call to the PayPal Order endpoint, which happens within here.
I highlight the particular line where this GET call depends on some meta information with the PayPal Gateway Order ID.
As an aside, this refund process is not well implemented by this WooCommerce plugin. Refunds are ultimately done using a capture ID, and should not rely on the Orders endpoint being accessible to provide a GET response that includes that capture ID. It works well enough so long as the PayPal Orders endpoint retains a record of that Order ID (which is not forever, as it's not an accounting value), but this is wrong to rely on. Instead, the Capture ID (eq. to the PayPal transaction ID) is what should be stored at transaction completion/capture time (as meta), and that stored meta value can then later be directly used to use the v2/payments refund, with no GET API request to the Orders API endpoint. The Orders API endpoint is only meant to be used during checkout approval, it is incorrect to be relying on it for anything once an order capture is successfully completed.

Change the Status of a Sales Order in ExactOnline

We currently need to set the status of orders to CANCEL in ExactOnline through the API when they are cancelled in our shop.
I got through the ExactOnline API documentation and in the PUT request of salesOrders, I did not find any Status field that I can update but this field exists when this is a GET request. https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=SalesOrderSalesOrders
My PUT request would have this body as status 45 = Cancelled.
{
"Status": 45
}
Which currently returns "204 No Content" (which is normal) BUT the status is not updated.
What would be the workaround then?
Thanks.
Have you tried using the PHP API client? https://github.com/picqer/exact-php-client if your API request is malformed, this might be an easier way to do it.
After some inquiry and discussions with ExactOnline team, updating the status of sales related things through API is not feasible.

Workflow Confusion: PayPal Cordova Plugin / Magento

I am a little bit confused by the Cordova plugin by PayPal in terms of what this means for implementing a safe workflow for interacting with a Magento instance.
Normally, the Express Checkout workflow looks like this:
Customer visits Magento Site checkout
Customer is directed to PayPal
Customer is returned to Magento Site
Customer clicks 'Place Order' on Magento Site
Magento Site converts quote to order
Magento Site accesses PayPal to capture / confirm funds, check for possible fraud, etc...
The workflow imposed by the Cordova plugin appears to be like this:
Customer visits App checkout
Customer is directed to PayPal
Payment is authorized or captured based upon the configuration
Customer is directed back to App
App executes a success handler
In the above Cordova Plugin workflow, notice that the step where a quote to order conversion is missing. From my perspective, I see two options:
Insert quote -> order conversion call between 2 and 3
Caveats:
The customer may not complete checkout and now an order is permanently orphaned in the system
The customer may wish to change something (which now can't happen -- orders can't be modified)
Insert quote -> order conversion call after 5
Caveats:
The client is being trusted to notify the server that the payment was made (which requires server-side cross-examination with PayPal / additional complexity)
The client may never actually send the notification.
I do not like any of the options presented above. Can anyone help clear up my confusion or show me what I hope that I'm missing?
I've found that I am able to provide a placeholder invoice number to the Cordova application to pass on to PayPal.
PayPal can then send this invoice number along with relevant transaction details to the Magento server via an IPN. This takes the client out of the picture and fits my needs.
So really the workflow is as follows:
The client clicks on the 'PayPal Button'
A request is sent to the Magento Server to create an order and placeholder invoice
The Magento Server provides the placeholder invoice number to the client
The order is now 'Pending Payment' in Magento
The client proceeds to PayPal to make the payment
If the client successfully pays, an IPN is sent to the Magento Server and the client is returned to the App payment success page
If the client fails to pay and fails to return to the app, the order will remain as 'Payment Pending' to be cancelled by a crontask every so often
If the client fails to pay and successfully returns to the app, the app will contact the Magento Server and immediately cancel the order
I'm severely disappointed by the lack of documentation / support for this product.

Send Order ID to Authorize.net Instead of Transaction ID in Magento

I'm using the authorize.net module in Magento 1.7 to process credit card transactions. Right now, the transaction ID is sent, not the order number. Is there any way to send the Order number instead?
Would I change ->setLastTransId($response->getTransactionId()) to getOrderID on line 1367 of app/code/core/Mage/Paygate/Model/Authorize.net?
Of course, I wouldn't change the core files, I'd copy it to local first.
It looks like currently the Authorize.Net payment method in Magento Community Edition 1.7 sends the order increment Id number (What is typically considered the order number) to the Authorize.Net gateway in the XInvoiceNum field. See lines 1154 to 1156 in app/code/core/Mage/Paygate/Model/Authorizenet.php:
if ($order && $order->getIncrementId()) {
$request->setXInvoiceNum($order->getIncrementId());
}
One possible way to get more order information into Authorize.Net from Magento is to use Authorize.Net's CIM (Customer Information Manager) version of the gateway, along with a Magento payment method such as ours:
http://www.storefrontconsulting.com/authorize-net-cim-saved-credit-cards-extension-for-magento/

How do I identify orders with the Google Checkout Notification API (using PHP)?

I am using the Google Checkout API to code a simple store. I have gotten as far as letting the user select items, edit the cart, and checkout/pay with Google Checkout. The notification API (with XML) is being used to read notifications sent by Google after receiving orders. How can I connect the order notifications with the orders information in my SQL database? Can I send an "order ID" or something like that to Google with the initial order? I have coded that portion (ordering) with the HTML API.
Thanks in advance!
When an order is placed, a notification is made giving you a serial number for the order. You need to store this serial number in your database against whatever internal order number you have, so that you can use the serial number to refer to the order with Google Checkout via the Notification API.
No. Notification and Polling are two separate concepts.
Notification is when Google Checkout sends you info as it occurs, and Polling is when you send a request for sale details at some time in the future.
Documentation for Polling is lacking on-line. That is why you - and I - have not found the answer.
Google sends an e-mail when a sale is made (or when something goes wrong with a payment), and it stores some detail in your dashboard. You can use the date or the number to Poll for the rest of the details. Exactly how to do that is lacking in the on-line documentation.
Use the merchant-private-data field to pass any custom data about your order.
When you get back the notification, read the custom info from the merchant-private-data field.
See this answer for a solution to a similar issue.

Categories