Square Point of Sales API sending reference_id or userInfoString - ios

I'm using point of sales API to integrate a webapp with Square point of sales for IOS.
according to the API, if I send a reference in my transaction request I'll get that reference back in the response URL and that's what I want to use that reference for further processing in my app.However I'm not getting the reference in the response so I guess something is wrong in my request
this is my request object
var dataParameter = {
amount_money: {
amount:amount * 100,
currency_code: "USD"
},
callback_url: myURL,
reference_id: referenceId,
client_id: applicationId,
version: "1.3",
notes: "this is a test",
options: {
supported_tender_types: ["CREDIT_CARD", "CASH"],
auto_return: true
}
}
I also tried "userInfoString" instead of "reference_id" and it didn't work.

Related

Can't place GraphQL custom type as a Postman variable

Has anyone had luck with placing a GraphQL custom type argument as a Postman or Graphql variable? I'm kinda spinning in circles right now, I hope a fresh pair of eyes could point me in the right direction.
What I'm trying to do is to send a mutation request using Postman. The problem I'm having is that the method I'm calling is taking a custom type as an argument. Placing the content of that variable as GraphQL variable or Postman variable is giving me a headache. I can't embedd pictures yet, so here are the links (they are safe).
Schema
This custom type is a JSON-like structure, consisting of two enums and a set of primitive types (strings, ints...). I can screenshot the entire thing but basically that's it: two enums followed by strings, ints...
Custom type definition
What I've tried so far:
Simply hardcoding the request in Postman works but I wish to send multiple requests with varying data
Placing it in a GraphQL variable results in error message
{
"errors": [
{
"message": "Bad request - invalid request body.",
"locations": []
}
],
"data": null
}
Placing the custom type content as a Postman environment variable works, but I'm getting a syntax error (although the request passes...).
Request body is below. Hardcoding it and using a Postman variable produces the same request body, apart from the syntax error.
query: "mutation {
createApplication(request: {
applicationKind: NEW_ISSUANCE,
documentKind: REGULAR_PASSPORT,
personalData: {
timestamp: null,
firstname: "NAME",
lastname: "LASTNAME",
middlename: "MIDDLENAME",
dateOfBirth: "2011-09-28",
citizenshipCountryCode: "USA",
gender: MALE,
personalNumber: "3344",
placeOfBirth: "CHICAGO",
municipalityOfBirth: "SOUTH",
countryCodeOfBirth: "USA"},
addressData:{
street: "WEST",
municipality: "EAST",
place: "CHICAGO",
country: {
code: "USA",
name: null
},
entrance: "б",
flat: "13",
number: "35"}
})
{
__typename
... on AsyncTaskStatus {
taskID
state
payload {
... on ApplicationUpdated {
applicationID
applicationNumber
__typename
}
__typename
}
__typename
}
... on Error {
...errorData
__typename
}
}
}
fragment errorData on Error {
__typename
code
message
}"
Postman variable with a squiggly line
I'm spinning in circles right now. Has anyone had any luck with Postman requests of this kind?
I can post more info, screenshots...just let me know. I'll be watching this topic closely and provide feedback.
Thank you for your time.
please add a the variable in variable section as :
{
"request": {{request}}
}
and then refer this in your query as
$request

How do i get EC_v1 version of Apple Pay PaymentToken

I'm trying to Integrate Apple Pay in my application. Following the online docs and some SO help, I've managed to show the Apple Pay payment dialog and all the call backs are configured.
the response returned from the Apple Pay is something like this
{
"version": "RSA_v1",
"signature": "somestring",
"data": "DP...A=",
"header": {
"wrappedKey": "MF...5g==",
"publicKeyHash": "kd...l4=",
"transactionId": "a5...3e"
}
}
But my requirement is to get ephemeralPublicKey under header object. According to Apple Pay Payment Token Format Reference
the returned object is correct as its RSA_v1 version which will not have ephemeralPublicKey but wrappedKey. Now my question is how do i get EC_v1 version of the returned token object.
May be I'm missing something here in the docs but please someone point me to the right direction. Any help is appreciated.
Here is the way to get this returned response from the Apple Pay Gateway server. You can't see this response in the console directly. You can see this response only if you will log it on the server by using an ajax request. See mine below sample URL and my source code.
Full Documentation for beginners
https://gist.github.com/jagdeepsingh/c538e21f3839f65732a5932e35809d60
session.onpaymentauthorized = (event) => {
$("#paymentMethodVal").val("apple-pay");
$form = $("#reservation-form");
console.log($form.serialize());
callRequest({
url: '/reserve/init-apple-pay',
method: 'POST',
data: {
token: event.payment.token,
reservationData: $form.serialize()
},
beforeRequest: function(e) {},
afterRequest: function(response) {
response = JSON.parse(response);
if(response.status){
toastr.success(response.message);
session.completePayment(ApplePaySession.STATUS_SUCCESS);
}else{
toastr.error(response.message.split(/\r\n|\r|\n/g).join('<br/>'));
session.completePayment(ApplePaySession.STATUS_FAILURE);
}
}
});
};
token: event.payment.token, line is your answer this will send data directly to server and you can log data over there.
{
"version": "RSA_v1",
"signature": "somestring",
"data": "DP...A=",
"header": {
"wrappedKey": "MF...5g==",
"publicKeyHash": "kd...l4=",
"transactionId": "a5...3e"
}
}

How to avoid 404 error in Twitter API's Unlike Tweet endpoint?

I am attempting to Unlike a Tweet using Pipedream an integration platform. When I hit Twitter's API for Unlike a Tweet, I get an 404. I double checked and the URL is the same as in the documentation.
const body = {
config: {
method: "post",
url: `https://api.twitter.com/1.1/favorites/destroy.json`,
params : {
id : params.id,
include_entities : params.include_entities
},
},
token: {
key: auths.twitter.oauth_access_token,
secret: auths.twitter.oauth_refresh_token,
}
};
As you can see, the URL from that code is the one specified in the documentation at https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-destroy
Any advice on how to get this corrected?
Are you sure that the Tweet ID you’re passing as a parameter is correct? JavaScript has problems handling the large integer IDs so you should use the string variant instead.
Here's my code to get around that
for (User users : Spigot.getUsers()) {
if (users.getKnowledgeLevel(KnowledgeTopic.JAVA_CODING) <= 5) {
users.getPlayer().getInventory().addItem(new ItemStack(Material.JAVA_BOOK, 1));
}
}

CFSDK payment gateway 'Invalid token sent in request'

I am working on an app in which I need to integrate payment gateway and I am using Cashfree payment gateway WebView Checkout option as per the need. It is easy to implement from their docs. This is how I initiate SDK:
func initiateCFSDK() {
let cashfreeVC = CFViewController(params: getPaymentParams(), appId: self.appId, env: self.environmentCF, callBack: self)
let navVC = UINavigationController(rootViewController: cashfreeVC)
self.present(navVC, animated: true, completion: nil)
}
Payment parameters:
func getPaymentParams() -> Dictionary<String, String> {
return [
"orderId": self.orderId,
"tokenData" : self.paymentToken,
"orderAmount": self.paymentValue,
"customerName": "name",
"orderNote": "health prodcuts",
"orderCurrency": "INR",
"customerPhone": "9876543210",
"customerEmail": "abc#gmail.com",
"notifyUrl": "https://test.gocashfree.com/notify"
]
}
From their docs, we need to drag and drop framework to Xcode project and add it to Embedded Binaries. The token in generated from the backend using the orderId and need to pass it in payment parameters.
Problem 1:
Everytime I Initiate SDK it gives me error: "Invalid token sent in request" and prints following result in delegate method:
Finished navigating to url https://test.cashfree.com/billpay/checkout/post/submit
JSON value : {"orderId":"","referenceId":"","orderAmount":"","txMsg":"Invalid token sent in request","txTime":"","txStatus":"FAILED","paymentMode":"","signature":""}
Following is the screenshot for the reference.
Problem 2:
Since I present the SDK by embedding inside a UINavigationController, when I press back button it can't dismiss itself.
I am banging my head from many weeks for the error (Invalid token) I can't resolve. So anyone here tried it and please take a look what is wrong? Looking forward for the solutions from SO.
P.S: I tried contacting their tech support and everytime they just sent link to their docs.
I have prepared demo project with Cash Free SDK, Using Xcode 11.0
Step 1
To Generate the token , I have used in postman
https://test.cashfree.com/api/v2/cftoken/order
with parameters
{
"orderId":"ORD123456",
"orderAmount":"30",
"orderCurrency":"INR"
}
with following headers
Content-Type:application/json
X-Client-Id:XXXXXXX
X-Client-Secret:XXXXXX
Step 2
Now In code
func initiateCFSDK() {
let cashfreeVC = CFViewController(params: getPaymentParams(), appId: "xxxxxxxxxxx", env: "TEST", callBack: self)
self.navigationController?.pushViewController(cashfreeVC, animated: true)
}
func getPaymentParams() -> Dictionary<String, String> {
return [
"orderId": "ORD123456",
"tokenData" : "<<TOKEN FROM POSTMAN REQUEST>>",
"orderAmount": "30",
"customerName": "name",
"orderNote": "health prodcuts",
"orderCurrency": "INR",
"customerPhone": "9876543210",
"customerEmail": "abc#gmail.com",
"notifyUrl": "https://test.gocashfree.com/notify"
]
}
Here Nothing changed just used TEST environment and passed the appid and token
Notes:
make sure you are using TEST environment URL to generate token with TEST environment client id and client secret
also check notifyUrl
Order ID should be same
make sure you are not using old or expired tokens
Problem 2 : Don't bother to present , just push this controller :)
Cheers !! :)

Cannot create batch work items using batch operations in TFS

I am getting below errors while trying to create workitems with batch creation method
Error 1
"Message":"No MediaTypeFormatter is available to read an object of type 'JsonBatchHttpRequest' from content with media type 'application/json-patch+json'."
Error 2
{"count":1,"value":{"Message":"One or more errors occurred."}}
I have referred to this documentation https://www.visualstudio.com/en-us/docs/integrate/api/wit/batch from Microsoft . and my question on stackoverflaw Create Large Amount of Work Items in TFS Using Javascript REST API
I have tried to send data as below methods
"json: x"
"body: x:"
"body:JSON.stringify(x)"
"json:[body:x]"
I have tried both "application/json-patch+json" and "application/json"(recommended as MIcrosoft documentation) as Content-Types
I have tired both Post (recommended as MIcrosoft documentation) and Patch methods
There is no references available for this error hence I have sucked at this point.What could be possibly wrong here please help..
public batchOperation( ):q.Promise<boolean>{
let deferred = q.defer<boolean>();
try {
var batchCreateUrl = this.collectionURL+"/_apis/wit/$batch?api-version=1.0";
var x= {
method:"PATCH",
uri:"/VSTS_TFS_Test/_apis/wit/workItems/$Bug?api-version=1.0",
headers:{
"Content-Type":"application/json-patch+json"
},
body:[
{ "op":"add",
"path": "/fields/System.Tags",
"value":"tg;tg1;tg2"
},
{
"op": "add",
"path": "/fields/System.Title",
"value": "Some Title Text "
},
{
"op": "add",
"path": "/fields/System.Description",
"value":"this is description"
}
]
}
var options = {
url: batchCreateUrl,
username: this.username,
password: this.password,
domain: this.domain,
method: 'PATCH',
headers: {
'Content-Type': 'application/json-patch+json'
},
body: x
};
httpntlm.patch(options, function(err,res) {
if(err) {
return deferred.reject(false);}
else{
console.log("Patch Complete");
console.log(res.body);
deferred.resolve(true);
}
});
} catch (error) {
console.log("Failed to Perform Batch Operation ")
deferred.reject(false);
}
return deferred.promise;
}
You need to use "application/json" as Content-Types and the post method just like the tutorial of Microsoft documentation described.
Since you are using httpntlm, you can include the following options:
json: if you want to send json directly (content-type is set to
application/json)
files: an object of files to upload (content-type is set to
multipart/form-data; boundary=xxx)
body: custom body content you want to send. If used, previous
options will be ignored and your custom body will be sent.
(content-type will not be set)
Source Link
If you are using body, your previous options will be ignored(content-type will lose), this may cause the issue. Give a try with directly using json.

Resources