public function details()
 {
     $logger = new PPLoggingManager('PaymentDetails');
     // ##PaymentDetailsRequest
     // The code for the language in which errors are returned, which must be
     // en_US.
     $requestEnvelope = new RequestEnvelope("en_US");
     // PaymentDetailsRequest which takes,
     // `Request Envelope` - Information common to each API operation, such
     // as the language in which an error message is returned.
     $paymentDetailsReq = new PaymentDetailsRequest($requestEnvelope);
     // You must specify either,
     //
     // * `Pay Key` - The pay key that identifies the payment for which you want to retrieve details. This is the pay key returned in the PayResponse message.
     // * `Transaction ID` - The PayPal transaction ID associated with the payment. The IPN message associated with the payment contains the transaction ID.
     // `paymentDetailsRequest.setTransactionId(transactionId)`
     // * `Tracking ID` - The tracking ID that was specified for this payment in the PayRequest message.
     // `paymentDetailsRequest.setTrackingId(trackingId)`
     $paymentDetailsReq->payKey = "AP-86H50830VE600922B";
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new AdaptivePaymentsService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->PaymentDetails($paymentDetailsReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " . $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters in
     // response object as shown below
     // ### Success values
     if ($response->responseEnvelope->ack == "Success") {
         // The status of the payment. Possible values are:
         //
         // * CREATED - The payment request was received; funds will be
         // transferred once the payment is approved
         // * COMPLETED - The payment was successful
         // * INCOMPLETE - Some transfers succeeded and some failed for a
         // parallel payment or, for a delayed chained payment, secondary
         // receivers have not been paid
         // * ERROR - The payment failed and all attempted transfers failed
         // or all completed transfers were successfully reversed
         // * REVERSALERROR - One or more transfers failed when attempting
         // to reverse a payment
         // * PROCESSING - The payment is in progress
         // * PENDING - The payment is awaiting processing
         $logger->log("Payment Status : " . $response->status);
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     return $response;
 }
示例#2
0
function invoice_details_callback()
{
    if (isset($_POST['inv_id']) && !empty($_POST['inv_id'])) {
        $invid = explode(",", $_POST['inv_id']);
        require_once 'paypal-invoice/PayPalInvoiceAPI.php';
        require_once 'paypal-invoice/credentials.php';
        //NOTE: edit this file with your info!
        $pAPI = new PayPalInvoiceAPI($api_username, $api_password, $api_signature, $app_id);
        foreach ($invid as $inv_id) {
            //update_post_meta( $inv_id, 'auction_active_pay_method', 'invoice' );
            $invoice_id = get_post_meta($inv_id, 'paypal_invoice_id', true);
            $invoice_data = $pAPI->getInvoiceDetails($invoice_id);
            $invoice_stat = '';
            if ($invoice_data['responseEnvelope.ack'] == "Success") {
                $invoice_stat = isset($invoice_data['invoiceDetails.status']) ? $invoice_data['invoiceDetails.status'] : '';
            } else {
                $invoice_stat = __('Failed to connect with PayPal account. Please verify your PayPal credentials or just reload this page.', 'wdm-ultimate-auction');
            }
            if (!empty($invoice_id)) {
                update_post_meta($inv_id, 'auction_invoice_status', $invoice_stat);
            }
        }
    }
    if (isset($_POST['adp_id']) && !empty($_POST['adp_id'])) {
        require_once 'paypal-adaptive/PPBootStrap.php';
        $adpid = explode(",", $_POST['adp_id']);
        foreach ($adpid as $adp_id) {
            //update_post_meta( $adp_id, 'auction_active_pay_method', 'adaptive' );
            $requestEnvelope = new RequestEnvelope("en_US");
            $paymentDetailsReq = new PaymentDetailsRequest($requestEnvelope);
            $payKey = get_post_meta($adp_id, 'paypal_invoice_id', true);
            if ($payKey != "") {
                $paymentDetailsReq->payKey = $payKey;
            }
            //if($_POST['transactionId'] != "") {
            //	$paymentDetailsReq->transactionId = $_POST['transactionId'];
            //}
            //if($_POST['trackingId'] != "") {
            //	$paymentDetailsReq->trackingId = $_POST['trackingId'];
            //}
            $service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
            try {
                /* wrap API method calls on the service object with a try catch */
                $response = $service->PaymentDetails($paymentDetailsReq);
            } catch (Exception $ex) {
            }
            update_post_meta($adp_id, 'paypal_trans_timestamp', $response->responseEnvelope->timestamp);
            $ack = strtoupper($response->responseEnvelope->ack);
            $pay_stat = '';
            if ($ack != "SUCCESS") {
                $pay_stat = __('Failed to connect with PayPal account. Please verify your PayPal credentials or just reload this page.', 'wdm-ultimate-auction');
            } else {
                $pay_stat = $response->status;
            }
            if (!empty($payKey)) {
                if (strtoupper($pay_stat) == 'CREATED') {
                    update_post_meta($adp_id, 'auction_invoice_status', 'Sent');
                } elseif (strtoupper($pay_stat) == 'COMPLETED') {
                    update_post_meta($adp_id, 'auction_invoice_status', 'Paid');
                } else {
                    update_post_meta($adp_id, 'auction_invoice_status', $pay_stat);
                }
            }
        }
    }
    die;
}
 public function paypalstatus()
 {
     $request = Requests::find(Session::get('request_id'));
     $requestEnvelope = new RequestEnvelope("en_US");
     $paymentDetailsRequest = new PaymentDetailsRequest($requestEnvelope);
     $paymentDetailsRequest->payKey = "AP-2K156847LU642333B";
     $sdkConfig = array("mode" => Config::get('app.paypal_sdk_mode'), "acct1.UserName" => Config::get('app.paypal_sdk_UserName'), "acct1.Password" => Config::get('app.paypal_sdk_Password'), "acct1.Signature" => Config::get('app.paypal_sdk_Signature'), "acct1.AppId" => Config::get('app.paypal_sdk_AppId'));
     $adaptivePaymentsService = new AdaptivePaymentsService($sdkConfig);
     $paymentDetailsResponse = $adaptivePaymentsService->PaymentDetails($paymentDetailsRequest);
     Log::info('paymentDetailsResponse = ' . print_r($paymentDetailsResponse, true));
     Log::info('payKey = ' . print_r($paymentDetailsResponse->{'payKey'}, true));
     $request->payment_id = $paymentDetailsResponse->{'payKey'};
     $request->is_paid = 1;
     $request->save();
     return Redirect::to('/user/request-trip');
 }
}
if ($_POST['transactionId'] != "") {
    $paymentDetailsReq->transactionId = $_POST['transactionId'];
}
if ($_POST['trackingId'] != "") {
    $paymentDetailsReq->trackingId = $_POST['trackingId'];
}
/*
* 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $response = $service->PaymentDetails($paymentDetailsReq);
} catch (Exception $ex) {
    require_once 'Common/Error.php';
    exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>PayPal Adaptive Payments - Payment Details</title>
<link href="Common/sdk.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Common/sdk_functions.js"></script>
</head>

<body>
	<div id="wrapper">
示例#5
0
 public function getPaymentDetail($paykey)
 {
     /*
     *  # PaymentDetails API
     Use the PaymentDetails API operation to obtain information about a payment. You can identify the payment by your tracking ID, the PayPal transaction ID in an IPN message, or the pay key associated with the payment.
     This sample code uses AdaptivePayments PHP SDK to make API call
     */
     /*
     * 
     				 PaymentDetailsRequest which takes,
     				 `Request Envelope` - Information common to each API operation, such
     				 as the language in which an error message is returned.
     */
     $requestEnvelope = new RequestEnvelope("en_US");
     /*
     * 		 PaymentDetailsRequest which takes,
     				 `Request Envelope` - Information common to each API operation, such
     				 as the language in which an error message is returned.
     */
     $paymentDetailsReq = new PaymentDetailsRequest($requestEnvelope);
     /*
     * 		 You must specify either,
     				
     				 * `Pay Key` - The pay key that identifies the payment for which you want to retrieve details. This is the pay key returned in the PayResponse message.
     				 * `Transaction ID` - The PayPal transaction ID associated with the payment. The IPN message associated with the payment contains the transaction ID.
     				 `paymentDetailsRequest.setTransactionId(transactionId)`
     				 * `Tracking ID` - The tracking ID that was specified for this payment in the PayRequest message.
     				 `paymentDetailsRequest.setTrackingId(trackingId)`
     */
     if ($paykey != "") {
         $paymentDetailsReq->payKey = $paykey;
     }
     /*if($_POST['transactionId'] != "") {
     			$paymentDetailsReq->transactionId = $_POST['transactionId'];
     		}
     		if($_POST['trackingId'] != "") {
     			$paymentDetailsReq->trackingId = $_POST['trackingId'];
     		}*/
     /*
     * 	 ## Creating service wrapper object
     		Creating service wrapper object to make API call and loading
     		Configuration::getAcctAndConfig() returns array that contains credential and config parameters
     */
     $service = new AdaptivePaymentsService($this->getAcctAndConfig());
     try {
         /* wrap API method calls on the service object with a try catch */
         $response = $service->PaymentDetails($paymentDetailsReq);
     } catch (Exception $ex) {
         return (object) array("success" => false);
         exit;
     }
     $ack = strtoupper($response->responseEnvelope->ack);
     if ($ack != "SUCCESS") {
         return (object) array("success" => false);
     } else {
         return (object) array("success" => true, "detail" => $response);
     }
 }