Beispiel #1
1
 public function payAction()
 {
     //THIS MAY BE THE PLACE WHERE WE CREATE AN INTERNAL INVOICE
     require_once "paypal/paypal.php";
     //do express checkout returns success or failure
     $doPay = new DoExpressCheckoutPayment($_GET['amount']);
     //amount is optional but should be
     //similar to the one set in
     //SetExpressCehckout
     $result = $doPay->getResponse();
     //result holds response from PayPal so you need to check if it was successful
     print_r($result);
 }
Beispiel #2
0
<?php

if (isset($_GET)) {
    //require paypal class
    require_once "paypal.php";
    //GetExpressCheckoutDetails is optional, returns customer's details from paypal
    $paypal = new GetExpressCheckoutDetails();
    $details = $paypal->getResponse();
    $totalPrice = '100';
    //however you want to receive this (database linked to INVNUM, session var, etcetera)
    //DoExpressCheckoutPayment - returns success or failure
    //amount is optional, if not set, amount from .ini file is used
    $payment = new DoExpressCheckoutPayment($totalPrice);
    $payment_response = $payment->getResponse();
    if ($payment_response['PAYMENTSTATUS'] == 'Completed') {
        //print responce from GetExpressCheckoutDetails
        echo '<pre>';
        print_r($details);
        //print responce from DoExpressCheckoutPayment
        echo '<pre>';
        print_r($payment_response);
    } else {
        //print error
    }
}
Beispiel #3
0
 public function actionSubmitpaypal()
 {
     $paypal = new GetExpressCheckoutDetails();
     $details = $paypal->getResponse();
     //$totalPrice = urldecode($details['AMT']);
     $what = urldecode($details['CUSTOM']);
     $desc = urldecode($details["DESC"]);
     $cst = $details["CUSTOM"];
     $cst = explode("_", $cst);
     $type = $cst[2];
     $cst = $cst[1];
     $discount = $cst[3];
     if ($type == "basic") {
         $totalPrice = "19.95";
     } else {
         if ($type == "basicplus") {
             $totalPrice = "24.95";
         } else {
             if ($type == "pro") {
                 $totalPrice = "29.95";
             }
         }
     }
     $prorate = round($totalPrice * (((double) date('t') - (double) date('j')) / (double) date('t')), 2);
     $initAmt = $prorate + 0;
     // switch ($_SESSION["discount"]) {
     //     case 'MFVideoMgr-100':
     //         $prorate = $initAmt = 0;
     //         break;
     //     case 'MFVM-50A':
     //         $prorate = round((float)$prorate * 0.50, 2);
     //         $initAmt = round((float)$initAmt * 0.50, 2);
     //         break;
     //     case 'MFVM25':
     //         $prorate = round((float)$prorate * 0.25, 2);
     //         $initAmt = round((float)$initAmt * 0.25, 2);
     //         break;
     // }
     if (isset($_SESSION["discount"])) {
         Yii::import('admin.models.*');
         $coupon = Coupon::model()->findByAttributes(array('name' => $_SESSION["discount"]));
         if ($coupon) {
             if ($coupon->discount >= 100) {
                 //$initAmt = $initAmt - (2*$initAmt);
                 $prorate = 0.01;
                 $initAmt = 0.01;
             } else {
                 $prorate = $prorate - round((double) $prorate * ($coupon->discount / 100), 2);
                 $initAmt = $initAmt - round((double) $initAmt * ($coupon->discount / 100), 2);
             }
         }
     }
     $payment = new DoExpressCheckoutPayment($initAmt);
     $payment_response1 = $payment->getResponse();
     $recur = new CreateRecurringPaymentsProfile(ucfirst($type) . " Subscription for VidMgr, {$totalPrice} /mo", $totalPrice);
     // \n $0 One Time Setup Fee
     $recur->setNVP("SUBSCRIBERNAME", user()->Name);
     $recur->setNVP("PROFILEREFERENCE", "userid_" . uid() . "_" . $cst);
     $recur->setNVP("PROFILESTARTDATE", date("Y-m-d\\TH:i:s\\Z", mktime(0, 0, 0, date("m") + 1, 1, date("y"))));
     $recur->setNVP("MAXFAILEDPAYMENTS", "1");
     $recur->setNVP("BILLINGPERIOD", "Month");
     $recur->setNVP("BILLINGFREQUENCY", "1");
     $recur->setNVP("CURRENCYCODE", "USD");
     $recur->setNVP('L_PAYMENTREQUEST_0_NAME0', "Video Subscription - Basic 40MB");
     $recur->setNVP('L_PAYMENTREQUEST_0_ITEMCATEGORY0', 'Digital');
     $recur->setNVP('L_PAYMENTREQUEST_0_AMT0', $totalPrice);
     $recur->setNVP('L_PAYMENTREQUEST_0_QTY0', "1");
     $recur->setNVP("INITAMT", $initAmt);
     $payment_response = $recur->getResponse();
     Ytrace($payment_response);
     Ytrace($details);
     if ($payment_response["ACK"] == "Success" && $payment_response1["ACK"] == "Success") {
         Video::model()->updateByPk($cst, array("active" => "1", "lastPayment" => sqlDate(), "payModel" => $type));
         User::model()->updateByPk(uid(), array("payModel" => $type, "coupon" => ""));
         $this->process($cst, $type);
     } else {
         $this->renderText("There was some problem in processing your request. Please try again. If you repeatedly face this error please use the contact page, we would love to help you.");
     }
 }
Beispiel #4
0
+-------------------------------------------------------------------------------+
*/
$test = new SetExpressCheckout("50.00");
//amount - optional, if not set
//amount form .ini file will be used
$test->setNVP("L_BILLINGTYPE0", "RecurringPayments");
$test->setNVP("L_BILLINGAGREEMENTDESCRIPTION0", "book order");
$test->getResponse();
//!!! you cannot use static method if you wan to use recurring payment, because
//you neet to set L_BILLINGTYPEn and L_BILLINGAGREEMENTDESCRIPTIONn
//get express checkout details (optional)
//the code below has to be placed in the file specified in RETURNURL
//(in SetExpressCheckout.ini) or setNVP() method
$result = GetExpressCheckoutDetails::request();
//there's no need to use: $data = new GetExpressCheckoutDetails();
//but if you want, you can
// now you can save data in database or whatever you want
//do express checkout returns success or failure
$doPay = new DoExpressCheckoutPayment("50.00");
//amount is optional but should be
//similar to the one set in
//SetExpressCehckout
$result = $doPay->getResponse();
//result holds response from PayPal so you need to check if it was successful
//create recurring payments profile response is success or failure
///first value is description and is required - same as
//L_BILLINGAGREEMENTDESCRIPTIONn in SetExpressCheckout.
//second value is amountt
$recPay = new CreateRecurringPaymentsProfile("book order", "50.00");
$result = $recPay->getResponse();
//result holds response from PayPal so you need to check if it was successful