Wirecard refund request - rest

I'm trying to integrate wirecard payments and got a problem with the refund transaction.
With test username "70000-APILUHN-CARD" and password "8mhwavKVb91T" i've created payment processing and could see that it's successful. But when it comes to refund i get "405 method not allowed" result.
So the payment request looks like this:
POST https://wpp-test.wirecard.com/api/payment/register
With auth header including encoded username/password, content-type header, and body:
{
"payment" :
{
"merchant-account-id" :
{
"value" : merchantId
},
"request-id" : generatedRequestId,
"transaction-type" : "auto-sale",
"requested-amount" :
{
"value" : 1,
"currency" : "EUR"
},
"payment-methods" :
{
"payment-method" :
[
{"name" : "creditcard"}
]
}
},
"options" :
{
"mode" : "seamless",
"frame-ancestor" : ancestorURL
}
}
After verification i could check that such transaction successfully completed and everything is fine, so i tried to make a refund request with the same headers:
POST https://api-test.wirecard.com/engine/rest/merchants/{merchantId}/payments/{transactionId}
and body:
{
"payment":{
"merchant-account-id":{
"value":merchantId
},
"request-id":generatedRequestId,
"requested-amount":{
"value":1,
"currency":"EUR"
},
"payment-methods":{
"payment-method":[
{
"name":"creditcard"
}
]
},
"card-token":{
"token-id":"4819253888096002"
},
"card":{
"expiration-month":"1",
"expiration-year":"2023",
"card-type":"visa"
},
"parent-transaction-id": parentTransactionId,
"transaction-type":"refund-request"
},
"options":{
"mode":"seamless",
"frame-ancestor":ancestorURL
}
}
Where all the data about card/card-token/etc were obtained from transaction state request.
Is there any mistakes in my refund request, or maybe there are some extra steps that i should perform?

There are a set of mistakes both in payment and in refund requests:
Payment request needs to have the "transaction-type" : "purchase" instead of "transaction-type" : "auto-sale"
Refund request should have the "transaction-type" : "refund-purchase" instead of "transaction-type" : "refund-request"
Also refund request should be sent at URL: "https://api-test.wirecard.com/engine/rest/payments/"
(From wirecard support answer)

Related

Sendgrid singlesend error with api : json could not be unmarshalled

I am trying to trigger a singlesend using sendgrid api but getting json could not be unmarshalled error.
Here is what I am trying to send in my payload
{
"name" : "this is a test api 2",
"send_at": "now",
"email_config": {
"sender_id": 4810***,
"design_id": "06daea5d-9470-4cb5-8dc6-******"
},
"send_to": {
"list_ids": [
"8a97936a-8cf8-4e60-bfd3-******"
],
"segment_ids": [],
"all" : false
}
}
I am following this doc : https://docs.sendgrid.com/api-reference/single-sends/create-single-send

Mongoose updateMany :: wont find any on given condition

I have updateMany function as follows
Article.updateMany({author: userId}, {author: anonym}, function(err, updated) {
if (err) {
res.send(err);
} else {
res.send(updated);
}
});
userId is = 6068b57dbe4eef0b579120c7
anonym is = 6069870676d6320f39e7e5a2
for testing purposes I have a single article in MongoDB as follows
db.articles.find()
{ "_id" : ObjectId("6068b591be4eef0b579120c8"), "favoritesCount" : 1, "comments" : [ ], "tagList" : [ ], "title" : "Martin", "description" : "Testib", "body" : "Asju", "author" : ObjectId("6068b57dbe4eef0b579120c7"), "slug" : "martin-2hzx78", "createdAt" : ISODate("2021-04-03T18:36:01.977Z"), "updatedAt" : ISODate("2021-04-03T18:53:29.809Z"), "__v" : 0 }
You can see that article has "author" : id field in it which currently shows userId as author.
I want to update that field and transfer authorship to anonym user.
When I send this request to postman I get following response
{
"n": 0,
"nModified": 0,
"ok": 1
}
And database remains unchanged. What am I doing wrong here ?

Unable to add a single line items with modifiers using Clover POS REST API

I am trying to add a single line item with modifiers using the Rest API. I see answers that it's not possible while adding bulk line items (the documentation for both suggests that this should be possible).
This is the request I am sending.
URL: https://sandbox.dev.clover.com/v3/merchants/MERCHANTID/orders/ORDERID/line_items
Request Type: POST
"item": {
"id":"9S1MXGERPQ7ER"
}
"modifications" : [{
"modifier" : {
"id" : "ZM8MV5X3M7R72",
"modifierGroup": {
"id" : "YC351CMAHF6AY"
}
},
"modifier" : {
"id" : "0X5A869PQT858",
"modifierGroup": {
"id" : "XZP32FHXQWKE6"
}
}
}]
The item gets created fine. but none of the modifiers are added.
I checked that creating a line item initially and then making an explicit call to the below URL to add modification works fine, but with this approach we can only add 1 modifier per call.
https://sandbox.dev.clover.com/v3/merchants/MERCHANTID/orders/ORDERID/line_items/LINEITEMID/modifications
Request:
{
"modifier" : {
"id" : "ZM8MV5X3M7R72"
}
}
With this approach we have to make multiple calls per line item based on number of modifiers selected.
Am I missing something here?
I have the same problem. you are missing the name and amount property of the modifier. These are required fields e.g
URL: https://sandbox.dev.clover.com/v3/merchants/MERCHANTID/orders/ORDERID/line_items
Request Type: POST
"item": {
"id":"9S1MXGERPQ7ER"
}
"modifications" : [{
"modifier" : {
"id" : "ZM8MV5X3M7R72",
"modifierGroup": {
"id" : "YC351CMAHF6AY"
},
},
"name": "yourModifierName",
"amount": "amountOfModifier"
}]

Query providing different results on Cosmos (vs Pure Mongo)

I have a Mongo collection which has this document structure:-
{
"_id" : ObjectId("5d5e5f1dfc325d4018302293"),
"status" : "PENDING",
"workflowJourney" : [
{
"_id" : ObjectId("5d5e5f1dfc325d401830229c"),
"workflowDate" : ISODate("2019-08-22T09:23:41.491Z"),
"workflowType" : "Email",
"workflowDescription" : "Email sent to Joe Bloggs",
"workflowRecipient" : {
"employeeNumber" : "12345",
"firstName" : "Joe",
"surname" : "Bloggs",
"emailAddress" : "joe.blogs#example.com"
},
"workflowSubject" : "Invoice Approval Required (2112)",
"workflowHtmlContent" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitiona..."
},
{
"_id" : ObjectId("5d5e5f1dfc325d401830229d"),
"workflowDate" : ISODate("2019-08-22T09:23:41.507Z"),
"workflowType" : "Email",
"workflowDescription" : "Email sent to Jane Bloggs",
"workflowRecipient" : {
"employeeNumber" : "56789",
"firstName" : "Jane",
"surname" : "Bloggs",
"emailAddress" : "jane.bloggs#example.com"
},
"workflowSubject" : "Invoice Approval Required (2112)",
"workflowHtmlContent" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitiona..."
}
],
"approvals" : [],
"__v" : 1
}
I'm trying to create a query which will get a single workflowJourney. At the point of executing the query, I will already know the _id of both the main document and the workflowJourney subdocument, so I could use either/both of of these in my query.
The issue is, for this development project we are using Azure Cosmos and the query that I would expect to work is giving strange results.
If I run this in pure Mongo:-
db.getCollection('Invoices').find(
{"workflowJourney._id": ObjectId("5d5e5fd907ba93320cc54198")},
{"workflowJourney.$": 1.0}
);
I get this nice result back:-
{
"_id" : ObjectId("5d5e5f1dfc325d4018302293"),
"workflowJourney" : [
{
"_id" : ObjectId("5d5e5f1dfc325d401830229d"),
"workflowDate" : ISODate("2019-08-22T09:23:41.507Z"),
"workflowType" : "Email",
"workflowDescription" : "Email sent to Jane Bloggs",
"workflowRecipient" : {
"employeeNumber" : "56789",
"firstName" : "Jane",
"surname" : "Bloggs",
"emailAddress" : "jane.bloggs#example.com"
},
"workflowSubject" : "Invoice Approval Required (2112)",
"workflowHtmlContent" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitiona..."
}
]
}
Running the same query in Azure Cosmos (database contains the same data), I get this:-
{
"_id" : ObjectId("5d5e5f1dfc325d4018302293"),
"workflowJourney" : [
{},
{}
]
}
So, no useful results. I know that Cosmos DB is more of a Mongo emulator rather than a pure implementation. But I guess what I am trying to achieve is a fairly common scenario; I wonder if anyone has any suggestions on how I could re-write my query to get the result I need?
Many thanks
Glen
Okay, so I've achieved what I need to do by doing the filtering from the Node level instead. I guess the filter queries are really designed for returning entire documents rather than filtering information from within a single document.
Example:-
router.get('/emailPreview/:invoiceId/:workflowJourneyItemId', (req, res, next) => {
Invoice.findOne({ "_id": req.params.invoiceId })
.then(invoice => {
if(invoice) {
const emailHtml = invoice.workflowJourney.filter((item) => {
return item.id === req.params.workflowJourneyItemId;
})[0].workflowHtmlContent;
res.status(200).set('Content-Type', 'text/plain').send(emailHtml);
} else {
res.status(404).json({ Error: 'Email not found'});
}
}).catch(err => {
res.status(404).json({ Error: 'Email not found'});
})
});

Spring Cloud Contract provider return same as request

I'm working with two microservices using Spring Cloud Contract. One providing its contract, and the other one consuming it. In one scenario the provider response is the same that the request.
So the provider contract is like this:
Contract.make {
request {
method 'POST'
url '/provider/foo'
body(
"foo": $(regex("[a-zA-Z0-9]{20}"))
)
}
response {
status 200
body(
"fooResponse": fromRequest().body("\$.foo")
)
}
And the generated wiremock mapping:
{
"id" : "a80c0871-f4c0-49e3-8cc1-94de39899669",
"request" : {
"url" : "/provider/foo",
"method" : "POST",
"bodyPatterns" : [ {
"matchesJsonPath" : "$[?(#.['foo'] =~ /[a-zA-Z0-9]{20}/)]"
} ]
},
"response" : {
"status" : 200,
"body" : "{\"fooResponse\":\"{{{jsonpath this '$.foo'}}}\"}",
"transformers" : [ "response-template" ]
},
"uuid" : "a80c0871-f4c0-49e3-8cc1-94de39899669",
"scenarioName" : "scenarioReturnSameAsRequest",
"requiredScenarioState" : "Started"
}
But when my code calls to the provider, with foo as any text, the wiremock returns:
{
"fooResponse" : "{{{jsonpath this '$.foo'}}}"
}
How can I build a contract that responses the same parameters as the request body?
Edit
I tried with a fixed value on the response and works fine:
Contract.make {
request {
method 'POST'
url '/provider/foo'
body(
"foo": $(regex("[a-zA-Z0-9]{20}"))
)
}
response {
status 200
body(
"fooResponse": "fooValue"
)
}
Now wiremock return:
{
"fooResponse" : "fooValue"
}
Maybe is not supported getting from request a regex value?
I think the mapping should contain request.body instead of this. Also I wonder if you need to use 3 times a { or just 2 times. Or do you need to escape these?
Possible mapping:
"response" : {
"status" : 200,
"body" : "{\"fooResponse\":\"{{jsonpath request.body '$.foo'}}\"}",
"transformers" : [ "response-template" ]
},
See also the chapter JSONPath helper on http://wiremock.org/docs/response-templating
I had the same problem once. You can try to use value() like this:
"fooResponse": value(fromRequest().body('$.foo'))