Everything is fine in the PayPal sandbox but in the live environment, there is an issue with transactions.
My js :
<script src="https://www.paypal.com/sdk/js?client-id=key¤cy=GBP"></script>
createOrder: (data, actions) => {
console.log("create order");
return actions.order.create({
purchase_units: [{
amount: {
value: 10.00
}
}]
});
},
onApprove: (data, actions) => {
console.log("on approve");
return actions.order.capture().then(function(orderData) {
const transaction = orderData.purchase_units[0].payments.captures[0];
alert(${transaction.status}: ${transaction.id});
});
}
}).render('#paypal-button-container');
This is my API response issue:
"payments": {
"captures": [
{
"amount": {
"currency_code": "GBP",
"value": "1.00"
},
"seller_protection": {
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
],
"status": "ELIGIBLE"
},
"status": "PENDING",
"status_details": {
"reason": "PENDING_REVIEW"
}
}
]
},
the amount is received. but it's going to hold because of this status pending. but the PayPal team provides this as the solution " As for pending payments that would be a setting on your shopping cart, the setting would need to be set as 'sale' instead of 'Authorisation' " how do set this?
the setting would need to be set as 'sale' instead of 'Authorisation' "
This is not your issue, this is already a capture. The reason it is pending is given as "pending review", which basically means what it says. PayPal will review and either approve or deny the transaction, usually within 24 hours.
Related
I have a Paypal generated smart button that I want to amend so that vat is broken down correctly on the paypal receipt.
I've read the paypal pages that say it cant be done in the paypal interface but have to be called through on the api.
The code I current have is...
<div id="paypal-button-container"></div>
<script src="https://www.paypal.com/sdk/js?client-id=xxxzzz¤cy=GBP" data-sdk-integration-source="button-factory"></script>
<script>
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
description: "my amazing rocketpack",
amount: {
value: '2.99'
}
}]
});
}, onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Shop transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
Looking at the paypal docs for purchase units it suggests I need to turn on amount.breakdown and specify item_total and tax_total.
But I cant seem to get it right (it either breaks the button so it doesn't display at all or the receipt is still just gross amount) and can find no examples of the code
Solved, in case anyone else wants to know, the below is how you initiate amount.breakdown (there is no dot)
purchase_units: [{
description: "my item",
amount: {
value: '29.99',
currency_code: 'GBP',
breakdown: {
item_total: {
currency_code: 'GBP',
value: '24.99'
},
tax_total: {
currency_code: 'GBP',
value: '5.00'
},
}
}
}]
I have integrated the PayPal smart buttons into my JavaScript shopping cart. I am trying to allow PayPal to tell the user the items they had in the cart at checkout. For example;
I know that to do this I need to use the following code:
<script>
paypal.Buttons({
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": [{
"description": "Stuff",
"amount": {
"value": "20.00",
"currency_code": "USD",
"breakdown": {
"item_total": {
"currency_code": "USD",
"value": "20.00"
},
}
},
"items": [
{
"unit_amount": {
"currency_code": "USD",
"value": "10.00"
},
"quantity": "1",
"name": "Item 1",
},
{
"unit_amount": {
"currency_code": "USD",
"value": "10.00"
},
"quantity": "1",
"name": "Item 2",
},
],
}
]
});
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer.
window.location.href = "orderConfirmed.php"
clearCart()
});
}
}).render('#paypal-button-container');
//This function displays Smart Payment Buttons on your web page.
</script>
In this example, there are 2 items in the dropdown tab: Item 1 and Item 2 but I need these to represent what the user has in their cart. I got an answer on her than said I needed to create amn array that held the cart item name, price and quantity.
I came up with this code, what I am trying to do is for every item in the cart, I want to return the product name, product price and product quantity. I came up with the code below:
function arrayOfItems() {
cart.forEach((cartItem, index) => {
let currency = cartItem.price;
let quantity = cartItem.quantity;
let itemName = cartItem.name;
let items = [{"unit_amount": {"currency_code": "USD","value": currency},"quantity": quantity,"name": itemName,}];
return items;
});
}
But when I run the new PayPal script like so:
<script src="cart.js"></script>
<script>
paypal.Buttons({
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: countCartTotal()
},
items: [
{
arrayOfItems()
},
],
}
]
});
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer.
window.location.href = "orderConfirmed.php"
clearCart()
});
}
}).render('#paypal-button-container');
//This function displays Smart Payment Buttons on your web page.
</script>
The PayPal buttons stop working!
Update
After making the changes the code now looks like this:
<script>
paypal.Buttons({
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": countCartTotal(),
"currency_code": "USD",
"breakdown": {
"item_total": {
"currency_code": "USD",
"value": countCartTotal()
},
},
"items": arrayOfItems()
}
]
});
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer.
window.location.href = "orderConfirmed.php"
clearCart()
});
}
}).render('#paypal-button-container');
//This function displays Smart Payment Buttons on your web page.
</script>
And is not producing any errors in my IDE, however when I run the code the JavaScript Console gives me this error:
You don't seem to be including the required breakdown. This may seem redundant, but it is required to have a breakdown section.
"breakdown": {
"item_total": {
"value": countCartTotal()
},
}
Also it looks like you are generating an items array, so you need to use it like so:
amount: {
value: countCartTotal()
},
items: arrayOfItems(),
All of the currency_code fields also seem to be required, and not optional when passing line item information, so you will need to add those back in.
That's three issues you need to fix.
If you still need help, post a runtime example of what everything is evaluating to, i.e. the output of the functions so we can tell you what's wrong
I'm using facebook Graph API to retrieve action values from campaigns. But the JSON returned is always different from any values from facebook screen.
My Request from JavaScript
var d = new FormData();
d.append("access_token", "MY_ADS_INSIGHTS_TOKEN");
d.append("fields", "actions");
d.append("date_preset", "lifetime"); // I want lifetime data
return await (await fetch("https://graph.facebook.com/v3.1/" + campaignid + "/insights", {
method: "post",
body: d
})).json();
and after I access the report insights using the URL:
https://graph.facebook.com/v3.1/REPORT_RUN_ID/insights?access_token=MY_ADS_INSIGHTS_TOKEN
JSON returned after access report task
{
"data": [
{
"actions": [
{
"action_type": "comment",
"value": "2"
},
{
"action_type": "like",
"value": "4"
},
{
"action_type": "photo_view",
"value": "30"
},
{
"action_type": "post",
"value": "1"
},
{
"action_type": "link_click",
"value": "7"
},
{
"action_type": "page_engagement",
"value": "249"
},
{
"action_type": "post_engagement",
"value": "245"
},
{
"action_type": "post_reaction",
"value": "205"
}
],
"date_start": "2018-07-09",
"date_stop": "2018-07-15",
"ad_id": null // removed
}
],
"paging": {
"cursors": {
"before": "MAZDZD",
"after": "MAZDZD"
}
},
"__fb_trace_id__": null // removed
}
Facebook Post Results
I want to know:
Why Facebook Graph API return the post_reaction as 205 since from facebook view it is 160 or 150? the value doesn't match anything, happens to action like too
Notes:
I'm not using any SDK, but this isn't the problem.
The Ad has only ONE ads group and the group has only ONE campaign
I make the requisition at the same time as I see the post. There are no major interactions in this post, it is old enough that the values do not change.
I known that Facebook cache anything, but this Ad is from 10, July.
Ad Campaign Insights reference: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group/insights/
I accept answers using SDKs or different programming languages like C#, php or Java as example, I want only know HOW make the right request or what is exactly happening.
I am new to angular and trying to develop an application having nested
ng-repeat and after submitting the form it should hit the rest api.
I have been using $http to make rest api calls. The code gets submitted
with normal data but does not get submitted with nested ng-repeat when i
click the save button. Below I have provided the code with details.
The whole data should be shown in the console. I might have made some
mistake somewhere.Thanks in advance.
JS
$scope.saveVenFormData = function(vendet){
console.log($scope.vendet);
$scope.venFullAddress.push({
'vendorName': $scope.name,
'panNum': $scope.panNum,
'personName': $scope.venBusDetails.personName,
'mobileNum': $scope.venBusDetails.mobileNum,
'workNum': $scope.workNum,
'emailid': $scope.emailid,
'addressLine1': $scope.addressLine1,
'addressLine2': $scope.addressLine2,
'city': $scope.city,
'state': $scope.state
});
var dataObj = $scope.venFullAddress;
// console.log($scope.dataObj);
$http.get('/showVendors').success(function(data){
console.log(angular.toJson(data));
});
var res = $http.post('http://localhost:8080/dman/mm', dataObj);
res.success(function(data, status, headers, config) {
$scope.message = data;
});
res.error(function(data, status, headers, config) {
alert( "failure message: " + JSON.stringify({data: data}));
});
};
JSON structure:
{
"vendor": {
"vendorName": "",
"panNum": "",
"venBusDetails": [{
"personName": "",
"mobileNum": "",
"workNum": "",
"emailid": "",
"venContDetails": [{
"addressLine1": "",
"addressLine2": "",
"city": "",
"state": ""
}]
}]
}
}
https://plnkr.co/edit/nP8R92KNkz8JEHpvH56S?p=catalogue
For convenience I have added a json structure. I need to access all the
data from the form and hit the rest api.
The above is the link to the plunker. Thank you.
Try this
$scope.dataObjToPost = {
"vendor": {
"vendorName": $scope.vendet.vendorName,
"panNum": $scope.vendet.panNum,
"venBusDetails": [{
"personName": $scope.venBusDetails[0].personName,
"mobileNum": $scope.venBusDetails[0].mobileNum,
"workNum": $scope.venBusDetails[0].workNum,
"emailid": $scope.venBusDetails[0].emailid,
"venContDetails": [{
"addressLine1": $scope.venContDetails[0].addressLine1,
"addressLine2": $scope.venContDetails[0].addressLine2,
"city": $scope.venContDetails[0].city,
"state": $scope.venContDetails[0].state
}]
}]
}
} //And send this data to POST method
You used $scope.name in JS file but in HTML view you used ng-model="vendet.vendorName". Thats why it is always undefined.
UPDATED ANSWER Plunk LINK IS HERE
Is there way to implement data validation programmatically using Office.js API ?
While you can absolutely implement your own data validation within an add-in, it would be distinct from the built-in data validation tool. There is currently no API for configuring Excel's data validation tool programmatically.
Here I have try to add data validation on excel cell within range.
Excel.run(function (context) {
var currentWorksheet = context.workbook.worksheets.getActiveWorksheet();
var expensesTable = currentWorksheet.tables.add("A1:D1", true /*hasHeaders*/);
expensesTable.name = "ExpensesTable";
expensesTable.getHeaderRowRange().values = [["Date", "Merchant", "Category", "Amount"]];
expensesTable.rows.add(null /*add at the end*/, [
["1/1/2017", "The Phone Company", "Communications", "120"],
["1/2/2017", "Northwind Electric Cars", "Transportation", "142.33"],
["1/5/2017", "Best For You Organics Company", "Groceries", "27.9"],
["1/10/2017", "Coho Vineyard", "Restaurant", "33"],
["1/11/2017", "Bellows College", "Education", "350.1"],
["1/15/2017", "Trey Research", "Other", "135"],
["1/15/2017", "Best For You Organics Company", "Groceries", "97.88"]
]);
var range = currentWorksheet.getRange("C2:C200");
range.dataValidation.clear();
range.dataValidation.rule = {
list: {
inCellDropDown: true,
source: "Groceries, Education, Other,Transportation",
autofitColumns: true
}
};
//range.dataValidation.errorAlert = {
// message: "Sorry, only positive numbers are allowed",
// showAlert: true,
// style: "Stop",
// title: "Negative Number Entered"
//};
list.find();
return context.sync();
}).catch(function (error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});