/** * Init call to webservice or return form params * * @see http://www.onebip.com/website/docs/Onebip_API.pdf * @param Payment_Invoice $invoice */ public function singlePayment(Payment_Invoice $invoice) { $data = array(); $data['username'] = $this->getParam('username'); $data['description'] = $invoice->getTitle(); $data['price'] = $invoice->getTotalWithTax() * 100; $data['currency'] = $invoice->getCurrency(); $data['command'] = 'standard_pay'; $data['item_code'] = $invoice->getId(); $data['return_url'] = $this->getParam('return_url'); $data['notify_url'] = $this->getParam('notify_url'); $data['cancel_url'] = $this->getParam('cancel_url'); $c = $invoice->getBuyer(); $data['customer_email'] = $c->getEmail(); $data['customer_firstname'] = $c->getFirstName(); $data['customer_lastname'] = $c->getLastName(); if ($c->getPhone()) { $data['customer_cell'] = $c->getPhone(); } if ($c->getCountry()) { $data['customer_country'] = $c->getCountry(); } if ($this->testMode) { $data['debug'] = 1; $data['debug_url'] = $this->getParam('notify_url'); } $data['logo_url'] = $this->getParam('logo_url'); return $data; }
public function ipn($data, Payment_Invoice $invoice) { $tx = new Payment_Transaction(); $tx->setAmount($invoice->getTotal()); $tx->setCurrency($invoice->getCurrency()); $tx->setId(md5(uniqid($invoice->getNumber()))); $tx->setIsValid(true); $tx->setStatus(Payment_Transaction::STATUS_COMPLETE); $tx->setType(Payment_Transaction::TXTYPE_PAYMENT); return $tx; }
public function singlePayment(Payment_Invoice $invoice) { $params = array('merchantID' => $this->getParam('merchantId'), 'SubID' => (int) $this->getParam('subId'), 'amount' => (int) ($invoice->getTotal() * 100), 'purchaseID' => $invoice->getNumber(), 'currency' => $invoice->getCurrency(), 'hash' => $this->_getHash($invoice), 'paymentType' => 'iDEAL', 'validUntil' => $this->_getValidUntil(), 'urlSuccess' => $this->getParam('return_url'), 'urlCancel' => $this->getParam('cancel_url'), 'urlError' => $this->getParam('return_url'), 'urlService' => $this->getParam('notify_url')); $i = 1; foreach ($invoice->getItems() as $item) { $params['itemNumber' . $i] = $item->getId(); $params['itemDescription' . $i] = $item->getDescription(); $params['itemQuantity' . $i] = $item->getQuantity(); $params['itemPrice' . $i] = (int) ($item->getPrice() * 100); $i++; } return $params; }
/** * @see http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API_Tag_Reference.html */ public function singlePayment(Payment_Invoice $invoice) { //replace in text nodes $what = array('&', '<', '>'); $to = array('&', '<', '>'); $xml = new DOMDocument('1.0', 'UTF-8'); $root = $xml->createElement('checkout-shopping-cart'); $root->setAttribute('xmlns', 'http://checkout.google.com/schema/2'); $xml->appendChild($root); $shoppingCart = $xml->createElement('shopping-cart'); $root->appendChild($shoppingCart); $items = $xml->createElement('items'); $shoppingCart->appendChild($items); foreach ($invoice->getItems() as $i) { $item = $xml->createElement('item'); $itemName = $xml->createElement('item-name', str_replace($what, $to, $i->getTitle())); $itemDescription = $xml->createElement('item-description', str_replace($what, $to, $i->getDescription())); $unitPrice = $xml->createElement('unit-price', $i->getPrice()); $unitPrice->setAttribute('currency', $invoice->getCurrency()); $quantity = $xml->createElement('quantity', $i->getQuantity()); $digitalContent = $xml->createElement('digital-content'); $description = $xml->createElement('description', str_replace($what, $to, '<a href="' . $this->getParam('return_url') . '">Click here to return to site</a>')); $digitalContent->appendChild($description); $item->appendChild($itemName); $item->appendChild($itemDescription); $item->appendChild($unitPrice); $item->appendChild($quantity); $item->appendChild($digitalContent); $items->appendChild($item); } $checkoutFlowSupport = $xml->createElement('checkout-flow-support'); $root->appendChild($checkoutFlowSupport); $merchantCheckoutSupport = $xml->createElement('merchant-checkout-flow-support'); $checkoutFlowSupport->appendChild($merchantCheckoutSupport); $continueShoppingUrl = $xml->createElement('continue-shopping-url', str_replace($what, $to, $this->getParam('continue_shopping_url'))); $merchantCheckoutSupport->appendChild($continueShoppingUrl); $merchantPrivateDdata = $xml->createElement('merchant-private-data'); $shoppingCart->appendChild($merchantPrivateDdata); $invoiceId = $xml->createElement('invoice', $invoice->getNumber()); $merchantPrivateDdata->appendChild($invoiceId); $str = $xml->saveXML(); $response = $this->_makeRequest($str); if (isset($response->{'redirect-url'})) { return urldecode($response->{'redirect-url'}); } else { throw new Payment_Exception('Connection to Google Checkout servers failed'); } return false; }
public function singlePayment(Payment_Invoice $invoice) { $c = $invoice->getBuyer(); $params = array('ap_merchant' => $this->getParam('email'), 'ap_purchasetype' => 'service', 'ap_currency' => $invoice->getCurrency(), 'ap_alerturl' => $this->getParam('notify_url'), 'ap_returnurl' => $this->getParam('return_url'), 'ap_cancelurl' => $this->getParam('cancel_url'), 'ap_fname' => $c->getFirstName(), 'ap_lname' => $c->getLastName(), 'ap_contactemail' => $c->getEmail(), 'ap_contactphone' => $c->getPhone(), 'ap_addressline1' => $c->getAddress(), 'ap_city' => $c->getCity(), 'ap_stateprovince' => $c->getState(), 'ap_zippostalcode' => $c->getZip(), 'ap_country' => $c->getCountry(), 'apc_1' => $invoice->getId(), 'apc_2' => $invoice->getNumber()); $i = 1; foreach ($invoice->getItems() as $item) { $params['ap_itemcode_' . $i] = $item->getId(); $params['ap_itemname_' . $i] = $item->getTitle(); $params['ap_description_' . $i] = $item->getDescription(); $params['ap_amount_' . $i] = $item->getPrice() + $item->getTax(); $params['ap_quantity_' . $i] = $item->getQuantity(); $i++; } return $params; }
public function recurrentPayment(Payment_Invoice $invoice) { $recurrenceInfo = $invoice->getSubscription(); $amount = $invoice->getCurrency() . ' ' . $invoice->getTotalWithTax(); $description = $invoice->getTitle(); $promotionAmount = 0; $processImmediate = true; $immediateReturn = true; $referenceId = $invoice->getId(); $recurringStartDate = ""; $recurringFrequency = $this->_getRecurringFrequency($recurrenceInfo); // '1 month' $subscriptionPeriod = ""; //'12 months'; $formHiddenInputs['accessKey'] = $this->getParam('AWSAccessKeyId'); $formHiddenInputs['amount'] = $amount; $formHiddenInputs['description'] = $description; $formHiddenInputs['recurringFrequency'] = $recurringFrequency; $formHiddenInputs['subscriptionPeriod'] = $subscriptionPeriod; $formHiddenInputs['recurringStartDate'] = $recurringStartDate; $formHiddenInputs['promotionAmount'] = $promotionAmount; $formHiddenInputs['referenceId'] = $referenceId; $formHiddenInputs['immediateReturn'] = true; $formHiddenInputs['ipnUrl'] = $this->getParam('notify_url'); $formHiddenInputs['returnUrl'] = $this->getParam('return_url'); $formHiddenInputs['abandonUrl'] = $this->getParam('cancel_url'); $formHiddenInputs['processImmediate'] = $processImmediate; uksort($formHiddenInputs, "strnatcasecmp"); $stringToSign = ""; foreach ($formHiddenInputs as $formHiddenInputName => $formHiddenInputValue) { $stringToSign = $stringToSign . $formHiddenInputName . $formHiddenInputValue; } $formHiddenInputs['signature'] = $this->_getSignature($stringToSign); //throw new Exception(print_r($formHiddenInputs, 1)); return $formHiddenInputs; }
public function getTransaction($data, Payment_Invoice $invoice) { $ipn = $data['post']; $tx = new Payment_Transaction(); $tx->setId($ipn['x_trans_id']); $tx->setType(Payment_Transaction::TXTYPE_PAYMENT); $tx->setAmount($ipn['x_amount']); $tx->setCurrency($invoice->getCurrency()); if (isset($ipn['x_response_code'])) { switch ($ipn['x_response_code']) { //Approved case '1': $tx->setStatus(Payment_Transaction::STATUS_COMPLETE); break; case '2': // Declined // Declined case '3': // Error // Error case '4': // Held for Review $tx->setStatus(Payment_Transaction::STATUS_PENDING); break; default: throw new Payment_Exception('Authorize.net unknown x_response_code'); } } return $tx; }
/** * Init single payment call to webservice * Invoice id is passed via notify_url * * @return string */ public function singlePayment(Payment_Invoice $invoice) { $buyer = $invoice->getBuyer(); return WebToPay::buildRequest(array('projectid' => $this->getParam('projectid'), 'sign_password' => $this->getParam('sign_password'), 'orderid' => $invoice->getNumber(), 'amount' => $this->moneyFormat($invoice->getTotalWithTax()), 'currency' => $invoice->getCurrency(), 'accepturl' => $this->getParam('return_url'), 'cancelurl' => $this->getParam('cancel_url'), 'callbackurl' => $this->getParam('notify_url'), 'paytext' => $invoice->getTitle(), 'p_firstname' => $buyer->getFirstName(), 'p_lastname' => $buyer->getLastName(), 'p_email' => $buyer->getEmail(), 'p_street' => $buyer->getAddress(), 'p_city' => $buyer->getCity(), 'p_state' => $buyer->getState(), 'p_zip' => $buyer->getZip(), 'p_countrycode' => $buyer->getCountry(), 'lang' => 'ENG', 'test' => $this->testMode)); }
/** * Init single payment call to webservice * Invoice id is passed via notify_url * * @param Payment_Invoice $invoice * @return array */ public function singlePayment(Payment_Invoice $invoice) { return array('ik_co_id' => $this->getParam('ik_co_id'), 'ik_pm_no' => $invoice->getId(), 'ik_am' => $invoice->getTotal(), 'ik_desc' => $invoice->getTitle(), 'ik_cur' => $invoice->getCurrency(), 'ik_ia_u' => $this->getParam('notify_url'), 'ik_ia_m' => 'post', 'ik_suc_u' => $this->getParam('return_url'), 'ik_suc_m' => 'get', 'ik_pnd_u' => $this->getParam('return_url'), 'ik_pnd_m' => 'get', 'ik_fal_u' => $this->getParam('cancel_url'), 'ik_fal_m' => 'get', 'ik_x_iid' => $invoice->getId()); }
/** * Handle IPN and return response object * @return Payment_Transaction */ public function getTransaction($data, Payment_Invoice $invoice) { $ipn = $data['post']; $client = $this->_getSoapClient(); $Pay_Status = 'FAIL'; $terminalId = $this->getParam('terminalId'); $userName = $this->getParam('userName'); $userPassword = $this->getParam('userPassword'); $refId = $ipn['RefId']; $resCode = $ipn['ResCode']; $orderId = $ipn['SaleOrderId']; $verifySaleOrderId = $ipn['SaleOrderId']; $verifySaleReferenceId = $ipn['SaleReferenceId']; $parameters = array('terminalId' => $terminalId, 'userName' => $userName, 'userPassword' => $userPassword, 'orderId' => $orderId, 'saleOrderId' => $verifySaleOrderId, 'saleReferenceId' => $verifySaleReferenceId); error_log('Parameters: ' . print_r($parameters, 1)); $result = $client->bpVerifyRequest($parameters); $VerifyAnswer = $result->return; error_log('Verify answer:' . $VerifyAnswer); if ($VerifyAnswer == '0') { // Call the SOAP method $result = $client->bpSettleRequest($parameters); $SetlleAnswer = $result->return; error_log('Settle answer:' . $SetlleAnswer); if ($SetlleAnswer == '0') { $Pay_Status = 'OK'; } } if ($VerifyAnswer != '0' and $VerifyAnswer != '') { $result = $client->bpInquiryRequest($parameters); $InquiryAnswer = $result->return; error_log('Inquiry Answer:' . $InquiryAnswer); if ($InquiryAnswer == '0') { // Call the SOAP method $result = $client->bpSettleRequest($parameters); $SetlleAnswer = $result->return; error_log('Second Settle Answer:' . $InquiryAnswer); if ($SetlleAnswer == '0') { $Pay_Status = 'OK'; } } else { // Call the SOAP method $result = $client->bpReversalRequest($parameters); $ReversalAnswer = $result->return; error_log('Reversal request Answer:' . $ReversalAnswer); } } if ($Pay_Status != 'OK') { throw new Payment_Exception('Sale verification failed: ' . $VerifyAnswer); } $response = new Payment_Transaction(); $response->setType(Payment_Transaction::TXTYPE_PAYMENT); $response->setId($refId); $response->setAmount($invoice->getTotalWithTax()); $response->setCurrency($invoice->getCurrency()); $response->setStatus(Payment_Transaction::STATUS_COMPLETE); return $response; }
public function getTransaction($data, Payment_Invoice $invoice) { $ipn = $data['post']; $uniqid = md5($ipn['trade_no'] . $ipn['trade_status']); $tx = new Payment_Transaction(); $tx->setId($uniqid); $tx->setAmount($ipn['total_fee']); $tx->setCurrency($invoice->getCurrency()); $contract = $this->getParam('type'); if ($contract == '1') { switch ($ipn['trade_status']) { case 'TRADE_SUCCESS': case 'TRADE_FINISHED': $tx->setType(Payment_Transaction::TXTYPE_PAYMENT); $tx->setStatus(Payment_Transaction::STATUS_COMPLETE); break; default: $tx->setStatus($ipn['trade_status']); break; } } if ($contract == '2') { switch ($ipn['trade_status']) { case 'WAIT_SELLER_SEND_GOODS': $tx->setType(Payment_Transaction::TXTYPE_PAYMENT); $tx->setStatus(Payment_Transaction::STATUS_COMPLETE); break; default: $tx->setStatus($ipn['trade_status']); break; } } return $tx; }
public function getTransaction($data, Payment_Invoice $invoice) { $ipn = $data['post']; //@todo $response = new Payment_Transaction(); $response->setType(Payment_Transaction::TXTYPE_PAYMENT); $response->setId(uniqid()); $response->setAmount($invoice->getTotalWithTax()); $response->setCurrency($invoice->getCurrency()); $response->setStatus(Payment_Transaction::STATUS_COMPLETE); return $response; }
public function singlePayment(Payment_Invoice $invoice) { $c = $invoice->getBuyer(); $params = array('pay_to_email' => $this->getParam('email'), 'transaction_id' => $invoice->getNumber(), 'return_url' => $this->getParam('return_url'), 'cancel_url' => $this->getParam('cancel_url'), 'status_url' => $this->getParam('notify_url'), 'merchant_fields' => 'invoice_id', 'invoice_id' => $invoice->getNumber(), 'pay_from_email' => $c->getEmail(), 'firstname' => $c->getFirstname(), 'lastname' => $c->getLastname(), 'address' => $c->getAddress(), 'phone_number' => $c->getPhone(), 'postal_code' => $c->getZip(), 'city' => $c->getCity(), 'state' => $c->getState(), 'country' => $c->getCountry(), 'amount' => $invoice->getTotal(), 'currency' => $invoice->getCurrency()); return $params; }
/** * @see http://www.libertyreserve.com/en/help/sciguide * @param Payment_Invoice $invoice * @return array - list of parameters to be posted to serviceUrl via POST method */ public function singlePayment(Payment_Invoice $invoice) { $params = array('lr_acc' => $this->getParam('accountNumber'), 'lr_amnt' => $invoice->getTotal(), 'lr_currency' => 'LR' . $invoice->getCurrency(), 'lr_merchant_ref' => $invoice->getNumber(), 'lr_success_url' => $this->getParam('return_url'), 'lr_success_url_method' => 'GET', 'lr_fail_url' => $this->getParam('cancel_url'), 'lr_fail_url_method' => 'GET', 'lr_status_url' => $this->getParam('notify_url'), 'lr_status_url_method' => 'POST', 'lr_comments' => $invoice->getTitle(), 'bb_invoice_id' => $invoice->getId()); return $params; }
public function getTransaction($data, Payment_Invoice $invoice) { $ipn = $data['post']; $tx = new Payment_Transaction(); $tx->setId($ipn['sign']); $tx->setAmount($ipn['total_fee']); $tx->setCurrency($invoice->getCurrency()); $tx->setType(Payment_Transaction::TXTYPE_PAYMENT); switch ($ipn['trade_status']) { case 'TRADE_SUCCESS': case 'TRADE_FINISHED': //case 'WAIT_SELLER_SEND_GOODS': $tx->setStatus(Payment_Transaction::STATUS_COMPLETE); break; default: throw new Payment_Exception('Unknown AliPay IPN status :' . $ipn['trade_status']); break; } return $tx; }