/*$amount,
  $email,
  $ipnlink,
  $walut (PLN...),
  $api_user,
  $api_password,
  
  
  
  


*/
$payRequest = new PayRequest();
$receiver = array();
$receiver[0] = new Receiver();
$receiver[0]->amount = $amount;
$receiver[0]->email = $email;
$receiverList = new ReceiverList($receiver);
$payRequest->receiverList = $receiverList;
$requestEnvelope = new RequestEnvelope("pl_PL");
$payRequest->requestEnvelope = $requestEnvelope;
$payRequest->actionType = "PAY";
$payRequest->cancelUrl = "https://devtools-paypal.com/guide/ap_simple_payment/php?cancel=true";
$payRequest->returnUrl = "https://devtools-paypal.com/guide/ap_simple_payment/php?success=true";
$payRequest->currencyCode = $walut;
$payRequest->ipnNotificationUrl = $ipnlink;
$sdkConfig = array("mode" => "live", "acct1.UserName" => $api_user, "acct1.Password" => $api_password, "acct1.Signature" => "{API_SIGNATURE}", "acct1.AppId" => "APP-80W284485P519543T");
$adaptivePaymentsService = new AdaptivePaymentsService($sdkConfig);
$payResponse = $adaptivePaymentsService->Pay($payRequest);
 public function postPaynow(Request $request, $affiliate_id)
 {
     $user_is = $request->user_infusionsoft;
     $affiliate_row = Affiliate::where('user_is_id', '=', $user_is->id)->where('aff_id', '=', $affiliate_id)->first();
     define('PAYPAL_SANDBOX', 1);
     define('PAYPAL_ACTION_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr');
     //adaptive payment request
     $payRequest = new \PayRequest();
     $receiver = array();
     $receiver[0] = new \Receiver();
     $receiver[0]->amount = $request->amount;
     $receiver[0]->email = $affiliate_row['paypal_email'];
     $receiverList = new \ReceiverList($receiver);
     $payRequest->receiverList = $receiverList;
     $payRequest->senderEmail = $user_is->paypal_business_account;
     $requestEnvelope = new \RequestEnvelope("en_US");
     $payRequest->requestEnvelope = $requestEnvelope;
     $payRequest->actionType = "PAY";
     $payRequest->cancelUrl = URL::to('affiliates/' . $affiliate_id . '/pay');
     $payRequest->returnUrl = URL::to('affiliates/' . $affiliate_id);
     $payRequest->currencyCode = "USD";
     $payRequest->ipnNotificationUrl = URL::to('paypal/ipn');
     $sdkConfig = array("mode" => PAYPAL_SANDBOX ? "sandbox" : 'live', "acct1.UserName" => $user_is->paypal_api_username, "acct1.Password" => $user_is->paypal_api_password, "acct1.Signature" => $user_is->paypal_api_signature, "acct1.AppId" => $user_is->paypal_app_id);
     $adaptivePaymentsService = new \AdaptivePaymentsService($sdkConfig);
     $payResponse = $adaptivePaymentsService->Pay($payRequest);
     $payment = new Payment();
     $payment->affiliate_id = $affiliate_row->id;
     $payment->payment_key = $payResponse->payKey;
     $payment->amount = $request['amount'];
     $payment->pay_result = json_encode($payResponse);
     $payment->status = 1;
     $payment->save();
     if ($payResponse->responseEnvelope->ack != 'Success') {
         return redirect(URL::to('affiliates/' . $affiliate_id . '/pay'))->with('error', 'Payment was not successful.');
     }
     return redirect(URL::to('affiliates/' . $affiliate_id . '/pay'))->with('success', 'Payment was successful');
 }
Esempio n. 3
0
 private function makeAPICall($payRequest)
 {
     $logger = new PPLoggingManager('Pay');
     // ## 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->Pay($payRequest);
     } 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 pay key, which is a token you use in other Adaptive
         // Payment APIs (such as the Refund Method) to identify this
         // payment. The pay key is valid for 3 hours; the payment must
         // be approved while the pay key is valid.
         $logger->log("Pay Key : " . $response->payKey);
         // Once you get success response, user has to redirect to PayPal
         // for the payment. Construct redirectURL as follows,
         // `redirectURL=https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey="
         // + $response->payKey`
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     return $response;
 }
Esempio n. 4
0
 /**
  *
  *
  * @param unknown $order_id
  *
  * @return unknown
  */
 public function paypalap_check_form($order_id)
 {
     global $woocommerce;
     $this->include_paypal_sdk();
     $this->logger = new PPLoggingManager('Pay');
     $order = new WC_Order($order_id);
     $receivers = $this->get_receivers($order);
     $receiverList = new ReceiverList($receivers);
     $actionType = 'CREATE';
     $cancelUrl = $order->get_cancel_order_url_raw();
     $currencyCode = get_woocommerce_currency();
     $returnUrl = esc_url_raw(add_query_arg('key', $order->order_key, add_query_arg('order-received', $order->id, $order->get_checkout_order_received_url())));
     $payRequest = new PayRequest(new RequestEnvelope("en_US"), $actionType, $cancelUrl, $currencyCode, $receiverList, $returnUrl);
     // ==================================================================
     //
     // Optional params
     //
     // ------------------------------------------------------------------
     $payRequest->feesPayer = 'EACHRECEIVER';
     $args = array('wc-api' => 'WC_PayPalAP', 'paypal_chain_ipn' => '1', 'order_id' => $order_id);
     $payRequest->ipnNotificationUrl = add_query_arg($args, home_url('/'));
     $payRequest->memo = !empty($order->customer_note) ? $order->customer_note : '';
     $payRequest->reverseAllParallelPaymentsOnError = true;
     $service = new AdaptivePaymentsService();
     try {
         $response = $service->Pay($payRequest);
     } catch (Exception $ex) {
         wc_add_notice(sprintf(__('Error: %s', 'wcvendors'), $ex->getMessage()), 'error');
         return false;
     }
     $this->logger->log("Received payResponse:");
     $ack = strtoupper($response->responseEnvelope->ack);
     if ($ack != 'SUCCESS') {
         $order->update_status('cancelled', sprintf(__('Error ID: %s. %s', 'wcvendors'), $response->error[0]->errorId, $response->error[0]->message));
         wc_add_notice(sprintf(__('Error ID: %s. %s', 'wcvendors'), $response->error[0]->errorId, $response->error[0]->message), 'error');
         return false;
     }
     return $response->payKey;
 }
/*
 * URL to redirect the sender's browser to after canceling the approval for a payment; it is always required but only used for payments that require approval (explicit payments) 
 */
/*
 * URL to redirect the sender's browser to after the sender has logged into PayPal and approved a payment; it is always required but only used if a payment requires explicit approval 
 */
$payRequest = new PayRequest(new RequestEnvelope("en_US"), $_POST['actionType'], $_POST['cancelUrl'], $_POST['currencyCode'], $receiverList, $_POST['returnUrl']);
/*
* 	 ## 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->Pay($payRequest);
} catch (Exception $ex) {
    require_once '../Common/Error.php';
    exit;
}
/* Make the call to PayPal to get the Pay token
 If the API call succeded, then redirect the buyer to PayPal
to begin to authorize payment.  If an error occured, show the
resulting errors */
?>
<!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 - Pay Response</title>
<link href="../Common/sdk.css" rel="stylesheet" type="text/css" />
 public function paybypalwebSubmit()
 {
     // Normal Payment
     $request_id = Request::segment(3);
     $request = Requests::where('id', $request_id)->first();
     $reqserv = RequestServices::where('request_id', $request_id)->first();
     $typess = ProviderType::where('id', $reqserv->type)->first();
     $total_amount = $request->total;
     $service_name = $typess->name;
     $owner = Owner::where('id', $request->owner_id)->first();
     $walker = Walker::where('id', $request->confirmed_walker)->first();
     $admins = Admin::first();
     // Adaptive payments
     // check if transfer is allowed
     $transfersett = Settings::where('key', 'transfer')->first();
     $payRequest = new PayRequest();
     if ($transfersett->value == 1) {
         $receiver = array();
         $receiver[0] = new Receiver();
         $receiver[0]->amount = $request->total - $request->transfer_amount;
         // $receiver[0]->email = "*****@*****.**";
         $receiver[0]->email = $admins->username;
         $receiver[0]->primary = "true";
         $receiver[1] = new Receiver();
         $receiver[1]->amount = $request->transfer_amount;
         // $receiver[1]->email = "*****@*****.**";
         $receiver[1]->email = $walker->email;
     } else {
         $receiver = array();
         $receiver[0] = new Receiver();
         $receiver[0]->amount = $request->total;
         // $receiver[0]->email = "*****@*****.**";
         $receiver[0]->email = $admins->username;
         $receiver[0]->primary = "true";
     }
     $receiverList = new ReceiverList($receiver);
     $payRequest->receiverList = $receiverList;
     $requestEnvelope = new RequestEnvelope("en_US");
     $payRequest->requestEnvelope = $requestEnvelope;
     $payRequest->actionType = "PAY";
     $payRequest->cancelUrl = URL::route('userpaypalstatus');
     $payRequest->returnUrl = URL::route('userpaypalstatus');
     $payRequest->currencyCode = "USD";
     $payRequest->ipnNotificationUrl = URL::route('userpaypalipn');
     $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);
     $payResponse = $adaptivePaymentsService->Pay($payRequest);
     Log::info('payResponse = ' . print_r($payResponse, true));
     return Redirect::to('userpaypalstatus');
 }
 public function adaptive_implicit_payment_developer()
 {
     # Get the Player's Paypal ID
     $this->load->model('Developer_model');
     $this->load->model('Paymenthistory_model');
     $this->load->model('Withdrawal_requests_model');
     $where = 'id = ' . $this->input->post('player_id');
     $player = $this->Developer_model->findByCondition($where);
     $response['status'] = false;
     $response['message'] = ERROR_MESSAGE . ':Something went wrong, the request could not be completed';
     if (!empty($player) && $player[0]['paypal_id'] != '' && $player[0]['paypal_id'] != null && $this->input->post('amount') > 0 && $player[0]['amount'] >= $this->input->post('amount')) {
         $payRequest = new PayRequest();
         $receiver = array();
         $receiver[0] = new Receiver();
         $receiver[0]->amount = $this->input->post('amount');
         $receiver[0]->email = $player[0]['paypal_id'];
         $receiverList = new ReceiverList($receiver);
         $payRequest->receiverList = $receiverList;
         $payRequest->senderEmail = "*****@*****.**";
         $requestEnvelope = new RequestEnvelope("en_US");
         $payRequest->requestEnvelope = $requestEnvelope;
         $payRequest->actionType = "PAY";
         $payRequest->cancelUrl = base_url() . 'admin/payment_error';
         $payRequest->returnUrl = base_url() . 'admin/payment_success';
         $payRequest->currencyCode = "USD";
         $sdkConfig = array("mode" => "sandbox", "acct1.UserName" => "jb-us-seller_api1.paypal.com", "acct1.Password" => "WX4WTU3S8MY44S7F", "acct1.Signature" => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy", "acct1.AppId" => "APP-80W284485P519543T");
         $adaptivePaymentsService = new AdaptivePaymentsService($sdkConfig);
         $payResponse = $adaptivePaymentsService->Pay($payRequest);
         $ack = strtoupper($payResponse->responseEnvelope->ack);
         if ($ack != "SUCCESS") {
         } else {
             $insertDataPaymentHistory = array('userID' => $player[0]['id'], 'type' => 'debit', 'reason' => 'Payment to a developer on behalf of a request', 'amount' => $this->input->post('amount'), 'referrer_id' => $player[0]['id'], 'referrer_type' => 'Developer', 'transaction_id' => '', 'gateway' => 'Paypal');
             $id = $this->Paymenthistory_model->save($insertDataPaymentHistory);
             if ($this->input->post('withdrawal_id') != '' && $this->input->post('withdrawal_id') != null) {
                 $where = 'id = ' . $this->input->post('withdrawal_id');
                 $updateDataWithdrawal = array('approved' => is_withdrawal_approved(), 'payment_id' => $id);
                 $this->Withdrawal_requests_model->updateByCondition($where, $updateDataWithdrawal);
                 $body = 'You sent a withdrawal request on your paypal id: ' . $player[0]['paypal_id'] . ' which has been approved and an amount of $' . $this->input->post('amount') . ' has been sent to your paypal account, please verify.';
             } else {
                 $new_balance = floatval(floatval($player[0]['amount']) - floatval($this->input->post('amount')));
                 $where = 'id = ' . $player[0]['id'];
                 $updateDataPlayer = array('amount' => $new_balance);
                 $id = $this->Developer_model->updateByCondition($where, $updateDataPlayer);
                 $body = 'An amount of $' . $this->input->post('amount') . ' has been sent on your paypal id: ' . $player[0]['paypal_id'] . ', please verify.';
             }
             mail_me(array('to' => $player[0]['email'], 'to_name' => $player[0]['fName'] . ' ' . $player[0]['lName'], 'from' => $this->config->item('adminEmail'), 'from_name' => $this->config->item('adminName'), 'from_pass' => $this->config->item('adminEmail_pass'), 'subject' => 'Payment Made', 'body' => $body));
             $response['status'] = true;
             $response['message'] = 'Payment Sucessfully made';
         }
     }
     return $response;
 }
 /**
  * Process the payment and return the result
  *
  * @access public
  * @param int     $order_id
  * @return array
  */
 function process_payment($order_id)
 {
     $receiver = array();
     $payRequest = new PayRequest();
     $order = new WC_Order($order_id);
     $sub_orders = get_children(array('post_parent' => $order_id, 'post_type' => 'shop_order'));
     if ($sub_orders) {
         $sum = 0;
         foreach ($sub_orders as $key => $order_post) {
             $seller_id = dokan_get_seller_id_by_order($order_post->ID);
             $seller_balance = $this->get_seller_net_balance($order_post->ID, $seller_id);
             $seller_pay_email = dokan_get_seller_withdraw_mail($seller_id);
             if (false === $seller_pay_email) {
                 $seller_pay_email = get_user_by('id', $seller_id)->user_email;
             }
             $receiver[$key] = new Receiver();
             $receiver[$key]->amount = $seller_balance;
             $receiver[$key]->email = $seller_pay_email;
             $sum += (double) $seller_balance;
         }
         if ($this->payment_process == 'chained') {
             $admin_amount = (string) $order->get_total();
         } else {
             $admin_amount = (string) ((double) $order->get_total() - $sum);
         }
     } else {
         $seller_id = dokan_get_seller_id_by_order($order_id);
         $seller_balance = $this->get_seller_net_balance($order_id, $seller_id);
         $seller_pay_email = dokan_get_seller_withdraw_mail($seller_id);
         if (false === $seller_pay_email) {
             $seller_pay_email = get_user_by('id', $seller_id)->user_email;
         }
         $receiver[0] = new Receiver();
         $receiver[0]->amount = $seller_balance;
         $receiver[0]->email = $seller_pay_email;
         if ($this->payment_process == 'chained') {
             if ($this->single_mode == 'yes') {
                 $admin_amount = (string) ((double) $order->get_total() - (double) $seller_balance);
                 $receiver[0]->amount = (string) $order->get_total();
             } else {
                 $admin_amount = (string) $order->get_total();
             }
         } else {
             $admin_amount = (string) ((double) $order->get_total() - (double) $seller_balance);
         }
     }
     $count = count($receiver);
     if ($admin_amount > 0) {
         $receiver[$count] = new Receiver();
         $receiver[$count]->amount = $admin_amount;
         $receiver[$count]->email = $this->pa_admin_email;
     }
     if ($this->payment_process == 'chained') {
         if ($this->single_mode == 'yes') {
             $receiver[0]->primary = "true";
         } else {
             $receiver[$count]->primary = "true";
         }
     }
     $this->add_log('Payment Process: ' . $this->payment_process . ' ------ Reciever list' . print_r($receiver, true) . '...');
     $receiverList = new ReceiverList($receiver);
     $payRequest->receiverList = $receiverList;
     $requestEnvelope = new RequestEnvelope("en_US");
     $payRequest->requestEnvelope = $requestEnvelope;
     $payRequest->actionType = "PAY";
     $payRequest->cancelUrl = esc_url($order->get_cancel_order_url());
     $payRequest->returnUrl = esc_url($this->get_return_url($order));
     $payRequest->currencyCode = get_woocommerce_currency();
     $payRequest->ipnNotificationUrl = $this->notify_url;
     if ('yes' == $this->testmode) {
         $sdkConfig = array("mode" => "sandbox", "acct1.UserName" => $this->test_appuser, "acct1.Password" => $this->test_apppass, "acct1.Signature" => $this->test_appsig, "acct1.AppId" => "APP-80W284485P519543T");
     } else {
         $sdkConfig = array("mode" => "live", "acct1.UserName" => $this->appuser, "acct1.Password" => $this->apppass, "acct1.Signature" => $this->appsig, "acct1.AppId" => $this->appid);
     }
     $adaptivePaymentsService = new AdaptivePaymentsService($sdkConfig);
     $payResponse = $adaptivePaymentsService->Pay($payRequest);
     if ($payResponse->payKey) {
         $shippingAddressInfo = new ShippingAddressInfo();
         $shippingAddressInfo->addresseeName = $order->billing_first_name . ' ' . $order->billing_last_name;
         $shippingAddressInfo->street1 = $order->billing_address_1;
         $shippingAddressInfo->street2 = $order->billing_address_2;
         $shippingAddressInfo->city = $order->billing_city;
         $shippingAddressInfo->zip = $order->billing_postcode;
         $shippingAddressInfo->state = $this->get_paypal_state($order->billing_country, $order->billing_state);
         $shippingAddressInfo->country = $order->billing_country;
         if ('yes' == $this->send_shipping) {
             $shippingAddressInfo->addresseeName = $order->shipping_first_name . ' ' . $order->shipping_last_name;
             $shippingAddressInfo->street1 = $order->shipping_address_1;
             $shippingAddressInfo->street2 = $order->shipping_address_2;
             $shippingAddressInfo->city = $order->shipping_city;
             $shippingAddressInfo->zip = $order->shipping_postcode;
             $shippingAddressInfo->state = $this->get_paypal_state($order->shipping_country, $order->shipping_state);
             $shippingAddressInfo->country = $order->shipping_country;
         }
         $so = new SenderOptions();
         $so->shippingAddress = $shippingAddressInfo;
         $re = new RequestEnvelope('en_US');
         $setPaymentOptionsRequest = new SetPaymentOptionsRequest($re, $payResponse->payKey);
         $setPaymentOptionsRequest->senderOptions = $so;
         $paymentOptionRequest = $adaptivePaymentsService->SetPaymentOptions($setPaymentOptionsRequest);
     }
     $this->add_log('Payment Response: ' . print_r($payResponse, true));
     // update paykey reference to find out
     update_post_meta($order->id, '_dokan_pap_key', $payResponse->payKey);
     if ('yes' == $this->testmode) {
         $paypal_url = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" . $payResponse->payKey;
     } else {
         $paypal_url = "https://www.paypal.com/webscr?cmd=_ap-payment&paykey=" . $payResponse->payKey;
     }
     // Return thankyou redirect
     return array('result' => 'success', 'redirect' => $paypal_url);
 }
Esempio n. 9
0
 public function prepareDirectPayment($paymentData)
 {
     if (isset($paymentData['receiver'])) {
         $receiver = array();
         $i = 0;
         $receiver[$i] = new Receiver();
         $receiver[$i]->email = $paymentData['receiver']['paypal_email'];
         /*
          *  	Amount to be credited to the receiver's account 
          */
         $receiver[$i]->amount = $paymentData['receiver']['amount'];
         /*
          * Set to true to indicate a chained payment; only one receiver can be a primary receiver. Omit this field, or set it to false for simple and parallel payments. 
          */
         $receiver[$i]->primary = $paymentData['receiver']['primary'];
         /*
          * (Optional) The invoice number for the payment. This data in this field shows on the Transaction Details report. Maximum length: 127 characters 
          */
         if (isset($paymentData['invoiceId']) && !empty($paymentData['invoiceId'])) {
             $receiver[$i]->invoiceId = $paymentData['invoiceId'];
         }
         /*
         * (Optional) The transaction type for the payment. Allowable values are:
         		
         					GOODS – This is a payment for non-digital goods
         					SERVICE – This is a payment for services (default)
         					PERSONAL – This is a person-to-person payment
         					CASHADVANCE – This is a person-to-person payment for a cash advance
         					DIGITALGOODS – This is a payment for digital goods
         					BANK_MANAGED_WITHDRAWAL – This is a person-to-person payment for bank withdrawals, available only with special permission.
         				
         				Note: Person-to-person payments are valid only for parallel payments that have the feesPayer field set to EACHRECEIVER or SENDER.
         */
         if (isset($paymentData['paymentType']) && !empty($paymentData['paymentType'])) {
             $receiver[$i]->paymentType = $paymentData['paymentType'];
         }
         $receiverList = new ReceiverList($receiver);
     }
     /*
     		 * The action for this request. Possible values are:
     		
     			PAY – Use this option if you are not using the Pay request in combination with ExecutePayment.
     			CREATE – Use this option to set up the payment instructions with SetPaymentOptions and then execute the payment at a later time with the ExecutePayment.
     			PAY_PRIMARY – For chained payments only, specify this value to delay payments to the secondary receivers; only the payment to the primary receiver is processed.
     */
     /*
      * The code for the currency in which the payment is made; you can specify only one currency, regardless of the number of receivers 
      */
     /*
      * URL to redirect the sender's browser to after canceling the approval for a payment; it is always required but only used for payments that require approval (explicit payments) 
      */
     /*
      * URL to redirect the sender's browser to after the sender has logged into PayPal and approved a payment; it is always required but only used if a payment requires explicit approval 
      */
     $payRequest = new PayRequest(new RequestEnvelope("en_US"), $paymentData['actionType'], $paymentData['cancelUrl'], $paymentData['currencyCode'], $receiverList, $paymentData['returnUrl']);
     // Add optional params
     /*
     		 *  (Optional) The payer of PayPal fees. Allowable values are:
     		
     			SENDER – Sender pays all fees (for personal, implicit simple/parallel payments; do not use for chained or unilateral payments)
     			PRIMARYRECEIVER – Primary receiver pays all fees (chained payments only)
     			EACHRECEIVER – Each receiver pays their own fee (default, personal and unilateral payments)
     			SECONDARYONLY – Secondary receivers pay all fees (use only for chained payments with one secondary receiver)
     */
     if (isset($paymentData['feesPayer']) && !empty($paymentData['feesPayer'])) {
         $payRequest->feesPayer = $paymentData['feesPayer'];
     }
     /*
     *  (Optional) The key associated with a preapproval for this payment. The preapproval key is required if this is a preapproved payment.
     		Note: The Preapproval API is unavailable to API callers with Standard permission levels.
     */
     if (isset($paymentData['preapprovalKey']) && !empty($paymentData['preapprovalKey'])) {
         $payRequest->preapprovalKey = $paymentData['preapprovalKey'];
     }
     /*
      * (Optional) The URL to which you want all IPN messages for this payment to be sent. Maximum length: 1024 characters 
      */
     if (isset($paymentData['ipnNotificationUrl']) && !empty($paymentData['ipnNotificationUrl'])) {
         $payRequest->ipnNotificationUrl = $_POST['ipnNotificationUrl'];
     }
     if (isset($paymentData['memo']) && !empty($paymentData['memo'])) {
         $payRequest->memo = $paymentData["memo"];
     }
     /*
     *(Optional) A unique ID that you specify to track the payment.
     		Note: You are responsible for ensuring that the ID is unique. 
     */
     if (isset($paymentData['trackingId']) && !empty($paymentData['trackingId'])) {
         $payRequest->trackingId = $_POST["trackingId"];
     }
     $service = new AdaptivePaymentsService($this->getAcctAndConfig());
     try {
         /* wrap API method calls on the service object with a try catch */
         $response = $service->Pay($payRequest);
     } catch (PayPal\Exception\PPConnectionException $ex) {
     } catch (Exception $ex) {
     }
     /* Make the call to PayPal to get the Pay token
     		 If the API call succeded, then redirect the buyer to PayPal
     		to begin to authorize payment.  If an error occured, show the
     		resulting errors */
     $ack = strtoupper($response->responseEnvelope->ack);
     if ($ack != "SUCCESS") {
         return (object) array("success" => false, "message" => "");
     } else {
         $payKey = $response->payKey;
         $payPalURL = PAYPAL_REDIRECT_URL . '_ap-payment&paykey=' . $payKey;
         return (object) array("success" => true, "message" => "", "payurl" => $payPalURL, "payKey" => $payKey);
     }
 }