I am following this tutorial to process cart / checkout for placing orders using graphql. Magento GraphQl Tutorial. And we have installed stripe on magento(backend).
So we are facing issue while placing order, we have done few steps upto point 5.
Customer logs in get a authentication token
Create empty cart
Add product to cart
Set billing and shipping address for cart
Set payment method to stripe_payments (without card details)
How to set payment information and where to set ?
Placing order receiving error here
How can I set payment method and debit card details to cart using graphql and place an successful test order?
Make sure all steps ( 1 to 5 ) have been done without any issue. Please check the below steps for the mutation by which you can set the payment method and place the order.
Example: Use the setPaymentMethodOnCart mutation to set the payment method for your order. The value checkmo ("Check / Money order" payment method code) was returned in the query.
mutation {
setPaymentMethodOnCart(input: {
cart_id: "{ CART_ID }"
payment_method: {
code: "checkmo"
}
}) {
cart {
selected_payment_method {
code
}
}
}
}
Response:
If the operation is successful, the response contains the code of the selected payment method.
{
"data": {
"setPaymentMethodOnCart": {
"cart": {
"selected_payment_method": {
"code": "checkmo"
}
}
}
}
}
Set payment method and place order
Use the setPaymentMethodAndPlaceOrder mutation to set the payment method and place the order.
Request:
mutation {
setPaymentMethodAndPlaceOrder(input: {
cart_id: "{ CART_ID }"
payment_method: {
code: "checkmo"
}
}) {
order {
order_id
}
}
}
Response:
If the operation is successful, the response contains the order ID.
{
"data": {
"setPaymentMethodAndPlaceOrder": {
"order": {
"order_id": "000000001"
}
}
}
}
Note: Make sure "setPaymentMethodAndPlaceOrder mutation" is not deprecated in the current version of Magento 2.
First check the available payment method ( added from magneto dashboard only)
Then set that payment method and post the query
https://devdocs.magento.com/guides/v2.4/graphql/tutorials/checkout/checkout-payment-method.html
Related
I have a user(in Austria) who sent images of his account with the cloud being enabled, etc. However, when I did a request against his account, I couldn’t see any data -- its similar to what my US account showed.
For example, during this time period, he showed a run:
{"group":[ { "startTime":1611288803278, "endTime":1611893603278, "sampleSet":[ { "dataCollectorId":"derived:com.huawei.continuous.steps.delta:com.huawei.hwid:merged", "samplePoints":[ ] } ] }, { "startTime":1611288803278, "endTime":1611893603278, "sampleSet":[ { "dataCollectorId":"derived:com.huawei.continuous.distance.delta:com.huawei.hwid:merged", "samplePoints":[] } ] }, { "startTime":1611288803278, "endTime":1611893603278, "sampleSet":[ { "dataCollectorId":"derived:com.huawei.continuous.calories.burnt:com.huawei.hwid:merged", "samplePoints":[] } ] }, { "startTime":1611288803278, "endTime":1611893603278, "sampleSet":[ { "dataCollectorId":"derived:com.huawei.instantaneous.heart_rate:com.huawei.hwid:merged", "samplePoints":[] } ] } ] }
HTTP response header showed “HTTP/1.1 200 OK”and the value of the x-health-app-privacy field is 2.
Could you give any info for x-health-app-privacy?
Is Austria (Europe) a supported region? If so, is there any reason why I could not read the data from his account?
the value of the x-health-app-privacy field in the HTTP response header is 2, which means that the user did not authorize the Health Kit to get data in the Sports Health App. Please refer to the below screenshots for users how to enable authorization.
for x-health-app-privacy, pls refer to below. https://developer.huawei.com/consumer/en/doc/development/HMSCore-References-V5/latest- sampleset-0000001078273166-V5
ParameterTypeMandatory (M)/Optional (O)Description
I'm using the Payouts API and to do so I have to specify an access token when calling https://api-m.sandbox.paypal.com/v1/payments/payouts
To get an access token, as specified here I have to send a POST request with Postman to https://developer.paypal.com/docs/api/overview/#get-an-access-token and it returns in the response the token
My problem is that this token has an expiration time, which is an issue because I can't go in my app every 15 minutes to change the token in the Authorization header. How can I get a "permanent" or rather an "auto refreshed" token ?
I tried to make a call from my app instead of Postman but it doesn't seem to work, it says my credentials are invalid
This is my code in case it can be useful (I'm managing everything from the front-end):
window.paypal
.Buttons({
createOrder: (data, actions) => {
return actions.order.create({
purchase_units: [
{
description: this.product.description,
amount: {
value: this.product.price
}
}
]
});
},
onApprove: (data, actions) => {
const timestamp = new Date().getUTCMilliseconds();
const id = timestamp;
return actions.order.capture().then(details => {
axios
.post(
"https://api-m.sandbox.paypal.com/v1/payments/payouts",
{
sender_batch_header: {
sender_batch_id: id,
email_subject: "You have a payout!",
email_message:
"You have received a payout! Thanks for using our service!",
recipient_type: "EMAIL"
},
items: [
{
amount: {
value: this.product.price,
currency: "USD"
},
note: "congrats someone bought your stuff",
sender_item_id: id,
receiver: "john#doe.com"
}
]
},
{
headers: {
Authorization:
"Bearer <my token that I get from postman>"
}
}
)
.then(() => {
alert(
"Transaction completed by " + details.payer.name.given_name
);
})
.catch(err => console.log(err));
});
}
})
.render(".paypal");
}
},
Update
Reading the code a second time and noticing how your Payout is for the same this.product.price as the original payment, that makes no sense. Don't use payouts at all for this use case. The full amount will go to your account normally, but if you want the full amount to go somewhere else instead, set the payee variable for this checkout: https://developer.paypal.com/docs/checkout/integration-features/pay-another-account/
(original answer below)
Using Payouts from the client side is an absolutely terrible idea, anyone with your client credentials will be able to send money from your account to wherever they want
The payouts API must be used from your server only. Your server needs to do an API call to get an access token, similar to what you mention about postman -- except using whatever backend environment you have. You can integrate direct HTTPS calls, or there are also Payouts SDKs available which will handle getting the access token automatically.
As for how to trigger that backend action when capturing a payment, use a proper server integration:
Create two routes, one for 'Create Order' and one for 'Capture Order', documented here. These routes should return JSON data. Before returning JSON data, that last route (the capture one) should record the successful transaction in your database and trigger any Payout logic you want.
Pair those two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
I am currently implementing paypal Checkout as per https://developer.paypal.com/docs/checkout/integrate/#
I can send payments etc no problem. However, how can I identify who made the payment?
createOrder: function(data, actions) {
// This function sets up the details of the transaction, including the amount and line item details.
return actions.order.create({
purchase_units: [{
amount: {
value: '1.0'
}
}]
});
}
.create does not allow me to append a order id or user id. In the paypal dashboard I can only see the name and the amount .
In you onApprove function, inside actions.order.capture(:
console.log(data);
The information will be there for you.
You can see an example of it used for an alter in the demo here: https://developer.paypal.com/demo/checkout/#/pattern/client
I have express checkout working with the latest checkout.js but do not need to show any shipping address. Since it's a digital good, the docs say I need noshipping set to 1. However, I can't figure out how that goes into the javascript.
I followed the basic integration steps and then used the REST API to execute the payment so I can charge to my server.
I've tried adding noshipping:1 all over the place within the javascript to create the payment with no luck. Here's what it looks like ( ignore compile issues as I'm just trying to show how I tried adding the noshipping:1 information):
payment: function() {
var env = this.props.env;
var client = this.props.client;
return paypal.rest.payment.create(env, client, {
transactions: [
{
amount: { total: '4.99', currency: 'USD' }
DOESNT WORK-->noshipping: 1
}
],
DOESNT WORK-->noshipping: 1
});
},
Does anyone know how to properly pass the noshipping information using the latest checkout.js?
OK, it appears that they have finally added support for this. It looks like this:
payment: {
transactions: [
{
amount: { total: '19.99', currency: 'USD' }
// Possibly there is also a 'custom' field we can specify here;
// https://stackoverflow.com/questions/46320753/
}
],
application_context: {
shipping_preference: 'NO_SHIPPING'
}
}
Got an "official" response from paypal support a week later:
Thank you for contacting PayPal Merchant Technical Services.
Unfortunately we do not have an option for the noshipping when using
REST API. That option is only available on the classic express
checkout which uses the NVP/SOAP API.
There it is. This fairly simple concept isn't possible with their latest SDK.
Yes, there's a way to specify NOSHIPPING as follows on PayPal-Python-SDK, as per your code:
payment: function() {
var env = this.props.env;
var client = this.props.client;
return paypal.rest.payment.create(env, client, {
transactions: [
{
amount: { total: '4.99', currency: 'USD' }
}
],
application_context: {
shipping_preferences: 'NO_SHIPPING',
}
});
},
I hope it helps.
I've added a custom field for 'interested parties' (users) in a particular issue, not project specific, and it works fine.
I would like YouTrack to generate emails to their email address on update or change of the issue, like they do to the person who it is assigned to, is this possible?
Let's say you want to send notifications by e-mail when a ticket is ready to be reviewed. People responsible for the review are set via a Reviewer custom field (which can contain multiple values). Then you can send notifications as follows:
var entities = require('#jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.stateMachine({
title: 'Workflow',
fieldName: 'State',
states: {
'To Be Reviewed': {
onEnter: function(ctx) {
var issue = ctx.issue;
issue.fields.Reviewer.forEach(function(user) {
user.notify("Reminder", "This is a reminder", true);
});
},
transitions: {}
},
},
requirements: {
Reviewer: {
type: entities.User.fieldType,
multi: true
}
}
});
You can create a custom workflow like the following one:
when {
if (Interested Parties.isNotEmpty) {
for each user in Interested Parties {
user.notify("subj", "body");
}
}
}
Another point is that you probably do not need this field since you can 'star' an issue on behalf of a user and the user thus will be notified about any changes. Just type star user_name in the command window.