Reputation: 43
I´m very new to the Integration of Paypal within an App so I have several questions. (I have just to implement the serversided scripts with PHP ...)
Do I understand the payment process right?:
My Questions:
I. The compamy programing the app told me that I´ll get a payment_id to look up the payment details, then I´ll have to "capture" the payment and then process the order. What does "capture" mean?? If I recive a proof of payment, the payment is allready done, so what should I have to capture??
II. I try to get payment details with following script, but I only recive an Error:
$curl = curl_init("https://api.sandbox.paypal.com/v1/payments/payment/" . $payment_id);
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $api_key,
'Accept: application/json',
'Content-Type: application/json'
));
$response = curl_exec($curl);
$result = json_decode($response);
print_r($result);
the Error:
stdClass Object
(
[name] => INTERNAL_SERVICE_ERROR
[message] => An internal service error has occurred
[information_link] => https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR
[debug_id] => 950d09d5a33e1
)
III. Do I hav to authorize this proof of payment, or can I change it if there is any mistake?
Thanks in advance.
Upvotes: 1
Views: 93
Reputation: 12341
The process for almost all types of online payment don't really differ much (implementation details may vary, but in the end):
Authorization
to hold funds which you will need to Capture
(finalize, complete, etc.) at some point. Some flows do this in one step (auth + capture), others are required to capture later (upon fulfillment of product/service).authorization
request good? Or not?capture
request good? Or not?Paying with a Paypal account adds additional steps because you have to ask the user for access to their Paypal account/funding instruments. So that request
goes through the same flow -
With all the above flows, you'll find data - e.g. payment_id
, payer_id
etc. that refer to items you need to complete the flow (you can infer what they are just by the names).
The most important part: You have to go through developer documentation and really understand all the details - for obvious reasons. Don't do things "piecemeal". These are flows that impact revenue for whomever you are doing this for. Paypal has SDKs with samples as well. Use them.
It's easy to code, but if you don't grasp what you're coding towards, it won't be pretty...
Upvotes: 1