Example #1
0
* `CompleteCode` - Indicates whether or not this is your last capture.
It is one of the following values:
* Complete – This is the last capture you intend to make.
* NotComplete – You intend to make additional captures.
`Note:
If Complete, any remaining amount of the original authorized
transaction is automatically voided and all remaining open
authorizations are voided.`
*/
$doCaptureReqest = new DoCaptureRequestType($_REQUEST['authID'], $amount, $_REQUEST['completeCodeType']);
$doCaptureReq = new DoCaptureReq();
$doCaptureReq->DoCaptureRequest = $doCaptureReqest;
/*
 *  ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $doCaptureResponse = $paypalService->DoCapture($doCaptureReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($doCaptureResponse)) {
    echo "<pre>";
    print_r($doCaptureResponse);
    echo "</pre>";
}
require_once '../Response.php';
 *  You use the GetPaymentOptions API operation to retrieve the payment options passed with the SetPaymentOptionsRequest. 
 */
/*
 * (Required) Information common to each API operation, such as the language in which an error message is returned.
 */
$requestEnvelope = new RequestEnvelope("en_US");
/*
 * (Required) The pay key that identifies the payment for which you want to get payment options. This is the pay key you used to set the payment options.
 */
$getPaymentOptionsReq = new GetPaymentOptionsRequest($requestEnvelope, $_POST['payKey']);
/*
* 	 ## 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->GetPaymentOptions($getPaymentOptionsReq);
} 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 - Get Payment Options</title>
<link href="Common/sdk.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Common/sdk_functions.js"></script>
</head>
Example #3
0
 $requestEnvelope = new RequestEnvelope("en_US");
 /*
 * 
 		 SendInvoiceRequest which takes mandatory params:
 		
 		 * `Request Envelope` - Information common to each API operation, such
 		 as the language in which an error message is returned.
 		 * `Invoice ID` - ID of the invoice to send.
 */
 $sendInvoiceRequest = new SendInvoiceRequest($requestEnvelope, $_POST['invoiceID']);
 /*
  *  ## Creating service wrapper object
 	 Creating service wrapper object to make API call and loading
      configuration file for your credentials and endpoint
 */
 $invoiceService = new InvoiceService(Configuration::getAcctAndConfig());
 // required in third party permissioning
 if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
     $cred = new PPSignatureCredential(USERNAME, PASSWORD, SIGNATURE);
     $cred->setThirdPartyAuthorization(new PPTokenAuthorization($_POST['accessToken'], $_POST['tokenSecret']));
 }
 try {
     /*
     *  ## Making API call
     			 Invoke the appropriate method corresponding to API in service
     			 wrapper object
     */
     if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
         $sendInvoiceResponse = $invoiceService->SendInvoice($sendInvoiceRequest, $cred);
     } else {
         $sendInvoiceResponse = $invoiceService->SendInvoice($sendInvoiceRequest);
Example #4
0
 public function actionPay($id)
 {
     $reservation = Reservation::model()->findByPk($id);
     if (isset($reservation)) {
         Yii::app()->session['llegada'] = $reservation->arrival_date;
         Yii::app()->session['salida'] = $reservation->departure_date;
         Yii::app()->session['maxPersonas'] = $reservation->number_people;
         Yii::app()->session['total'] = $reservation->total;
         $count = 0;
         $habitacion = [];
         foreach (RoomsBooked::model()->findAllByAttributes(array('reservation_id' => $reservation->id)) as $i => $rb) {
             $count += $rb->quantity;
             for ($i = 0; $i < $rb->quantity; $i++) {
                 $n = 'room_' . TypeRoom::model()->findByPk($rb->type_room_id)->name . '_name';
                 array_push($habitacion, Yii::t('rooms', $n));
             }
         }
         Yii::app()->session['habitacion'] = $habitacion;
         Yii::app()->session['habitaciones'] = $count;
         /* paypal */
         require_once 'paypal/PPBootStrap.php';
         $buttonVar = array("item_name=reservacion", "item_number=" . $this->generateRandomString(3) . $reservation->id . $this->generateRandomString(1), "return=" . Yii::app()->request->getBaseUrl(true) . "#cuenta", "business=marisaloorv@yahoo.com", "amount=" . $reservation->total, "notify_url=" . Yii::app()->request->getBaseUrl(true) . "/site/ipn", "no_shipping=1", "cancel_return=" . Yii::app()->request->getBaseUrl(true) . "#cuenta");
         $createButtonRequest = new BMCreateButtonRequestType();
         $createButtonRequest->ButtonCode = "ENCRYPTED";
         $createButtonRequest->ButtonType = "BUYNOW";
         $createButtonRequest->ButtonSubType = 'SERVICES';
         $createButtonRequest->BuyNowText = 'PAYNOW';
         $createButtonRequest->ButtonLanguage = 'es';
         $createButtonRequest->ButtonImageURL = Yii::app()->request->getBaseUrl(true) . "/images/paypal.png";
         $createButtonRequest->ButtonVar = $buttonVar;
         $createButtonReq = new BMCreateButtonReq();
         $createButtonReq->BMCreateButtonRequest = $createButtonRequest;
         $paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
         try {
             $createButtonResponse = $paypalService->BMCreateButton($createButtonReq);
             if ($createButtonResponse->Ack == 'Success') {
                 Yii::app()->session['button'] = $createButtonResponse->Website;
             } else {
                 $this->redirect(Yii::app()->request->getBaseUrl(true) . '#cuenta');
             }
         } catch (Exception $ex) {
             print_r($ex);
             die;
         }
         /* --- */
         $this->redirect(Yii::app()->request->getBaseUrl(true) . '#pagar');
     } else {
         $this->redirect(Yii::app()->request->getBaseUrl(true) . '#cuenta');
     }
 }
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;
}
Example #6
0
 function getResponse()
 {
     $token = $_GET['token'];
     $getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType($token);
     $getExpressCheckoutReq = new GetExpressCheckoutDetailsReq();
     $getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
     /*
      * 	 ## Creating service wrapper object
     Creating service wrapper object to make API call and loading
     Configuration::getAcctAndConfig() returns array that contains credential and config parameters
     */
     $paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
     try {
         /* wrap API method calls on the service object with a try catch */
         $getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
     } catch (Exception $ex) {
         if (isset($ex)) {
             $ex_message = $ex->getMessage();
             $ex_type = get_class($ex);
             if ($ex instanceof PPConnectionException) {
                 $ex_detailed_message = "Error connecting to " . $ex->getUrl();
             } else {
                 if ($ex instanceof PPMissingCredentialException || $ex instanceof PPInvalidCredentialException) {
                     $ex_detailed_message = $ex->errorMessage();
                 } else {
                     if ($ex instanceof PPConfigurationException) {
                         $ex_detailed_message = "Invalid configuration. Please check your configuration file";
                     }
                 }
             }
             print_r($ex_detailed_message);
         }
         exit;
     }
     if (isset($getECResponse)) {
         $payerId = urlencode($getECResponse->GetExpressCheckoutDetailsResponseDetails->PayerInfo->PayerID);
         $paymentAction = urlencode("Sale");
         $getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType($token);
         $getExpressCheckoutReq = new GetExpressCheckoutDetailsReq();
         $getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
         /*
         Configuration::getAcctAndConfig() returns array that contains credential and config parameters
         */
         $paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
         try {
             /* wrap API method calls on the service object with a try catch */
             $getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
         } catch (Exception $ex) {
             if (isset($ex)) {
                 $ex_message = $ex->getMessage();
                 $ex_type = get_class($ex);
                 if ($ex instanceof PPConnectionException) {
                     $ex_detailed_message = "Error connecting to " . $ex->getUrl();
                 } else {
                     if ($ex instanceof PPMissingCredentialException || $ex instanceof PPInvalidCredentialException) {
                         $ex_detailed_message = $ex->errorMessage();
                     } else {
                         if ($ex instanceof PPConfigurationException) {
                             $ex_detailed_message = "Invalid configuration. Please check your configuration file";
                         }
                     }
                 }
                 print_r($ex_detailed_message);
             }
             exit;
         }
         //----------------------------------------------------------------------------
         /*
          * The total cost of the transaction to the buyer. If shipping cost (not applicable to digital goods) and tax charges are known, include them in this value. If not, this value should be the current sub-total of the order. If the transaction includes one or more one-time purchases, this field must be equal to the sum of the purchases. Set this field to 0 if the transaction does not include a one-time purchase such as when you set up a billing agreement for a recurring payment that is not immediately charged. When the field is set to 0, purchase-specific fields are ignored.
          */
         $orderTotal = new BasicAmountType();
         $orderTotal->currencyID = "MXN";
         $orderTotal->value = $getECResponse->GetExpressCheckoutDetailsResponseDetails->PaymentDetails[0]->OrderTotal->value;
         $paymentDetails = new PaymentDetailsType();
         $paymentDetails->OrderTotal = $orderTotal;
         $DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
         $DoECRequestDetails->PayerID = $payerId;
         $DoECRequestDetails->Token = $token;
         $DoECRequestDetails->PaymentAction = $paymentAction;
         $DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
         $DoECRequest = new DoExpressCheckoutPaymentRequestType();
         $DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
         $DoECReq = new DoExpressCheckoutPaymentReq();
         $DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
         try {
             /* wrap API method calls on the service object with a try catch */
             $DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
         } catch (Exception $ex) {
             if (isset($ex)) {
                 $ex_message = $ex->getMessage();
                 $ex_type = get_class($ex);
                 if ($ex instanceof PPConnectionException) {
                     $ex_detailed_message = "Error connecting to " . $ex->getUrl();
                 } else {
                     if ($ex instanceof PPMissingCredentialException || $ex instanceof PPInvalidCredentialException) {
                         $ex_detailed_message = $ex->errorMessage();
                     } else {
                         if ($ex instanceof PPConfigurationException) {
                             $ex_detailed_message = "Invalid configuration. Please check your configuration file";
                         }
                     }
                 }
                 print_r($ex_detailed_message);
             }
             exit;
         }
         if (isset($DoECResponse)) {
             if (isset($DoECResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo)) {
                 $return = array('transactionID' => $DoECResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo[0]->TransactionID, 'total' => $DoECResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo[0]->GrossAmount->value);
                 return $return;
             } else {
                 return false;
             }
         }
     }
 }
$request = new GetAccessTokenRequest();
$request->requestEnvelope = $requestEnvelope;
/*
 * (Required) The request token from the response to RequestPermissions.
*/
$request->token = $_REQUEST['Requesttoken'];
/*
 * (Required) The verification code returned in the redirect from PayPal to the return URL.
*/
$request->verifier = $_REQUEST['Verifier'];
/*
 * 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$permissions = new PermissionsService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $response = $permissions->GetAccessToken($request);
} catch (Exception $ex) {
    require_once '../error.php';
    exit;
}
/* Display the API response back to the browser.
 If the response from PayPal was a success, display the response parameters'
 If the response was an error, display the errors received using APIError.php.
 */
$ack = strtoupper($response->responseEnvelope->ack);
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $response;
    $location = "APIError.php";
 function doCancelPreapproval($backing)
 {
     // $backing is projectbacking record
     extract($backing);
     $this->con->update("update projectbacking set payment_status='c' where backingId='" . $backingId . "'");
     if (isset($paypalId) && !empty($paypalId) && $paypalid != 0) {
         $this->con->update("update paypaltransaction set status='CANCELLED' where paypalId='" . $paypalId . "'");
     }
     $requestEnvelope = new RequestEnvelope("en_US");
     $cancelPreapprovalReq = new CancelPreapprovalRequest($requestEnvelope, $preapproval_key);
     wrtlog("DEBUG cancelPreapprovalReq=" . print_r($cancelPreapprovalReq, true));
     $service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
     try {
         $response = $service->CancelPreapproval($cancelPreapprovalReq);
         $final_arr = array();
         $preq = dismount($cancelPreapprovalReq);
         foreach ($preq as $K => $P) {
             $final_arr[addslashes($K)] = addslashes(is_array($P) ? json_encode($P) : $P);
         }
         if (is_object($response)) {
             $newarray = dismount($response);
             $response = $newarray;
         }
         foreach ($response as $K => $P) {
             $final_arr[addslashes($K)] = addslashes(is_array($P) ? json_encode($P) : $P);
         }
         $final_arr['url'] = get_url();
         $this->con->insert("insert into preapproval_detail (detail) values ('" . mysql_real_escape_string(json_encode($final_arr)) . "')");
         $cancel_detail_id = mysql_insert_id();
         $this->con->update("update projectbacking set cancel_detail_id='" . $cancel_detail_id . "' where backingId='" . $backingId . "'");
         wrtlog("DEBUG doCancelPreapproval response for project {$projectId} : " . print_r($response, true));
     } catch (Exception $ex) {
         wrtlog("DEBUG doCancelPreapproval error: " . $ex->getMessage());
         wrtlog("DEBUG doCancelPreapproval request: " . print_r($cancelPreapprovalReq, true));
         require_once 'Common/Error.php';
         /// THIS IS CALLED BY automatic_cron.php ////
         /// SO TBD IF WE SHOULD STOP IT          ////
         exit;
     }
 }
Example #9
0
 public function doExpressCheckout()
 {
     $token = urlencode($_REQUEST['token']);
     $payerId = urlencode($_REQUEST['PayerID']);
     $token = $_REQUEST['token'];
     $getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType($token);
     $getExpressCheckoutReq = new GetExpressCheckoutDetailsReq();
     $getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
     $paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
     try {
         /** @var \PayPal\PayPalAPI\GetExpressCheckoutDetailsResponseType $getECResponse */
         $getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
     } catch (Exception $ex) {
         echo $ex->getMessage();
     }
     $orderTotal = new BasicAmountType();
     $orderTotal->currencyID = $getECResponse->GetExpressCheckoutDetailsResponseDetails->PaymentDetails[0]->OrderTotal->currencyID;
     $orderTotal->value = $getECResponse->GetExpressCheckoutDetailsResponseDetails->PaymentDetails[0]->OrderTotal->value;
     //Details about each individual item included in the order.
     $itemDetails = new PaymentDetailsItemType();
     $itemDetails->Name = 'Sexy Plus Size V-Neck Short Sleeve Lace Hollow Out Dress(SKU189442)';
     $itemDetails->Amount = $orderTotal;
     $itemDetails->Quantity = '1';
     $itemDetails->ItemCategory = 'Digital';
     $PaymentDetails = new PaymentDetailsType();
     $PaymentDetails->PaymentDetailsItem[0] = $itemDetails;
     //$PaymentDetails->ShipToAddress = $address;
     $PaymentDetails->OrderTotal = $orderTotal;
     /*
      * How you want to obtain payment. When implementing parallel payments, this field is required and must be set to Order. When implementing digital goods, this field is required and must be set to Sale.
      */
     $PaymentDetails->PaymentAction = 'Sale';
     $PaymentDetails->ItemTotal = $orderTotal;
     $DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
     $DoECRequestDetails->PayerID = $payerId;
     $DoECRequestDetails->Token = $token;
     $DoECRequestDetails->PaymentDetails[0] = $PaymentDetails;
     $DoECRequest = new DoExpressCheckoutPaymentRequestType();
     $DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
     $DoECReq = new DoExpressCheckoutPaymentReq();
     $DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
     $paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
     $DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
     //var_dump($DoECResponse);
     if ($DoECResponse->Ack == 'Success') {
         $this->successExpressCheckout();
     } else {
         echo "failed, please contact us: cservice@pandoraf.com!";
         exit;
     }
 }
Example #10
0
//if(!session_id()) session_start();
// jwg
if (version_compare(phpversion(), '5.4.0', '<')) {
    if (session_id() == '') {
        session_start();
    }
} else {
    if (session_status() == PHP_SESSION_NONE) {
        session_start();
    }
}
// setup global vars that might still be used by old paypal api
require_once 'Configuration.php';
// obtain from new api config
$ppconfig = new Configuration();
$theconfig = $ppconfig->getAcctAndConfig();
$application_id = $theconfig['acct1.AppId'];
$api_username = $theconfig['acct1.UserName'];
$api_password = $theconfig['acct1.Password'];
$api_signature = $theconfig['acct1.Signature'];
$developer_account_email = 'admin@' . $_SERVER['SERVER_NAME'];
$sandbox = $theconfig['mode'];
/** 
 * Sandbox Mode - TRUE/FALSE
 */
//$sandbox = TRUE;
// jwg - noopd next
//$domain = $sandbox ? 'http://www.sandbox.paypal.com/' : 'http://www.paypal.com/';
/**
 * Enable error reporting if running in sandbox mode.
 */