Reputation: 457
here is the user scenario:
"John have 5 virtual credits with his account in a website, he can convert his virtual credits into real money by cliking a button in the website. The website will then give him the real money throught paypal, wether John has a paypal account or not."
I would like to know if it is possible to put this scenario in place ?
Of course for security reasons, i'll check in the server side all the data needed in order to safely do the operation.
Can it be automatized without any action from the admin of the website ?
Thank you for your answers !
EDIT:
I've found this post : https://www.x.com/devzone/articles/using-adaptive-payments-disburse-cash-prizes-real-time-easter-eggs
I'll try to adapt it for my scenario. I'll update my post today when i have finished the integration.
EDIT 2:
Everything seems to be ok, but i try to get an app ID from www.x.com they are questionning me about how i'm using the API:
Hi and Thank You for your Submission,
Before we can proceed with our review, can you clarify the API's you require please?
Can you clarify your use of ‘Implicit Payments’ which would be used to pay your users from your PayPal account? If this is not required, please deselect it from the ‘Services used by App’ -- ’Adaptive Payments’ -- ’Basic Payments’ section of your submission
You have also selected Preapprovals which is an advanced API requiring an in-depth review. This would be used to create a Billing Agreement with your customers (as in a ‘Subscription’ business model). If this is required, please complete the ‘Preapproval Terms’ field and let us know how we can test the Preapproved payment flow on your site. If it is not required, please deselect it from the ‘Services used by App’ -- ’Adaptive Payments’ section of your submission.
Note: You will need to click the App Name in the ‘My Apps’ section of x.com in order to expand and edit the fields of your submission form.
What should i do ?
EDIT 3:
Ok I had the benediction of Paypal now i can use the API with live credentials ! I've unchecked Preapprovals and everything went well.
Last question but not the least:
How can i configure my Adaptive payment in order to change the payment in pending process and give the choice to the vendor to validate the payment?
Here is the Use Case to better understand the situation:
"John want to convert 5 virtual credits into 5$, he click the withdrawal button and the webapplication sends him automatically the real money on his paypal account. Dr house want to convert 100 virtual credits into 100$, this amount needs the approval of the admin, this admin goes into his paypal account and check if everything is ok he confirm the payment, then Dr House will get his money!"
I've found this option:
$PayRequestFields = array(
'ActionType' => 'PAY', // Required. Whether the request pays the receiver or whether the request is set up to create a payment request, but not fulfill the payment until the ExecutePayment is called. Values are: PAY, CREATE, PAY_PRIMARY
If a change the value PAY into the value CREATE, it doesn't do anything.
Faithfully !
Upvotes: 4
Views: 1919
Reputation: 360
I got it working in sandbox mode with this code, haven't tried live yet:
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var request = (HttpWebRequest)WebRequest.Create("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay");
request.ContentType = "application/json";
request.Method = "POST";
request.Headers.Add("X-PAYPAL-SECURITY-USERID", apiUsername);
request.Headers.Add("X-PAYPAL-SECURITY-PASSWORD", apiPassword);
request.Headers.Add("X-PAYPAL-SECURITY-SIGNATURE", apiSig);
request.Headers.Add("X-PAYPAL-APPLICATION-ID", "APP-80W284485P519543T"); // sandbox app id
request.Headers.Add("X-PAYPAL-REQUEST-DATA-FORMAT", "JSON");
request.Headers.Add("X-PAYPAL-RESPONSE-DATA-FORMAT", "JSON");
JObject j = new JObject();
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
string json = "{ \"actionType\": \"PAY\", \"currencyCode\": \"GBP\", \"useCredentials\": \"FALSE\", \"senderEmail\": \"[email protected]\",\"ipnNotificationUrl\": \"http://example.com/IPN.aspx\", \"receiverList\": {\"receiver\": [{\"amount\": \"1.00\", \"email\": \"[email protected]\" }] }, \"returnUrl\": \"http://example.com/thanks.aspx\", \"cancelUrl\": \"http://example.com/cancel.aspx\", \"requestEnvelope\": { \"errorLanguage\": \"en_US\", \"detailLevel\": \"ReturnAll\" }}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)request.GetResponse();
string sResult = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
sResult = streamReader.ReadToEnd();
}
A few things to look out for:
This makes an automated payment from your account to a recipient that doesn't need you to log in to authorise it.
Upvotes: 0
Reputation: 7319
You could set this up to be automated. If your specifically wanting to use Adaptive Payments, you would want to use the Adaptive Payments Pay API to send the money to John. However, John would need a PayPal in order to access the money and with draw the funds.
Upvotes: 2