I'm integrating paypal in our shopping system.
I'm using the Java Api.
In the current form the process is the following:
The user chooses paypal as payment and clicks on "Pay Order"
The Server sends a an createOrder Request with Capture Intent.
The Server receives a response with links.
The user is redirected to the "approve" link.
After finishing paypal redirects the user to the shop page with the "thanks for your order message".
All this is working as expected.
But no payment is done / no money transfered.
What am I doing wrong here?
Thanks in advance!
For reference the request/response:
Request: {}, {
"application_context" : {
"user_action" : "PAY_NOW",
"landing_page" : "BILLING",
"return_url" : "https://www.foobar.de.localhost:8443/payment/paypal?result=ok&order_id=MGS063464&secret=2E1C1B304178...",
"brand_name" : "<removed>",
"cancel_url" : "https://www.foobar.de.localhost:8443/payment/paypal?result=cancel&order_id=MGS063464",
"shipping_preference" : "SET_PROVIDED_ADDRESS"
},
"purchase_units" : [ {
"amount" : {
"breakdown" : {
"shipping" : {
"value" : "3",
"currency_code" : "EUR"
},
"item_total" : {
"value" : "2.45",
"currency_code" : "EUR"
}
},
"value" : "5.45",
"currency_code" : "EUR"
},
"reference_id" : "MGS063464",
"shipping" : {
"address" : {
"country_code" : "DE",
"address_line_1" : "<removed>",
"admin_area_2" : "<removed>",
"postal_code" : "<removed>"
},
"name" : {
"full_name" : "<removed>"
}
},
"description" : "<removed>,
"items" : [ {
"quantity" : "1",
"name" : "<removed>",
"unit_amount" : {
"value" : "2.45",
"currency_code" : "EUR"
},
"sku" : "OCI08"
} ]
} ],
"intent" : "CAPTURE"
}
Response: {}, {
"create_time" : "2021-03-14T10:52:46Z",
"purchase_units" : [ {
"payee" : {
"email_address" : "<removed>",
"merchant_id" : "L4EC8HB5DTVSC"
},
"amount" : {
"breakdown" : {
"shipping" : {
"value" : "3.00",
"currency_code" : "EUR"
},
"item_total" : {
"value" : "2.45",
"currency_code" : "EUR"
}
},
"value" : "5.45",
"currency_code" : "EUR"
},
"reference_id" : "MGS063464",
"shipping" : {
"address" : {
"country_code" : "DE",
"address_line_1" : "<removed>",
"admin_area_2" : "<removed>",
"postal_code" : "<removed>"
},
"name" : {
"full_name" : "<removed>"
}
},
"description" : "<removed>",
"items" : [ {
"quantity" : "1",
"name" : "<removed>",
"unit_amount" : {
"value" : "2.45",
"currency_code" : "EUR"
},
"sku" : "OCI08"
} ]
} ],
"links" : [ {
"method" : "GET",
"rel" : "self",
"href" : "https://api.sandbox.paypal.com/v2/checkout/orders/5MY66978KX626104P"
}, {
"method" : "GET",
"rel" : "approve",
"href" : "https://www.sandbox.paypal.com/checkoutnow?token=5MY66978KX626104P"
}, {
"method" : "PATCH",
"rel" : "update",
"href" : "https://api.sandbox.paypal.com/v2/checkout/orders/5MY66978KX626104P"
}, {
"method" : "POST",
"rel" : "capture",
"href" : "https://api.sandbox.paypal.com/v2/checkout/orders/5MY66978KX626104P/capture"
} ],
"id" : "5MY66978KX626104P",
"intent" : "CAPTURE",
"status" : "CREATED"
}
You are missing an API call, step 5 should instead be: The Server sends a Capture Order request.
Your final Step 6 should be to thank the buyer only if the capture was successful
See 'Capture Order' in the documentation.
Redirecting to an "approve" link is an old integration method, for old websites. For a modern user experience you should keep your page loaded (not redirect away) by changing your 'Create Order' and 'Capture Order' to be two server routes that return only JSON data (no other HTML or text)
Pair those routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
Related
{
"_id" : ObjectId("dde3431134247d401b1cef"),
"_resourceId" : "fwf4-fefre4-ffdfwsc",
"organizationId" : 343203,
"domains" : [
{
"_resourceId" : "da7-cwcwe-2432d",
"name" : "d12.net",
"tenantId" : "A1650",
"application" : "TEST",
"activeInd" : true,
"subdomains" : [
{
"_resourceId" : "fw243-weded3-2eddas",
"name" : "name1",
"clientName" : "Andrew",
"phoneNumber" : "8573458456",
"email" : "modalwindow#gmail.com",
},
{
"_resourceId" : "bce3-cwdd32ede-23ede",
"name" : "name2",
"clientName" : "client2",
"phoneNumber" : "9999999999",
"email" : "test#gmail.com",
}
]
}
]
}
I am using Springboot and MongoTemplate for the find Query. If I want to retrieve a subdomain based on "domains.subdomain.name" field, can I get only the subdomain json from a mongo query, or do I get the entire document and then iterate and filter the subdomain in my java code.
Use $unwind and then $replaceWith
db.collection.aggregate([
{
$match: {
"domains.subdomains.name": "name1"
}
},
{
$unwind: "$domains"
},
{
$unwind: "$domains.subdomains"
},
{
$match: {
"domains.subdomains.name": "name1"
}
},
{
$replaceWith: "$domains.subdomains"
}
])
mongoplayground
My mongodb records are like in this link Updating nested array inside array mongodb and sample records are as below and want to update a field in the nested document "parameter" array provided it satisfies some conditions (_id : "04", operations._id : "100" and operations.parameters.pid : "012"), this update query UPDATES wrong nested record (operations.parameters.pid : '011') , please help where I am going wrong:
{
"_id" : "04",
"name" : "test service 4",
"id" : "04",
"version" : "0.0.1",
"title" : "testing",
"description" : "test",
"protocol" : "test",
"operations" : [
{
"_id" : "99",
"oName" : "test op 52222222222",
"sid" : "04",
"name" : "test op 52222222222",
"oid" : "99",
"description" : "testing",
"returntype" : "test",
"parameters" : [
{
"oName" : "Param1",
"name" : "Param1",
"pid" : "011",
"type" : "582",
"description" : "testing",
"value" : "",
"version" : 1.0
},
{
"oName" : "Param2",
"name" : "Param2",
"pid" : "012",
"type" : "58222",
"description" : "testing",
"value" : "",
"version" : 2.0
}
]
},
{
"_id" : "100",
"oName" : "test op 909090",
"sid" : "05",
"name" : "test op 90909",
"oid" : "1009",
"description" : "testing",
"returntype" : "test",
"parameters" : [
{
"oName" : "Param1",
"name" : "Param1",
"pid" : "011",
"type" : "582",
"description" : "testing",
"value" : "",
"version" : 1.0
},
{
"oName" : "Param2",
"name" : "Param2",
"pid" : "012",
"type" : "58222",
"description" : "testing",
"value" : "",
"version" : 2.0
}
]
},
{
"_id" : "101",
"oName" : "test op 52222222222",
"sid" : "04",
"name" : "test op 52222222222",
"oid" : "99",
"description" : "testing",
"returntype" : "test",
"parameters" : [
{
"oName" : "Param1",
"name" : "Param1",
"pid" : "011",
"type" : "582",
"description" : "testing",
"value" : "",
"version" : 1.0
},
{
"oName" : "Param2",
"name" : "Param2",
"pid" : "012",
"type" : "58222",
"description" : "testing",
"value" : "",
"version" : 1.0
}
]
},
{
"_id" : "102",
"oName" : "test op 909090",
"sid" : "05",
"name" : "test op 90909",
"oid" : "1009",
"description" : "testing",
"returntype" : "test",
"parameters" : [
{
"oName" : "Param1",
"name" : "Param1",
"pid" : "011",
"type" : "582",
"description" : "testing",
"value" : "",
"version" : 1.0
},
{
"oName" : "Param2",
"name" : "Param2",
"pid" : "012",
"type" : "58222",
"description" : "testing",
"value" : "",
"version" : 2.0
}
]
}
]
}
My update query is as follows :
db.foo.update(
{ $and : [{'_id':'04'},
{'operations._id':'100' },
{'operations.parameters.pid': '012'}]},
{
"$set": {
"operations.1.parameters.$.dummy": "foo"
}
}
)
I am using mongodb 3.6.2 referred to https://docs.mongodb.com/master/reference/operator/update/positional-filtered/
Sample record from this link :
{
"_id" : 1.0,
"grades" : [
{
"type" : "quiz",
"questions" : [
10.0,
8.0,
5.0
]
},
{
"type" : "quiz",
"questions" : [
8.0,
9.0,
6.0
]
},
{
"type" : "hw",
"questions" : [
5.0,
4.0,
3.0
]
},
{
"type" : "exam",
"questions" : [
25.0,
10.0,
23.0,
0.0
]
}
]
}
Example from this link
db.student3.update(
{},
{ $inc: { "grades.$[t].questions.$[score]": 2 } },
{ arrayFilters: [ { "t.type": "quiz" } , { "score": { $gte: 8 } } ], multi: true}
)
ERror I got from robo-3t :
cannot use the part (grades of grades.$[t].questions.$[score]) to traverse the element ({grades: [ { type: "quiz", questions: [ 10.0, 8.0, 5.0 ] }, { type: "quiz", questions: [ 8.0, 9.0, 6.0 ] }, { type: "hw", questions: [ 5.0, 4.0, 3.0 ] }, { type: "exam", questions: [ 25.0, 10.0, 23.0, 0.0 ] } ]})
Please help;
Regards
Kris
In your update operation
"$set": {
"operations.1.parameters.$.dummy": "foo"
}
refers to the 1st element in operations that is an element with "_id" : "100", and within parameters array, the $ updates the first element in array.
You need to consider using mongodb 3.6 if you want to update nested array elements using $[] to update all matching elements.
One possible way to do this in 3.4 version is fetching the required sub-document and do matches and updates on the application side.
The project is a visual analysis of business data, MongoDB through Spring Data, REST interface, then d3.js.
On the database level, my data looks like this:
/* 1 */
{
"_id" : ObjectId("58ac466160fb39e5e8dc8b70"),
"dots" : {
"x" : 4,
"y" : 3
}
}
/* 2 */
{
"_id" : ObjectId("58ac468060fb39e5e8dc8b7e"),
"squares" : {
"x" : 12,
"y" : 2
}
}
The REST interface (spring) delivers this:
{
"_embedded" : {
"JSON" : [ {
"squares" : null,
"dots" : {
"dot" : {
"x" : 4,
"y" : 3
}
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/JSON/58ac466160fb39e5e8dc8b70"
},
"jSON" : {
"href" : "http://localhost:8080/JSON/58ac466160fb39e5e8dc8b70"
}
}
}, {
"squares" : {
"square" : {
"x" : 12,
"y" : 2
}
},
"dots" : null,
"_links" : {
"self" : {
"href" : "http://localhost:8080/JSON/58ac468060fb39e5e8dc8b7e"
},
"jSON" : {
"href" : "http://localhost:8080/JSON/58ac468060fb39e5e8dc8b7e"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/JSON"
},
"profile" : {
"href" : "http://localhost:8080/profile/JSON"
}
},
"page" : {
"size" : 20,
"totalElements" : 2,
"totalPages" : 1,
"number" : 0
}
}
Now I'm having trouble accessing this for processing in d3.js for visualization, whatever way I try to access the data, I only get "undefined" with no values back on the console.
Should I reformat to get rid of the "_embedded" part, or to "flatten" the data generally, or do I need a specific way to access it?
As of now, I'm just using "d3.json("/JSON")" to access the interface, but can't extract any data.
Ok so I am making API requests to retrieve certain things like movies, songs, or to ping the server. However all of these responses are contained within the same response JSON object that has varying fields depending on the response. Below are three examples.
ping
{
"response" : {
"status" : "ok",
"version" : "0.9.1"
}
}
getIndexes
{
"response" : {
"status" : "ok",
"version" : "0.9.1",
"indexes" : {
"index" : [ {
"name" : "A",
"movie" : [ {
"id" : "150",
"name" : "A Movie"
}, {
"id" : "2400",
"name" : "Another Movie"
} ]
}, {
"name" : "S",
"movie" : [ {
"id" : "439",
"name" : "Some Movie"
}, {
"id" : "209",
"name" : "Some Movie Part 2"
} ]
} ]
}
}
}
getRandomSongs
{
"response" : {
"status" : "ok"
"version" : "0.9.1"
"randomSongs" : {
"song": [ {
"id" : "72",
"parent" : "58",
"isDir" : false,
"title" : "Letter From Yokosuka",
"album" : "Metaphorical Music",
"artist" : "Nujabes",
"track" : 7,
"year" : 2003,
"genre" : "Hip-Hop",
"coverArt" : "58",
"size" : 20407325,
"contentType" : "audio/flac",
"suffix" : "flac",
"transcodedContentType" : "audio/mpeg",
"transcodedSuffix" : "mp3",
"duration" : 190,
"bitRate" : 858,
"path" : "Nujabes/Metaphorical Music/07 - Letter From Yokosuka.flac",
"isVideo" : false,
"created" : "2015-06-06T01:18:05.000Z",
"albumId" : "2",
"artistId" : "0",
"type" : "music"
}, {
"id" : "3135",
"parent" : "3109",
"isDir" : false,
"title" : "Forty One Mosquitoes Flying In Formation",
"album" : "Tame Impala",
"artist" : "Tame Impala",
"track" : 4,
"year" : 2008,
"genre" : "Rock",
"coverArt" : "3109",
"size" : 10359844,
"contentType" : "audio/mpeg",
"suffix" : "mp3",
"duration" : 258,
"bitRate" : 320,
"path" : "Tame Impala/Tame Impala/04 - Forty One Mosquitoes Flying In Formation.mp3",
"isVideo" : false,
"created" : "2015-06-29T21:50:16.000Z",
"albumId" : "101",
"artistId" : "30",
"type" : "music"
} ]
}
}
}
So basically my question is, how should I structure my model classes to use for parsing these responses? At the moment I have an abstract response object that only contains fields for the status and version. However, by using this approach I will need a response class that extends this abstract class for ever request I make (e.g. AbstractResponse, IndexesResponse, RandomSongsResponse). Also, some models with the same name may have different fields depending on the API request made. I would prefer to avoid making a model class for every possible scenario.
And as an extra note, I am using GSON for JSON serialization/deserialization and Retrofit to communicate with the API.
I'm having an issue in STS creating a custom template. What I want is the ability to do token-based replacement within all files in the project. I've read this is possible with the "token" replacement, but cannot seem to get the wizard.json to let me accept multiple inputs. The "example" you see everywhere is replacing the top-level-package, which I've got to work great.
Anyone have any examples of doing multiple inputs in the wizard.json, or have any idea on what I'm doing wrong?
Here is what I have, which doesn't work:
{
"info" : {
"elements" : {
"element" : [
{
"name" : "mysystem",
"description" : "Please the name of your system (ex. marketing, hr, accounting, etc).",
"type" : "java.lang.String",
"page" : 0,
"required" : true,
"pattern" : "\\w+",
"replaceKind" : "token"
}
],
"element" : [
{
"name" : "myapp",
"description" : "Please the name of your application (ex. thisapplication, thatapplication, etc).",
"type" : "java.lang.String",
"page" : 0,
"required" : true,
"pattern" : "\\w+",
"replaceKind" : "token"
}
]
},
"projectName" : "projectName",
"pages" : {
"page" : [
{
"order" : 0,
"description" : "System Info"
}
]
}
}
}
The "myapp" picks up and does the translation, but the "mysystem" never even gets displayed for input (screen one is just the myapp text).
For those who run into the same problem, I have figured this out. Here is what I ended up with.
{
"info" : {
"elements" : {
"element" : [
{
"name" : "mysystem",
"description" : "Please the name of your system (ex. marketing, hr, accounting, etc).",
"type" : "java.lang.String",
"page" : 0,
"required" : true,
"pattern" : "\\w+",
"replaceKind" : "token"
},
{
"name" : "myapp",
"description" : "Please the name of your application (ex. thisapplication, thatapplication, etc).",
"type" : "java.lang.String",
"page" : 1,
"required" : true,
"pattern" : "\\w+",
"replaceKind" : "token"
}
]
},
"projectName" : "projectName",
"pages" : {
"page" : [
{
"order" : 0,
"description" : "System Info"
}
],
"page" : [
{
"order" : 1,
"description" : "System Info 2"
}
]
}
}
}