(I'm a first time poster, so please forgive my lack of proper formatting, and if this question has already been answered in some form or fashion)
Issue: Shopify API - Partial Refund On Order Through Creation of A New Transaction(opposed to simply cancelling the order)
Reason: Give customer partial refund without cancelling the order
Problem: The Query Crashes at the point of sending the 'Create Transaction' into the shopify api, no errors, try and catch are not initiated, and the code after the query to shopify is ignored as well.
Shopify Developer API XML/JSON for Transactions:
http://api.shopify.com/transactions.html
Currently using Sandeepsheety's PHP API Code:
https://github.com/sandeepshetty/shopify.php/blob/master/README.md
<?php
//-------------------------------------------------------------------------------
//PHP Code Begins
//NOTE: [Does return correct values for the Order through GET through id=135264996 and,
// transaction GET data is verified as well - Test Order Total = $94.50 and,
// tested a few other orders ids with the same result.]
//-------------------------------------------------------------------------------
//Does connect and I have verified with a few GETS and even a couple cancellations
$shopify = shopify_api_client($SHOPIFY_STORE_URL, NULL, $SHOPIFY_API_KEY, $SHOPIFY_TOKEN, true);
//Based on Create Transactions: (POST /admin/orders/#{id}/transactions.json)
$jsonURL= "/admin/orders/135264996/transactions.json";
$query = $shopify('POST', $jsonURL, array('kind'='refund', 'amount'=10));
//NOTHING HAPPENS and Code Stops HERE
echo "Passed"; //IGNORED
?>
The Transaction API only supports 'capture' as the kind. The server is returning a 403 Forbidden, with text "Only capturing is currently supported".
shopify.php must not be handling that error properly but that is the issue you're running into.
Related
I am currently facing a strange behaviour on shopware 6.
What I need is to get order's documents informations when the order is refunded (invoice number & creditNote number).
Here is how I am getting the documentEntity in the orderRepository:
$criteria = new Criteria([$orderId]);
$criteria->addAssociation('lineItems');
$criteria->addAssociation('documents');
$orderObject = $this->orderRepository->search($criteria, $context);
$documents = $orderObject->first()->getDocuments();
Normal behaviour
When the order state is set to "refunded_partially", $documents perfectly contains what it should.
The problem
When the order state is set to "refunded", $documents is empty and I have no errors in logs.
Maybe I overlooked but I saw no differences between the dump I made on $orderObject when it's "refunded" and when it's "refunded_partially".
Does someone have a clue on how to manage this correctly?
AS this one is pretty tricky to do, I recommand you to use a specific event to work with documents. The event is triggered when a document is created for an order (invoice, credit note, etc.)
Example here
I am using the gabrielbull ups api wrapper and it is working fine, except when I want to add an UPS access point; the documentation says I have to declare a "AlternateDeliveryAddress". The access point data should then be printed on the ups label, but they are not appearing.
Since there isn't an example for this case on the wrapper GitHub page, I searched for methods on my own and found one but I have the feeling I forgot something since I don't receive any errors. I tried this code for the specific part. The surrounding code is like in the shipping class example
$address = new \Ups\Entity\Address();
$address->setAddressLine1($ap_addressline1);
$address->setPostalCode($ap_postal);
$address->setCity($ap_city);
$address->setCountryCode($ap_country);
$alternateTo = new \Ups\Entity\AlternateDeliveryAddress;
$alternateTo->setAddress($address);
$alternateTo->setUpsAccessPointId($ap_id);
$alternateTo->setName($ap_name);
$alternateTo->setAttentionName($ap_name);
$shipment->setAlternateDeliveryAddress($alternateTo);
Edit: I got this info of setting up the accesspoint from UPS support. The guy told me to set an alternate address with the AccessPoint data that will be printed at the bottom line of the label (where it's currently missing). If I misunderstood something (though we did a video conference and he showed me the result) and you know another way, feel free to tell me.
Ok after re-reading the official docs I found out what was missing.
If you want to use an accesspoint as address you also have to set the Indication Type via setShipmentIndicationType. There are 2 codes: 01 and 02 depending on the way you want to send it. Ofcourse I didn't add them before...
I haven't finished it yet because I get some errors but that's more about what information ups needs from me and so on. At least I can work with that.
As I mentioned in my initial post I used the example of the api wrapper as base and insert the required part before the request was send:
...
// Set Reference Number
...
// this is the part where you set shipment indication type for the accesspoint
$accesspoint = new \Ups\Entity\ShipmentIndicationType;
$accesspoint->setCode(Ups\Entity\ShipmentIndicationType::CODE_HOLD_FOR_PICKUP_ACCESS_POINT); // for "01"
#$accesspoint->setCode(Ups\Entity\ShipmentIndicationType::CODE_ACCESS_POINT_DELIVERY); // for "02"
$shipment->setShipmentIndicationType($accesspoint);
// Set payment information
...
// Ask for negotiated rates (optional)
...
// Get shipment info
...
I am trying to send a receipt (bill/ expense) as a draft to the Xero, but what ever I try and do, I am getting an error. Basically, I want to upload the receipt( the invoice sent by the supplier), enter the Name of the supplier, Amount to pay, Invoice Number from the supplier and our reference code merged (eg: Inv Num / Ref as 987/ 123), due date, and a small description like 1 dozen blue ball pens.
Can you please guide me how to solve this issue please.
$invoice= new \XeroPHP\Models\Accounting\Receipt();
$xcontact= new \XeroPHP\Models\Accounting\Contact();
$xcontact->setName('Test Contact');
$xcontact->setFirstName('Test');
$xcontact->setLastName('Contact');
$xcontact->setEmailAddress('amo.chohan#gmail.com');
$xcontact->setDefaultCurrency('AUD');
$invoice->setContact($xcontact);
// till the above code, things are working fine but having issues here)
$invoice->setTotal('300.00');
$dateInstance = new DateTime();
$invoice->setDate($dateInstance);
$invoice->setReceiptNumber('987/');
$invoice->setReference('123');
i was trying to send the info but giving me an error as:
Call to undefined method XeroPHP\Models\Accounting\Receipt::setReceiptNumber()
and if comment the setReceiptNumber(); I get the following error as:
XeroPHP\Models\Accounting\Receipt::$LineItems is mandatory and is
either missing or empty.
Not too sure how can I send the Bills to the Xero.
Thanks for your time.
Use sendEmail() function to send email.
$invoice->sendEmail();
I am trying to create Passenger Name Record using Create Passenger Name Record API of Sabre. But When I pass information fetched from BargainFinderMax API to Passenger Name Record API, It gives the following error. It happens in some requests.
Please find below my Request Sample Flight segment part
"OriginDestinationInformation":{
"FlightSegment":[
{
"Status":"NN",
"MarriageGrp":"O",
"FlightNumber":"206",
"NumberInParty":"2",
"OriginLocation":{
"LocationCode":"JFK"
},
"ArrivalDateTime":"2018-09-15T22:10:00",
"MarketingAirline":{
"Code":"EK",
"FlightNumber":"206"
},
"ResBookDesigCode":"U",
"DepartureDateTime":"2018-09-14T22:20:00",
"DestinationLocation":{
"LocationCode":"DXB"
}
},{
"Status":"NN",
"MarriageGrp":"I",
"FlightNumber":"604",
"NumberInParty":"2",
"OriginLocation":{
"LocationCode":"DXB"
},
"ArrivalDateTime":"2018-09-16T05:30:00",
"MarketingAirline":{
"Code":"EK",
"FlightNumber":"604"
},
"ResBookDesigCode":"U",
"DepartureDateTime":"2018-09-16T02:30:00",
"DestinationLocation":{
"LocationCode":"KHI"
}
}
]
}
Below is the response with error that I receive from the API.
{"CreatePassengerNameRecordRS":{"ApplicationResults":{"status":"NotProcessed","Error":[{"type":"BusinessLogic","timeStamp":"2018-09-11T08:45:51.946-05:00","SystemSpecificResults":[{"Message":[{"code":"ERR.SWS.HOST.ERROR_IN_RESPONSE","content":"Unable to perform air booking step"}]}]}],"Warning":[{"type":"Application","timeStamp":"2018-09-11T08:45:51.946-05:00","SystemSpecificResults":[{"Message":[{"code":"WARN.SP.PROVIDER_ERROR","content":"EnhancedAirBookRQ: CODE - UC SEG STATUS NOT ALLOWED-0003"}]}]}]}},"Links":[{"rel":"self","href":"https://api.test.sabre.com/v2.1.0/passenger/records?mode=create"},{"rel":"linkTemplate","href":"https://api.test.sabre.com//passenger/records?mode="}]}
could you please guide me why this happens. please also note that I am sending this request from PHP using CURL. In some cases booking is successfully completed.
Thanks in advance.
This is normal, but the rate of getting is UC code should be less than 10%.
Possible reasons could be
Your PCC is blocked. Which is not the case with you because you are not getting this code on all requests.
The airline when you are booking becomes unavailable or the seat is taken before you confirm your PNR
The issue also comes in some coshare flights where partnered airlines have some issues
This is normal behavior and depends on the flights you use, at the moment of booking them they may not be available anymore. cURL and PHP do not affect this in any way. Are you obtaining this flight combination from BFM or an availability request?
As this workflow is notorious unstable, i recommend you using the SOAP Enhanced Airbook + Passenger Details. I have not heared of anybody that is using create PNR in production yet.
OK, I've been banging my head against this for a few days now. I'm building a payment process into a PHP application which will allow for upselling products after a customer approves a payment.
I can get the payment charged to the customer without an issue, but if they select any kind of upsell product which requires the order value to change, then I get errors even though it is following to the letter what was in the documentation I could find...
Below is the test function I'm using, this is the function which is called when the user is redirected back to the website AFTER approving the payment.
public function confirmOrder($payer_id, $payment_id, $incentives = false){
//GET PAYMENT
$payment = Payment::get($payment_id, $this->apiContext);
//CREATE EXECUTION WITH PAYER ID
$execution = new PaymentExecution();
$execution->setPayerId($payer_id);
//APPLY PAYMENT AMOUNT - Original amount was 7.00
$amount = new Amount();
$amount = $amount->setCurrency('GBP')->setTotal('8.00');
//PATCH REPLACE
$patchReplace = new Patch();
$patchReplace = $patchReplace->setOp('replace')->setPath('/transactions/0/amount')->setValue($amount);
//CREATE PATCH OBJECT
$patchRequest = new PatchRequest();
$patchRequest = $patchRequest->setPatches(array($patchReplace));
try {
$payment->update($patchRequest, $this->apiContext);
} catch (PayPalConnectionException $ex) {
return "PATCH ERROR: State(" . $payment->getState() . ") ".$ex->getData();
}
}
This isn't the final code I will use but right now I'm just trying to get an order updated before I build in more of the logic. This code gives me the following error:
PATCH ERROR: State(created) {"name":"PAYMENT_STATE_INVALID","message":"This request is invalid due to the current state of the payment","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#PAYMENT_STATE_INVALID","debug_id":"9caacdc1d652b"}
You can see I'm outputting the getState() which is coming back as 'created' which would normally be fine for updating in everything I can find but it is still failing.
Does anyone else have experience with the PayPal PHP SDK and could help point me in the right direction?
In PayPal, once the user has approved the payment from the consent screen, the amount cannot be changed, as you can understand the user agreed to pay only the amount he/she saw on the consent screen. Modifying the amount after user approves it, is not allowed, and that's why you are seeing that state exception, as the state is already approved.
Anyway, looking at your scenario, I think you might be interested in either creating order, or capture, instead of sale.
Also, in our PayPal-PHP-SDK, there are a lot of interesting documents that could help you understand PHP-SDK better. We also provide a lot of runnable samples, that you could setup in your local machine, by one command only.