Iam trying to do the paypal payment.after completion of the payment how can we get the details of the transaction and how to get the success or failure response from paypal payment in angularjs?
Asked
Active
Viewed 432 times
-1
-
Possible duplicate of [Angular 2 paypal](http://stackoverflow.com/questions/39885352/angular-2-paypal) – Georg Grab Mar 15 '17 at 13:10
1 Answers
1
I'm using this PHP Code to make it. So, after you complete a transaction in Paypal, they will return to you a response, (even if the transaction was a failure). Just check the the parameter "ACK" at the array.
This response is an array with the informations about your transaction. If you want to confer the information of your transaction. Just use the method "GetTransactionDetails", and the paypal server will return you an array with all informations(you must the transaction ID to make your Query, not your token). Just adapt this code to angularJS
<?php
function verify_Transaction($idTrans,$show){
$nvp = array(
'METHOD' => 'GetTransactionDetails',
'VERSION' => '124.0',
'PWD' => 'YOUR PASS',
'USER' => 'YOUR USER',
'SIGNATURE' => 'YOUR SIGNATURE' ,
'TRANSACTIONID' => yourTransactionID
);
$curl = curl_init();
curl_setopt( $curl , CURLOPT_URL , 'https://api-3t.sandbox.paypal.com/nvp' );
curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
curl_setopt( $curl , CURLOPT_POST , 1 );
curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );
$response = urldecode( curl_exec( $curl ) );
$responseNvp = array();
if ( preg_match_all( '/(?<name>[^\=]+)\=(?<value>[^&]+)&?/' , $response , $matches ) ) {
foreach ( $matches[ 'name' ] as $offset => $name ) {
$responseNvp[ $name ] = $matches[ 'value' ][ $offset ];
}
}
if($show){
echo '<pre>';print_r($responseNvp);echo'</pre>';
}
if($responseNvp['ACK']=='Success'){
//echo "true";
return true;
}else{
//echo "false";
return false;
}
}
?>

Igor Santos de Lima
- 177
- 1
- 10