Exemplo n.º 1
0
 private function handle_validated_ipn($data)
 {
     if (isset($data['payment_status'])) {
         if ($data['payment_status'] == 'Completed' || $data['payment_status'] == 'Reversed' || $data['payment_status'] == 'Canceled_Reversal') {
             $transaction = new Transaction();
             $transaction->id = $data['txn_id'];
             $transaction->gross = $data['mc_gross'];
             $transaction->fee = $data['mc_fee'];
             $transaction->sender = new Customer($data['payer_email']);
             $transaction->sender->name = $data['first_name'] . ' ' . $data['last_name'];
             $transaction->sender->businessName = empty($data['payer_business_name']) ? null : $data['payer_business_name'];
             $transaction->sender->ip = $data['custom'];
             $transaction->sender->email = $data['payer_email'];
             $transaction->sender->contactPhone = empty($data['contact_phone']) ? null : $data['contact_phone'];
             $transaction->sender->address->street = $data['address_street'];
             $transaction->sender->address->postcode = $data['address_zip'];
             $transaction->sender->address->state = $data['address_state'];
             $transaction->sender->address->city = $data['address_city'];
             $transaction->sender->address->country = $data['address_country_code'];
             $order = new Order($transaction->gross);
             $order->setName($data['item_name']);
             $order->setItem($data['item_number']);
             $order->additional = $data;
             $transaction->order = $order;
             $payment_status = $data['payment_status'];
             if ($data['payment_status'] == 'Completed') {
                 return new PaymentCompleteMessage($transaction);
             } elseif ($payment_status == 'Reversed') {
                 return new ReversalMessage('', $transaction);
             } elseif ($payment_status == 'Canceled_Reversal') {
                 return new FundsReturnMessage('', $transaction);
             }
         } else {
             return new IPNErrorMessage("Unknown message: " . $data['payment_status']);
         }
     }
     //A message that we dont care about
     return null;
 }
Exemplo n.º 2
0
 function ipn()
 {
     $post_data = file_get_contents("php://input");
     $invoice = $this->bitPay->verifyNotification($post_data);
     if (!is_object($invoice)) {
         return new IPNErrorMessage("Not valid IPN");
     }
     //Check the status
     if ($invoice->status == 'confirmed' || $invoice->status == 'complete') {
         $transaction = new Transaction();
         $transaction->id = $invoice->id;
         $transaction->gross = $invoice->price;
         $transaction->fee = 0;
         $order = new Order($transaction->gross);
         list($name, $item) = explode('|', $invoice->posData);
         $order->setName($name);
         $order->setItem($item);
         $transaction->order = $order;
         return new PaymentCompleteMessage($transaction);
     }
     //A message that we dont care about
     return null;
 }
Exemplo n.º 3
0
 private function handle_validated_ipn($data)
 {
     if (isset($data['ap_transactionstate'])) {
         if (true) {
             //todo
             $transaction = new Transaction();
             $transaction->id = $data['ap_referencenumber'];
             $transaction->gross = $data['ap_totalamount'];
             $transaction->fee = $data['ap_feeamount'];
             $transaction->sender = new Customer($data['ap_custemailaddress']);
             $transaction->sender->email = $data['ap_custemailaddress'];
             $transaction->sender->name = $data['ap_custfirstname'] . ' ' . $data['ap_custlastname'];
             $transaction->sender->businessName = null;
             $transaction->sender->ip = $data['apc_1'];
             $transaction->sender->address->street = $data['ap_custaddress'];
             $transaction->sender->address->postcode = $data['ap_custzip'];
             $transaction->sender->address->state = $data['ap_custstate'];
             $transaction->sender->address->city = $data['ap_custcity'];
             $transaction->sender->address->country = $data['ap_custcountry'];
             $order = new Order($transaction->gross);
             $order->setName($data['ap_itemname']);
             $order->setItem($data['ap_itemcode']);
             $order->setAdditional($data);
             $transaction->order = $order;
             $payment_status = $data['ap_transactionstate'];
             if ($data['ap_notificationtype'] == 'New' && ($payment_status == 'Completed' || $payment_status == 'On Hold')) {
                 return new PaymentCompleteMessage($transaction);
             } elseif ($payment_status == 'Reversed') {
                 return new ReversalMessage('', $transaction);
             } elseif ($payment_status == 'Refunded') {
                 return new FundsReturnMessage('', $transaction);
             }
         }
     }
     //A message that we dont care about
     return null;
 }