Mollie webhook URL called but payment id not getting - mollie

We have already created issues and this similar this https://github.com/mollie/api-documentation/issues/583
We have set webhook URL the id parameter in request but every time we got id is null so my question is id parameter are we pass or your side passed the parameter? let me know we are big trouble at this moment.
Create a payment response
{
"resource": "payment",
"id": "tr_pCHpdCbpb5",
"mode": "test",
"createdAt": "2020-01-24T09:40:18+00:00",
"amount": {
"value": "100.10",
"currency": "EUR"
},
"description": "46-201800046",
"method": null,
"metadata": null,
"status": "open",
"isCancelable": false,
"expiresAt": "2020-01-24T09:55:18+00:00",
"profileId": "pfl_wv9K6uRbg7",
"sequenceType": "oneoff",
"redirectUrl": "http://localhost:60991/nl-nl/OrderValidation?paymentType=mollie",
"webhookUrl": "https://devee05.solvisoft.net/api/mollie/webhook",
"_links": {
"self": {
"href": "https://api.mollie.com/v2/payments/tr_pCHpdCbpb5",
"type": "application/hal+json"
},
"checkout": {
"href": "https://www.mollie.com/payscreen/select-method/pCHpdCbpb5",
"type": "text/html"
},
"documentation": {
"href": "https://docs.mollie.com/reference/v2/payments-api/create-payment",
"type": "text/html"
}
}
}
When we paid amount specific to payment method Webhook URL automatically called but we got id every time null, but we detected or auto mapped currently created payment id? in webhook URL.

If you are struggling with the webhook controller method appearing not to be properly called: prefix the id parameter with the [FromForm] attribute. With that, the id value is nicely available.
As the documentation points out, the request made by Mollie is form encoded:
Content-Type: application/x-www-form-urlencoded
My controller method looks like this:
[HttpPost, Route("paymentstatus", Name = nameof(NotifyPaymentStatusChange))]
public async Task<IActionResult> NotifyPaymentStatusChange([FromForm] string id)
{
// Use the received id value to continue the payment verification process ...
}

Hello all I'm getting the webhook URL data using Request content
public virtual HttpResponseMessage Webhook(string id)
{
StringBuilder sb = new StringBuilder();
string filePath = System.Web.Hosting.HostingEnvironment.MapPath("~/MollieLog/MollieStatus.txt");
HttpContent requestContent = Request.Content;
string jsonContent = requestContent.ReadAsStringAsync().Result;
sb.AppendLine("Request content - " + jsonContent);
try
{
string mollieResponse = new MollieService(_apiKey).Get(string.Concat("payments/", id));
sb.AppendLine("ID - " + id);
sb.AppendLine("Current Date Time " + DateTime.Now);
sb.AppendLine(mollieResponse);
sb.AppendLine(Newtonsoft.Json.JsonConvert.SerializeObject(Request.Headers));
sb.AppendLine("---------------------------------------");
File.AppendAllText(filePath, sb.ToString());
sb.Clear();
}
catch (Exception ex)
{
sb.AppendLine("Error " + ex.Message);
File.AppendAllText(filePath, sb.ToString());
}
return Request.CreateResponse(HttpStatusCode.OK);
}
Output
Request content - id=tr_dCCujJWqK9

Related

How to create multiple entities using a single OData POST to a Business Central Web Service?

I tried to POST an array of objects and, as expected, it isn't that easy. In my case I want to insert multiple Transfer Order Lines in the same request.
// Request Body
[
{
"documentNo": "1002",
"itemNo": "1968-S",
"quantity": 3
},
{
"documentNo": "1002",
"itemNo": "1968-S",
"quantity": 113
}
]
// Response
{
"error": {
"code": "BadRequest",
"message": "Invalid Request Body CorrelationId: a2606676-3f8f-4753-aaee-be91a621f070."
}
}
Is it possible to do what I want without sending a request for every Line entity I want to add?
You need to create a structure like this:
url: api/2.0/$batch
Body:
```lang-json
{
"requests":
[
{
"method": "POST",
"id":"R1",
"url": "companies(id)/APIEntitySetName",
"headers":
{
"content-Type": "application/json"
},
"body":
{}
},
{
another line
}
]
}
```

Migrating from API V1 to V2: How to getPaymentInstuctions after capture order?

I'm trying to migrate from API V1 to V2 in PHP. In V1, you could use this code to get further payment-instructions after executing a payment:
try {
$execution = new Paypal\Api\PaymentExecution();
$execution->setPayerId($sPayerId);
$payment = \Paypal\Api\Payment::get($sPaymentId, getApiContext());
$payment->execute($execution, getApiContext());
$payment = \Paypal\Api\Payment::get($sPaymentId, getApiContext()); // re-fetch payment with payment-instructions
if ($payment->getPaymentInstruction())
{ $sBankName = $payment->getPaymentInstruction()->recipient_banking_instruction->bank_name;
$sBandAccountNumber = $payment->getPaymentInstruction()->recipient_banking_instruction->international_bank_account_number;
...
}
}
catch(PayPal\Exception\PayPalConnectionException $ex) {
...
}
It's important for us to display the payment-instructions to our customer: If they use the "pay later"/"pay via invoice"-feature, they need to know to which bank and account to transfer the money to.
In API V2, you use this code to capture an authorized order:
$request = new PayPalCheckoutSdk\Orders\OrdersCaptureRequest($sOrderId);
try {
$response = getClient()->execute($request);
}
catch(PayPalHttp\HttpException $exception) {
....
}
So what are the next steps to get the payment-instructions now?
The field was not documented for the v1/payments API.
For v2/checkout/orders , a payment_instruction field is documented as an order creation request field (within purchase_units) and response field.
A similar field exists when capturing an authorization.
For Pay Upon Invoice, there is a processing_instruction field.
In all these cases, the fields do not contain information regarding "which bank and account to transfer the money to" or similar.
However, for PUI there is a response field payment_source.pay_upon_invoice.deposit_bank_details . Perhaps this is what you are looking for.
{
"id": "5O190127TN364715T",
"intent": "CAPTURE",
"status": "COMPLETED",
"processing_instruction": "ORDER_COMPLETE_ON_PAYMENT_APPROVAL",
"payment_source": {
"pay_upon_invoice": {
"birth_date": "1990-01-01",
"name": {
"given_name": "John",
"surname": "Doe"
},
"email": "buyer#example.com",
"phone": {
"national_number": "6912345678",
"country_code": "49"
},
"billing_address": {
"address_line_1": "Schönhauser Allee 84",
"admin_area_2": "Berlin",
"postal_code": "10439",
"country_code": "DE"
},
"payment_reference": "b8a1525dlYzu6Mn62umI",
"deposit_bank_details": {
"bic": "DEUTDEFFXXX",
"bank_name": "Deutsche Bank",
"iban": "DE89370400440532013000",
"account_holder_name": "Paypal - Ratepay GmbH - Test Bank Account"
}
}
},
"purchase_units": [
....
],
"links": [
....
]
}

Facebook Graph API Post

I'm trying to post a score on facebook using graph api for a game that i created. My input is the following:
Method is POST:
me/score/score=10
{
"error": {
"message": "(#100) At least one reference object must be specified.",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Aa4wSne7KqK"
}
}
I was able to do it yesterday, and the score changed to 100. However it is not working today.
If i use the get method to see my score, here is what i get:
{
"data": [
{
"score": 100,
"user": {
"name": "Nassif Bousaba",
"id": "10159173554635214"
}
},
{
"score": 0,
"user": {
"name": "Nassif Bousaba",
"id": "10159173554635214"
}
}
]
}
All permissions were granted since i was able to post the score before.
This worked after changing the code from request ExecuteAndWait to executeAsync. Additionally i had to change the application type to game in facebook application settings. Code is below for android
public void PublishMyScore(String Score)
{
Bundle params = new Bundle();
params.putString("score", Score);
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/"+AccessToken.getCurrentAccessToken().getUserId()+"/scores/",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.w("TAG","SCORE ADDED");
Log.w("TAG",response.toString());
}
}
).executeAsync();
}

Add event to calendar on SharePoint through REST API

I'm trying to add a calendar event to a SharePoint Calendar through REST API but i can't seems to find the relevant resources to achieve this.
If i understand correctly, the calendar in SharePoint is a List of events object, as such I should be able to add the event via ListItem object?
Sorry if this sounds wrong as I'm not familiar with SharePoint structure.
Thanks
This is the example for OAuth token Authentication but REST part is anyway like this.
var dataObj = {
"Subject": "Birthday Party"
"Body": {
"ContentType": "Text",
"Content": "Birthday Party for Cathy",
},
"Start": {
"dateTime": "2016-07-03T09:00:00Z",
"timeZone": "Asia/Tokyo"
},
"End": {
"dateTime": "2016-07-04T11:00:00Z",
"timeZone": "Asia/Tokyo"
},
"Location": {
"DisplayName": "Conference Room 1"
},
"ShowAs": "Busy",
"Attendees": [
{
"EmailAddress": { "Name": "Alex Darrow", "Address": "darrow.alex#company.com" },
"Type": "Required"
}
]
};
var url = "https://graph.microsoft.com/v1.0/me/events/";
var data = JSON.stringify(dataObj);
$.ajax({
url: url,
type: "POST",
data: data,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json;odata.metadata=full;odata.streaming=true");
XMLHttpRequest.setRequestHeader('Authorization', 'Bearer ' + accessToken);
XMLHttpRequest.setRequestHeader("content-type", "application/json;odata=verbose");
},
success: function (result, textStatus, jqXHR) {
//Success
},
error: function (data) {
//
}});

Record saves, promise rejects with custom REST adapter

I'm writing an ember-data adapter for the DreamFactory services platform and am running into an issue I think is related to my adapter.
When updating an existing record the promise resulting from model.save() is ALWAYS rejected with an error of
Assertion Failed: An adapter cannot assign a new id to a record that already has an id. <App.Event311:1> had id: 1 and you tried to update it with null. This likely happened because your server returned data in response to a find or update that had a different id than the one you sent
Thing is - the request to the REST API and the response back from the REST API have the same ID!
Request (PUT)
{
"record": {
"id": "1",
"title": "Sample Event",
"date": "7/20/2013",
"type": "success",
"desc": "My first sample event."
}
}
Response
{
"record": [
{
"id": 1,
"title": "Sample Event",
"date": "7/20/2013",
"type": "success",
"desc": "My first sample event."
}
]
}
The really weird thing is the record still updates properly both in the store AND in the database!
I have a working JSBin at http://emberjs.jsbin.com/mosek/1/edit that illustrates the problem. My custom adapter is on GitHub at https://github.com/ultimatemonty/ember-data-dreamfactory-adapter. The JSBin as well as my app are using Ember 1.7.0 and ED 1.0.0-beta.9
EDIT
The JSBin is attached to my personal hosted instance of DreamFactory - I haven't done anything with it outside of allowing access from JSBin but please be gentle :)
* EDIT #2 *
The updateRecord code is accessible on GitHub at https://github.com/ultimatemonty/ember-data-dreamfactory-adapter/blob/master/lib/ember-data-dreamfactory-adapter.js#L106 but here is the full method for reference:
updateRecord: function(store, type, record) {
var data = {};
var serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record);
var adapter = this;
return new Ember.RSVP.Promise(function(resolve, reject) {
// hack to make DSP send back the full object
adapter.ajax(adapter.buildURL(type.typeKey) + '?fields=*', "PUT", { data: data }).then(function(json){
// if the request is a success we'll return the same data we passed in
resolve(json);
}, function(reason){
reject(reason.responseJSON);
});
});
}
The adapter/serializer you're using is expecting you to return a response without the type in it:
{
"id": 1,
"title": "Sample Event",
"date": "7/20/2013",
"type": "success",
"desc": "My first sample event."
}
Example: http://emberjs.jsbin.com/tigiza/1/edit
You can see it here in the extractSingle, where it tries to wrap the payload in in another object with the type specified
EmberDreamFactoryAdapter.Serializer = DS.RESTSerializer.extend({
extractArray: function(store, primaryType, payload) {
var namespacedPayload = {};
namespacedPayload[Ember.String.pluralize(primaryType.typeKey)] = payload.record;
return this._super(store, primaryType, namespacedPayload);
},
extractSingle: function (store, primaryType, payload, recordId) {
var namespacedPayload = {};
namespacedPayload[primaryType.typeKey] = payload;
return this._super(store, primaryType, namespacedPayload, recordId);
},
Your response looks like this:
{
"record": [
{
"id": 1,
"title": "Sample Event",
"date": "7/20/2013",
"type": "success",
"desc": "My first sample event."
}
]
}
Then the serializer kicks in, and it looks like this:
{
event:{
"record": [
{
"id": 1,
"title": "Sample Event",
"date": "7/20/2013",
"type": "success",
"desc": "My first sample event."
}
]
}
}
When really, the serializer should have it looking like this:
{
event:{
"id": 1,
"title": "Sample Event",
"date": "7/20/2013",
"type": "success",
"desc": "My first sample event."
}
}
You can see from the second example, the serializer wraps it in the type, then Ember Data says, hey, give me the id, so it looks at event.id which is undefined, because it lives under event.record[0].id