Sending payment using PayPal from my app's users - paypal

I would like to create an app where users would authorize my app with their PayPal account and then my app would be able to send payments to other PayPal users in their name without them having to do anything anymore (imagine background cron payments). I was looking at PayPal APIs but it seems that most APIs are meant to be used in a way that app is a receiver or sender of money, and not that app just coordinates sending or receiving money for its users, or that user has to be in a loop because protocol with redirect to PayPal for user's confirmation.
Is there a PayPal API for this?

It sounds like you're describing a third party Mass Pay. Mass pay would take money from their PayPal account and send it to another account. For your part, you would need third party authorization for each account they wanted to send from. This would require them to authorize your API username. MassPay doesn't require them to subscribe to anything (you pay when you use it).

You can use this api:
"Use the Pay API operation to transfer funds from a sender's PayPal account to one or more receivers' PayPal accounts"
https://developer.paypal.com/docs/classic/api/adaptive-payments/Pay_API_Operation/
Example, Preapproved payment example:
"In this example, the sender has a valid preapproval agreement with you and makes a payment of $100 to a PayPal-registered receiver and $50 to another PayPal-registered receiver. The payment is completed without the sender logging in to paypal.com."
curl https://svcs.sandbox.paypal.com/AdaptivePayments/Pay \
-s \
--insecure \
-H "X-PAYPAL-SECURITY-USERID: api_username" \
-H "X-PAYPAL-SECURITY-PASSWORD: api_password" \
-H "X-PAYPAL-SECURITY-SIGNATURE: api_signature" \
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" \
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" \
-H "X-PAYPAL-APPLICATION-ID: app_id" \
-d actionType=PAY \
-d cancelUrl=http://your_cancel_url \
-d currencyCode=USD \
-d feesPayer=EACHRECEIVER \
-d memo=Preapproval-payment-example \
-d preapprovalKey=PA-9JR04288NR0519129 \
-d receiverList.receiver(0).amount=100.00 \
-d receiverList.receiver(0).email=receiver1#domain \
-d receiverList.receiver(0).primary=false \
-d receiverList.receiver(1).amount=50.00 \
-d receiverList.receiver(1).email=receiver2#domain/em> \
-d receiverList.receiver(1).primary=false \
-d requestEnvelope.errorLanguage=en_US \
-d returnUrl=http://your_return_url \
-d reverseAllParallelPaymentsOnError=true \
-d senderEmail=sender#domain
Edited:
How to Set Up a Payment Preapproval Using Adaptive Payments,
https://developer.paypal.com/docs/classic/adaptive-payments/ht_ap-basicPreapproval-curl-etc/

You can do this with PayPay's Adaptive Payments API.
https://developer.paypal.com/webapps/developer/docs/classic/products/adaptive-payments/
You can enable "Funds Transfer within a Group" and allow "person-to-person" payments. Pretty cool stuff.
https://developer.paypal.com/docs/classic/use-cases/uc_social-transfers-within-group/

Related

How to accept an invitation automatically to a GitHub repository?

Monthly I receive several invitations to be a collaborator of several Github repositories, unfortunately sometimes I miss the 7 days time to accept the invitations and as a consequence the invitations expire, making it impossible for me to access the repositories
I have tried to automate the invitations through GitHubActions but there is no such option.
Please, does anyone know how I can automate the acceptance of the invitations, so they will not expire after 7 days, which is the maximum time that Github grants before the invitations expire?
I have tried to automate the invitations through GitHubActions but there is no such option.
You can test out the GitHub Action kbrashears5/github-action-auto-accept-collabs which should auto accept all collaboration invites.
It does:
get all repository invites for [${USERNAME}]
curl -X GET -H "Accept: application/vnd.github.v3+json" -u ${USERNAME}:${GITHUB_TOKEN} \
--silent ${GITHUB_API_URL}/user/repository_invitations | \
jq '.[].id'
Accept each invite:
curl -d #- \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-u ${USERNAME}:${GITHUB_TOKEN} \
--silent \
${GITHUB_API_URL}/user/repository_invitations/${invite}

How to Star a Topic on GitHub with API?

Star a topic can be done on the website. But how to do the same operation via GitHub API v3 or v4? I read through the reference but got no clues.
For the v3 REST API it's documented at Star a repository for the authenticated user
The curl example is:
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/starred/octocat/hello-world
But this doesn't show how to insert your token, so you actually need something more like:
curl \
-X PUT \
-H "Authorization: token $GITHUB_API_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/starred/octocat/hello-world
Where GITHUB_API_TOKEN has been previously set like:
GITHUB_API_TOKEN="ghp_16C7e42F292c6912E7710c838347Ae178B4a"
Per comments to this earlier question how to star a repo with github api make sure that the token used has the correct permissions to do the starring, which means having the repo scope (or at least repo_public) enabled.
I'd also love to know how to do this with the v4 GraphQl API.

Paypal Direct Payments Api Arguments

I am trying to access the Paypal Direct Payements Api using cURL and I get this response:
TIMESTAMP=2020%2d11%2d25T10%3a53%3a01Z&CORRELATIONID=7877664ffef0b&ACK=Failure&L_ERRORCODE0=10004&L_SHORTMESSAGE0=Invalid%20Request%20Error%2e&L_LONGMESSAGE0=Transaction%20refused%20because%20of%20an%20invalid%20argument%2e
An this is the cURL statement minus the credentials:
curl https://api-3t.sandbox.paypal.com/nvp --insecure -d VERSION=56.0 -d SIGNATURE=hidden -d USER=hidden -d PWD=hidden -d METHOD=DoDirectPayment -d PAYMENTACTION=Sale -d IPADDRESS= -d AMT=8.88 -d CREDITCARDTYPE=Visa -d ACCT=4032032245382681 -d EXPDATE=10/2021 -d CVV2=283 -d FIRSTNAME=John -d LASTNAME=Doe -d STREET=MohlalaRd -d CITY=Nelspruit -d STATE=Mpumalanga -d ZIP=1201 -d COUNTRYCODE=ZA
EXPDATE=10/2021
This is the invalid argument, format is MMYYYY
DoDirectPayment requires a live PayPal Payments Pro account for use in live and is an old API, you should not be using it in new integrations. Also version 56 is an extremely old version of the classic NVP API. If you were to be integrating something like this with a classic API (which you should not be doing), you would at the very least want to use a reasonably recent version such as 202.
See Advanced Credit and Debit Card Payments instead, or use Braintree if you need a gateway.

How to authenticate user in keycloak using challenge response system while using its admin api

i m using keycloak 8.0 and i m looking to authenticate user by calling it admin api. Below is the curl command .
curl -X POST \
http://localhost:8180/auth/realms/quickstart-serv-springboot/protocol/openid-connect/token \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Postman-Token: abf5c8bf-0d1f-4178-951d-ba6c9d385596' \
-d 'client_id=wb-auth-url-demo&username=admin-wb-auth-url-demo&password=admin&grant_type=password&client_secret=a3ffca99-e0b7-49d2-8369-b9eb15385b60'
This approach looks at sending password in clear text to keycloak server but i m looking to use challenge response system which comapres hashvalue of the password for the user. How can i do this using the admin apis ?

Obtaining JWT of a user in Keycloak

As admin of a Keycloak server, how can I obtain access-token of a particular user without knowing his password? Unfortunately impersonation doesn't help me because it does not contain neither his id nor his username.
There's a feature starting from keycloak 3.4.0 called token exchange wich allows you to exchange an access token from a user with impersonation permission to get other token on behalf of the other user. You can use the token endpoint this way:
curl -X POST \
-d "client_id=starting-client" \
-d "client_secret=geheim" \
--data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \
-d "subject_token=...." \
--data-urlencode "requested_token_type=urn:ietf:params:oauth:token-type:access_token" \
-d "audience=target-client" \
-d "requested_subject=wburke" \
http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/token
You might find this post useful too.