Using the PAYPAL REST API, I was able to successfully (1) Vault a credit card and (2) Lookup the vaulted credit card information.
After you lookup the Vaulted Credit Card and receive Paypal's response; however, do you re-use that response data to create a transaction in the future?
#How to Look up the Vaulted Credit Card
curl -v [link removed]/CARD-8TT93830P06829326KIOO3XI -H "Content-Type:application/json" -H "Authorization:Bearer O912TKmsB8WRsgdNrNrJAmlCqF5kLdEl.re3z4Kmp8M"
#Paypal's Response to the Lookup Request
{"id":"CARD-8TT93830P06829326KIOO3XI","valid_until":"2016-08-26T00:00:00Z","state":"ok","payer_id":"user12345","type":"visa","number":"xxxxxxxxxxxx0331","expire_month":"11","expire_year":"2018","first_name":"Joe","last_name":"Shopper","links":[{"href":"[link removed]/CARD-8TT93830P06829326KIOO3XI","rel":"self","method":"GET"},{"href":"[link removed]/CARD-8TT93830P06829326KIOO3XI","rel":"delete","method":"DELETE"}]}
I am looking for a curl command that would allow me to use the Vaulted Credit Card to bill monthly.
You would use the same /payment call, but switch out the card data for the credit_card_id.
For example;
{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card_token": {
"credit_card_id": "CARD-XXXXXXXXXXXXXX"
}
}
]
},
"transactions": [
{
"amount": {
"total": "7.47",
"currency": "USD"
},
"description": "This is the payment transaction description."
}
]
}
Or in cURL:
curl -v https://api.sandbox.paypal.com/v1/payments/payment -X POST -H "Content-Type:application/json" -H "Authorization:Bearer xxxxxxxxx" -d '{"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card_token":{"credit_card_id":"CARD-9ND477057R590115SKIOT7OY"}}]},"transactions":[{"amount":{"total":"7.47","currency":"USD"},"description":"This is the payment transaction description."}]}'
There is some more information about this in the docs as well.
Related
I am trying to complete a checkout with the /checkout API integrated with Stripe, following this documentation: https://shopify.dev/tutorials/complete-a-sales-channel-payment-with-checkout-api#integrate-stripe-wi...
I am getting this response on my final request:
Request:
curl --location --request POST 'https://<nameofmyshop>.myshopify.com/admin/api/2021-04/checkouts/<shopify-checkout-token>/complete.json' \
--header 'Content-Type: application/json' \
--header 'X-Shopify-Access-Token: <shpat_shopify-access-token>' \
--data-raw '{
"payment": {
"amount": "1.00",
"unique_token": "unique token I made",
"payment_token": {
"payment_data": "<tok_stripe-vault-token>",
"type": "stripe_vault_token"
},
"request_details": {
"ip_address": "123.1.1.1",
"accept_language": "en",
"user_agent": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/54.0.2840.98 Safari\/537.36"
}
}
}'
(error) Response:
422 Unprocessable Entity
{
"errors": {
"base": [
{
"code": "missing_transactions",
"message": "Cannot complete the checkout without any transactions.",
"options": {}
}
]
}
}
Some details about my Shopify Shop, and Stripe setup:
I have Shopify Payments enabled
test mode is on
I successfully placed an order though the shop's website with CC# 4242 4242 4242 4242
I have a test Stripe Connect account for my "customer"
I can successfully get a Stripe token generated for the customer
Here is my flow:
create a checkout POST https://{{store_name}}.myshopify.com/admin/api/{{api_version}}/checkouts.json
Save checkout.token, and checkout.shopify_payments_account_id from the response
Get Stripe token for customer:
curl --location --request POST 'https://api.stripe.com/v1/tokens' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Stripe-Account: {{shopify_payments_account_id}}' \
--header 'Authorization: Bearer {{stripe-token}}' \
--data-urlencode 'customer=<cus_customers-stripe-connect-id>'
save id from response "id: <tok_stripe-vault-token>"
complete checkout with Stripe token (request above)
Should we be able to complete a checkout using Shopify /checkout API + Stripe-Connect Test Accounts?
Thank you for any help!
I was using the wrong endpoint:
final request should go to /payments.json, not /complete.json
url --location --request POST 'https://<nameofmyshop>.myshopify.com/admin/api/2021-04/checkouts/<shopify-checkout-token>/payments.json' \
--header 'Content-Type: application/json' \
--header 'X-Shopify-Access-Token: <shpat_shopify-access-token>' \
--data-raw '{
"payment": {
"amount": "1.00",
"unique_token": "unique token I made",
"payment_token": {
"payment_data": "<tok_stripe-vault-token>",
"type": "stripe_vault_token"
},
"request_details": {
"ip_address": "123.1.1.1",
"accept_language": "en",
"user_agent": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/54.0.2840.98 Safari\/537.36"
}
}
}'
In Sandbox, the logged-in user needs to be a member of a group to register data products or apps.
How can I add my user to a group?
You, as user, are an identity of type Person. A Group is also a type of identity in Platform of Trust.
A Person must be linked to a Group with MemberOf type of link.
Using Identity API, you can create a Group type identity and connect your own user identity to the group with a MemberOf type link.
To create a group, run the following cURL command:
curl -i -X POST \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9eyJzY29w...DVs5aaf" \
-H "Content-Type: application/json" \
-d \
"{
"context": "https://standards.oftrust.net/v2/Context/Identity/Group/",
"type": "Group",
"data": {
"name": "Company Oy"
}
}" "https://api-sandbox.oftrust.net/identities/v1"
On Success, you'll get the following response including the ID of the created group.
Next, you need to link your user identity to the created group identity with a MemberOf type link.
option1: This post in StackOverflow discusses how to obtain the current logged-in user's ID.
OR,
option2:
Start with getting your user ID (you need to be logged-in into the Sandbox) using /me end
point of Login API
Request:
curl -i -X GET \
-H "Authorization: Bearer eyJ0eXAi...hdEsJLNGV2YA" \
"https://api-sandbox.oftrust.net/me"
Response:
HTTP/1.0 200
{
"#context": "https://standards.oftrust.net/v2/Context/Identity/LegalParty/Person/",
"#type": "Person",
"#id": "33237067-14c3-4801-9e50-bf08406406e2",
"email": "user#example.com",
"role": "developer",
"firstName": "Anna",
"lastName": "Bar"
}
Then make a POST request to Identity API with Identity IDs of your user and the created group as parameters:
curl -i --request POST \
--url https://api-sandbox.oftrust.net/identities/v1/{fromIdentityId}/link/{toIdentityId} \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9eyJzY29w...DVs5aaf' \
--header 'content-type: application/json' \
--data '{
"context": "https://standards.oftrust.net/v2/Context/Link/Role/MemberOf/",
"type": "MemberOf"
}'
Remember to set the parameters as the following:
fromIdentityId = ID of your own user
toIdentityID = ID of the created group above.
On success, you should receive the following response:
HTTP/1.0 201
{
"#context": "https://standards.oftrust.net/v2/Context/Link/Role/MemberOf/",
"#type": "MemberOf",
"#id": "be7a2c57-03d8-46f4-aaf0-2b1ca118ef5c",
"from": "8ac7494b-b7bc-4a63-a253-4b9b1887b262",
"to": "a6b5a74e-bd98-4c9b-9561-932877258833",
"data": {},
"metadata": {
"createdAt": "2019-09-12T09:49:24+00:00",
"createdBy": "33237067-e72c-4f26-b78b-9f9e234b2e7d",
"updatedAt": "2019-09-12T09:49:24+00:00",
"updatedBy": "33237067-e72c-4f26-b78b-9f9e234b2e7d"
}
}
Now you will bee able to use the created group to register data products and apps in Platform of Trust.
Alternatively, you can use world-sandbox.oftrust.net to create your group identity using the UI. Simply save the group ID that appears in the S-alert.
Checkout Identity API documentation here.
You can also use our Insomnia Workspace and Guide to execute chain request to create a Group.
I am using BigQuery Connector in WSO2 to insert multiple records in BigQuery cloud.
I followed this link and was able to insert a single record successfully.
First I tried to pass multiple records by separating them using a comma.
However, in this case, only the first record gets inserted and other records are skipped.
Please note that no error is returned in this case.
My Json message with multiple records:
{"insertId":"101","json":{"NAME":"Vishal_101","ADDRESS":"UK","ID":"vbordia"}},{"insertId":"102","json":{"NAME":"Vishal_102","ADDRESS":"UK","ID":"vbordia"}}
Second I tried this link which explain how to build multiple records.
However, this time I get an invalid response from BigQuery. Since the response message is not well explanatory I am unable to understand the cause.-
Messagean :
{
"rows":
[
{
"insertId":"209",
"json":
{
"NAME": "NewRow1",
"ADDRESS": "NewAddr",
"ID": "123"
}
},
{
"insertId":"210",
"json":
{
"NAME": "NewRow2",
"ADDRESS": "NewAddr",
"ID": "123"
}
}
]
}
Error Message Returned from BigQuery :
{
"insertErrors": [
{
"index": 0,
"errors": [
{
"reason": "invalid",
"location": "",
"debugInfo": "",
"message": ""
}
]
}
]
}
Can anyone please help me here.What is the correct way of inserting multiple records in BigQuery via Wso2.
Thanks in advance.
This was a bug in WSO2 Bigquery connector. We have raised with WSO2 and they have now released new version of connector which is capable of inserting multiple records.You can find the latest version at WSO2 market place.
Based on your data I created a test table in my project
And used the API to upload your example data as follow:
curl --request POST \
'https://www.googleapis.com/bigquery/v2/projects/myproject/datasets/dataset/tables/testInsert/insertAll' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"rows":[{"insertId":"z1","json":{"NAME":"Vishal_z1","ADDRESS":"UK","ID":"vbordia"}},{"insertId":"z2","json":{"NAME":"Vishal_z2","ADDRESS":"UK","ID":"vbordia1"}}]}' \
--compressed
using this SELECT:
SELECT * FROM `project.dataset.testInsert` LIMIT 1000
I confirmed the data is in the table:
Using v2 of the API via: http://gdata.youtube.com/schemas/2007/categories.cat, I can see both assignable and deprecated video categories.
However, using the v3 google data API, I see all categories, but no flag indicating if they are usable as a category on a video upload. Case in point is the category labelled "Anime/Animation" (category 31). If you try to upload a video using this category, you will receive a "Bad Request" response from YT at the end of the upload process.
If you choose any of the categories in the "assignable" list as per the first URL, then the upload works. Here's a deprecated category using the Atom based API:
<atom:category term="Movies_anime_animation" label="Anime/Animation" xml:lang="en-US">
<yt:deprecated/>
</atom:category>
Here's the same thing, in JSON, from the Google API Explorer:
{
"id": "31",
"kind": "youtube#videoCategory",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/-p_eJg3ji5PiNMcZrzS4hNfl4gQ\"",
"snippet": {
"channelId": "UCBR8-60-B28hp2BmDPdntcQ",
"title": "Anime/Animation"
}
I've looked at the video.list v3 API docs, and also the raw JSON output from the same API. I can't see how I could differentiate between deprecated and assignable categories. Is this just plain missing from the API or have I missed something?
You can receive the list of assignable categories parsing XML document. This is an example on PHP:
$catURL = 'http://gdata.youtube.com/schemas/2007/categories.cat';
$cxml = simplexml_load_file($catURL);
$cxml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
$result = $cxml->xpath('//atom:category/yt:assignable/..');
$categories = array();
foreach ($result as $row) $categories[(string)$row['term']] = (string)$row['label'];
For anyone who stumbles upon this question: YouTube V3 API now returns an assignable flag with each category snippet.
Request
curl \
'https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode=NL&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Response
{
"kind": "youtube#videoCategory",
"etag": "7mqChSJogdF3hSIL-88BfDE-W8M",
"id": "17",
"snippet": {
"title": "Sports",
"assignable": true,
"channelId": "UCBR8-60-B28hp2BmDPdntcQ"
}
}
I'm new in rest api and i'm trying to use the api rest to associate file to object:
curl -X POST \
-H "X-Parse-Application-Id: qS0KL*9lFLE**S3VMk" \
-H "X-Parse-REST-API-Key: nh3***MhcKJIfIt1Gm" \
-H "Content-Type: application/json" \
-d '{
"name": "Andrew",
"picture": {
"name": "...profile.png",
"__type": "File"
}
}' \
https://api.parse.com/1/classes/PlayerProfile
Can anyone explain me how to set the ajax call?And what is "name":"andrew"?Is this a column named andrew in my player profile?
This is my implementation of api,but the server responded me bad request 400:
$.ajax({
type: 'POST',
headers: {'X-Parse-Application-Id':'qS0KLMx5h9lFLG**yhM9EEPiTS3VMk','X-Parse-REST-API-
Key':'nh3G8D**hcKJIfIt1Gm','Content-Type': 'application/json'},
url: "https://api.parse.com/1/users",
data: {
"username": "francesco",
"picture": {
"name": "b3b47ce2-62dc-4861-a0ad-79cfffe9b07a-foto ste.jpg",
"__type": "File"
}
},
contentType: "application/json",
success: function(data) {
console.log(data );
},
error: function(data) {
console.log("ko" );
}
});
May the api -d is wrong in my implementation.What's means -d in curl?
The example in the guide shows how you can create a new PlayerProfile object and associate it with a File in a single request. Since you want to update an existing User (and not create a new one), you'll need to use the Update REST API request format. Use PUT instead of POST, then specify which user you're referring to by appending the object id to the endpoint URL: https://api.parse.com/1/users/{objectId}.