function create_paypal_AutoBill($account, $paymentmethod)
{
    $ipAddress = '127.0.0.1';
    $uniqueValue = get_unique_value();
    $merchantAutoBillId = 'ab-' . $uniqueValue;
    $merchantProductId = 'mm_1_day_recurring';
    //'Video';
    $merchantBillingPlanId = 'Daily';
    //'OneMonthSubOneMonthRecurring';
    $autobill = new AutoBill();
    $autobill->setMerchantAutoBillId($merchantAutoBillId);
    $autobill->setAccount($account);
    $product = new Product();
    $product->setMerchantProductId($merchantProductId);
    $billingplan = new BillingPlan();
    $billingplan->setMerchantBillingPlanId($merchantBillingPlanId);
    $item = new AutoBillItem();
    $item->setIndex(0);
    $item->setProduct($product);
    $autobill->setItems(array($item));
    $autobill->setSourceIp($ipAddress);
    $autobill->setBillingPlan($billingplan);
    $autobill->setCurrency('USD');
    $autobill->setPaymentMethod($paymentmethod);
    // Set PaymentMethod used by AutoBill
    //$duplicateBehavior = 'Fail'; //removed in 9.0
    //$validatePaymentMethod = true; //removed in 9.0
    $immediateAuthFailurePolicy = 'doNotSaveAutoBill';
    //added in 9.0
    $validateForFuturePayment = true;
    //added in 9.0
    $minChargebackProbability = 100;
    $ignoreAvsPolicy = true;
    $ignoreCvnPolicy = true;
    $campaignCode = null;
    $dryrun = false;
    $response = $autobill->update($immediateAuthFailurePolicy, $validateForFuturePayment, $minChargebackProbability, $ignoreAvsPolicy, $ignoreCvnPolicy, $campaignCode, $dryrun);
    if ($response['returnCode'] != '200') {
        print 'Error creating autobill' . PHP_EOL;
        print 'Soap Id = ' . $response['data']->return->soapId . PHP_EOL;
        print 'Return Code = ' . $response['returnCode'] . PHP_EOL;
        print 'Return String = ' . $response['returnString'] . PHP_EOL;
    } else {
        $response_object = $response['data'];
        $auth_status = $response_object->authStatus;
        if ($auth_status->status == 'AuthorizationPending') {
            $redirection_url = $auth_status->payPalStatus->redirectUrl;
            echo "To authorize, please visit: <a href=\"" . $redirection_url . "\">Continue to Paypal</a>" . PHP_EOL;
        } else {
            if ($auth_status->status == 'Cancelled') {
                echo "Autobill not accepted by PayPal";
            } else {
                echo "Status = " . $auth_status->status;
            }
        }
    }
    return $redirection_url;
}
 public function setLimit(Model $Model, $data = array())
 {
     if (!empty($data)) {
         $Model->set($data);
     }
     if (empty($Model->data[$Model->alias])) {
         return false;
     }
     $limitField = $this->settings[$Model->alias]['limitField'];
     if (!isset($Model->data[$Model->alias][$limitField])) {
         $billingPlanModel = new BillingPlan();
         $limitValue = $billingPlanModel->field($limitField, array('id' => $Model->data[$Model->alias]['plan_id']));
         $Model->data[$Model->alias][$limitField] = $limitValue;
     }
     $scope = $this->settings[$Model->alias]['scope'];
     $remoteModel = $this->settings[$Model->alias]['remoteModel'];
     App::import('Model', $remoteModel);
     $remoteModel = new $remoteModel();
     if (in_array($Model->data[$Model->alias]['user_id'], $this->ownersWhitelist)) {
         $Model->data[$Model->alias][$limitField] = 199999999999;
     }
     $result = $remoteModel->updateAll(array($remoteModel->alias . '.' . $this->settings[$Model->alias]['remoteField'] => $Model->data[$Model->alias][$limitField]), array($remoteModel->alias . '.' . $scope => $Model->data[$Model->alias]['user_id']));
     if ($result) {
         //hardcoded group members manipulation
         if ($remoteModel == 'GroupLimit') {
             $this->membersOperate($Model);
         }
         return true;
     }
     return false;
 }
function create_ecp_AutoBill($account)
{
    $ipAddress = '127.0.0.1';
    $uniqueValue = get_unique_value();
    $merchantAutoBillId = 'ab-' . $uniqueValue;
    $merchantProductId = 'git_hub_product';
    $merchantBillingPlanId = 'git_hub_example';
    $autobill = new AutoBill();
    $autobill->setMerchantAutoBillId($merchantAutoBillId);
    $autobill->setAccount($account);
    $product = new Product();
    $product->setMerchantProductId($merchantProductId);
    $billingplan = new BillingPlan();
    $billingplan->setMerchantBillingPlanId($merchantBillingPlanId);
    $item = new AutoBillItem();
    $item->setIndex(0);
    $item->setProduct($product);
    $autobill->setItems(array($item));
    $autobill->setSourceIp($ipAddress);
    $autobill->setBillingPlan($billingplan);
    $autobill->setCurrency('USD');
    //$duplicateBehavior = 'Fail'; //removed in 9.0
    //$validatePaymentMethod = true; //removed in 9.0
    $immediateAuthFailurePolicy = 'doNotSaveAutoBill';
    //added in 9.0
    $validateForFuturePayment = true;
    //added in 9.0
    $minChargebackProbability = 100;
    $ignoreAvsPolicy = true;
    $ignoreCvnPolicy = true;
    $campaignCode = null;
    $dryrun = false;
    $response = $autobill->update($immediateAuthFailurePolicy, $validateForFuturePayment, $minChargebackProbability, $ignoreAvsPolicy, $ignoreCvnPolicy, $campaignCode, $dryrun);
    if ($response['returnCode'] != '200') {
        print 'Error creating autobill' . PHP_EOL;
        print 'Soap Id = ' . $response['data']->return->soapId . PHP_EOL;
        print 'Return Code = ' . $response['returnCode'] . PHP_EOL;
        print 'Return String = ' . $response['returnString'] . PHP_EOL;
    } else {
        $response_object = $response['data'];
        $auth_status = $response_object->authStatus;
        if ($auth_status->status == 'AuthorizedForValidation') {
            echo "ECP payment in AuthorizedForValidation status, this is a successful test of ECP." . PHP_EOL;
        } else {
            if ($auth_status->status == 'Cancelled') {
                echo "Validation of ECP failed.";
            } else {
                echo "Status = " . $auth_status->status;
            }
        }
    }
    return $auth_status->status;
}
function Step3MigrateVideoMember($merchantAccountId)
{
    $uniqueValue = $merchantAccountId;
    //Step 3
    //Assume that this subscription is for Video access for one year, and was paid in full 6 months ago.
    //As such it will be up for renewal in 6 months.
    //Generally, these dates are retrieved from your datastore.
    $sixmonthsagoPT = new \DateTime('-6 months', new \DateTimeZone('America/Los_Angeles'));
    $sixmonthsfromnowPT = new \DateTime('6 months', new \DateTimeZone('America/Los_Angeles'));
    $dateActiveSubscriptionPeriodPaidInFull = $sixmonthsagoPT->format(DateTime::ATOM);
    $dateActiveSubscriptionPeriodUpForRenewal = $sixmonthsfromnowPT->format(DateTime::ATOM);
    $billPlan = new BillingPlan();
    $product = new Product();
    // Generally, the billing plan and productid will be provided in your datastore.
    // These objects need to exist in CashBox prior to migration.
    $merchantBillingPlanId = 'OneYearSubOneYearRecurring';
    $merchantProductId = 'Video';
    $billPlan->setMerchantBillingPlanId($merchantBillingPlanId);
    $product->setMerchantProductId($merchantProductId);
    //To save a soap call, you can use sparse objects.
    $account = new Account();
    $account->merchantAccountId = $merchantAccountId;
    // Assuming merchantPaymentMethodId is the same value as the merchantAccountId.
    $merchantPaymentMethodId = $merchantAccountId;
    $paymentMethod = new PaymentMethod();
    $paymentMethod->merchantPaymentMethodId = $merchantPaymentMethodId;
    //If you don't have the address VID, then set migrationtransaction shippingaddress to null.
    $address = null;
    //    // If you want to fetch the account by making a soap call to CashBox...
    //    // This is a soap call to CashBox.
    //    $fetchedAccount = get_account_by_merchantAccountId($merchantAccountId);
    //
    //    // Only use sparse object, so all data members are not over-written.
    //    $account->merchantAccountId = $fetchedAccount->merchantAccountId;
    //    $fetchedPaymentMethod = $account->paymentMethods[0];
    //
    //    // Only use sparse object, so all data members are not over-written.
    //    $paymentMethod->merchantPaymentMethodId = $fetchedPaymentMethod->merchantPaymentMethodId;
    $paymentMethodType = 'CreditCard';
    $currency = 'USD';
    $lastPaidPrice = '10.00';
    $useZeroUnlessYouKnowDifferent = 0;
    $paymentProcessor = 'Paymentech';
    $transactionType = 'Recurring';
    $authCode = '000';
    $capturedStatus = 'Captured';
    $txItemType = 'RecurringCharge';
    $txItemName = $merchantProductId . ':' . $merchantBillingPlanId;
    // This paymentProcessorTransactionId makes the transaction refundable if migrating from Litle (Vantiv) into Litle.
    $paymentProcessorTransactionId = 'RetrievedIdFromLegacyBillingPaymentProcessor';
    // Assume campaigns were not used when creating this Autobill.
    // Alternatively, consider specifying campaign on the AutoBillItem if necessary.
    $item = new AutoBillItem();
    $item->setIndex(0);
    $item->setAddedDate($dateActiveSubscriptionPeriodPaidInFull);
    $item->setMerchantAutoBillItemId(get_unique_value());
    $item->setProduct($product);
    $autobill = new AutoBill();
    // No need to set payment method on Autobill as it will be inherited from the Account.
    $autobill->setAccount($account);
    $autobill->setItems(array($item));
    $autobill->setBillingPlan($billPlan);
    $autobill->setCurrency($currency);
    $autobill->setCustomerAutoBillName($uniqueValue);
    $autobill->setMerchantAutoBillId($uniqueValue);
    $autobill->setStartTimestamp($dateActiveSubscriptionPeriodPaidInFull);
    // For this example, we assume one transaction item with a price equal to the entire migration transaction amount.
    $txItemA = new MigrationTransactionItem();
    $txItemA->setItemType($txItemType);
    $txItemA->setName($txItemName);
    $txItemA->setPrice($lastPaidPrice);
    $txItemA->setServicePeriodStartDate($dateActiveSubscriptionPeriodPaidInFull);
    $txItemA->setServicePeriodEndDate($dateActiveSubscriptionPeriodUpForRenewal);
    // It is recommended Sku equals the merchantProductId of the Product set on the Autobill.
    $txItemA->setSku($merchantProductId);
    $creditCardStatusA = new TransactionStatusCreditCard();
    $statusLogA = new TransactionStatus();
    // AuthCode is the code for a transaction successfully run through the payment processor.
    $creditCardStatusA->setAuthCode($authCode);
    $statusLogA->setCreditCardStatus($creditCardStatusA);
    $statusLogA->setPaymentMethodType($paymentMethodType);
    $statusLogA->setStatus($capturedStatus);
    $statusLogA->setTimestamp($dateActiveSubscriptionPeriodPaidInFull);
    $merchantTransactionId = $uniqueValue;
    fail_if_merchant_transaction_id_too_long($merchantTransactionId);
    // Assume sales tax calculated refunds not in scope in this example.
    // If they were, consider setting salesTaxAddress and tax migration transaction items.
    // Assume we are only migrating the last transaction used to pay for the Autobill.
    // If in scope, you have the option to migrate more than one.
    $migrationTransaction = new MigrationTransaction();
    $migrationTransaction->setAccount($account);
    // Set to 21 characters or less, or you will not be able to refund against this.
    $migrationTransaction->setMerchantTransactionId($merchantTransactionId);
    // Total migration transaction amount must equal sum of tx items.
    $migrationTransaction->setAmount($lastPaidPrice);
    // It is recommended that AutoBillCycle is set to the number of times the Autobill has renewed.
    // Make a best effort guess if exact number is unknown.
    // This will help with CashBox Reviews to determine metrics such as Lifetime Value (LTV).
    $migrationTransaction->setAutoBillCycle($useZeroUnlessYouKnowDifferent);
    $migrationTransaction->setBillingDate($dateActiveSubscriptionPeriodPaidInFull);
    // If the billing plan is modified, then the billing plan cycle resets to 0.
    // In general, if the billing has not been modified, this value will be the same as the AutoBill Cycle.
    $migrationTransaction->setBillingPlanCycle($useZeroUnlessYouKnowDifferent);
    $migrationTransaction->setCurrency($currency);
    $migrationTransaction->setPaymentProcessor($paymentProcessor);
    $migrationTransaction->setMerchantBillingPlanId($merchantBillingPlanId);
    $migrationTransaction->setMigrationTransactionItems(array($txItemA));
    $migrationTransaction->setPaymentMethod($paymentMethod);
    $migrationTransaction->setShippingAddress($address);
    $migrationTransaction->setStatusLog(array($statusLogA));
    $migrationTransaction->setType($transactionType);
    $migrationTransaction->setPaymentProcessorTransactionId($paymentProcessorTransactionId);
    //    Division ID mapping:
    //    123456 - Standard Subscription  [Default]
    //    123457 - Premium Subscription
    // CashBox merchant configuration will be configured to route automatically based on a name value pair.
    // Confirm with your Deployment Consultant the values matching the merchant configuration.
    $divisionId = new NameValuePair();
    $divisionId->setName('vin:Division');
    $divisionId->setValue('Premium Subscription');
    $migrationTransaction->setNameValues(array($divisionId));
    //$divisionNumber='123456';
    //$migrationTransaction->setDivisionNumber($divisionNumber);
    $srd = '';
    $response = $autobill->migrate($srd, $dateActiveSubscriptionPeriodUpForRenewal, array($migrationTransaction));
    // Log soap id for each API call.
    //    $log->addDebug('Method = Autobill.migrate' . PHP_EOL);
    //    $log->addDebug('Soap Id = ' . $response['data']->return->soapId . PHP_EOL);
    //    $log->addDebug('Return Code = ' . $response['returnCode'] . PHP_EOL);
    //    $log->addDebug('Return String = ' . $response['returnString'] . PHP_EOL);
    if ($response['returnCode'] == 200) {
        print "Call succeeded" . PHP_EOL;
    } else {
        print "Call failed" . PHP_EOL;
    }
    return $response;
}
Example #5
0
 function defaultRender(BillingPlan $plan = null, $short = false)
 {
     return sprintf('&nbsp;<b>%s</b> %s<br/><span class="small">%s</small><br />', $this->getTitle(false), $plan ? ___($plan->getTerms()) : "", $this->getDescription(false));
 }
<?php

ini_set('include_path', '/usr/local');
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
require_once 'Vindicia/Soap/Vindicia.php';
require_once 'Vindicia/Soap/Const.php';
$abId = $argv[1];
$bpId = $argv[2];
$effectiveDate = 'today';
$prorate = $argv[3];
$dryrun = $argv[4];
print "Modifying to use billing plan {$bpId} \n";
print "dryrun is {$dryrun} \n";
$autobill = new AutoBill();
$return = $autobill->fetchByMerchantAutoBillId($abId);
$autobillVID = $return['data']->autobill->VID;
print "VID is {$autobillVID} \n";
$modAutoBill = new AutoBill();
$modAutoBill->setVID($autobillVID);
$changeBillingPlanTo = new BillingPlan();
$changeBillingPlanTo->setMerchantBillingPlanId($bpId);
$response = $modAutoBill->modify('', $prorate, $effectiveDate, $changeBillingPlanTo, NULL, $dryrun, '');
print_r($response);
Example #7
0
 function shortRender(Product $p, BillingPlan $plan = null)
 {
     return $p->getTitle() . ' - ' . $plan->getTerms();
 }
$account->setMerchantAccountId($accountID);
// must be an existing Product
$productID = $argv[2];
print "productID is {$productID} \n";
$product = new Product();
$product->setMerchantProductId($productID);
// AutoBills may have multiple products (AutoBill Items)
$item = new AutoBillItem();
// You can apply a Campaign Code to the product here:
$item->setCampaignCode('1MonthBonusPromo');
// set the Product in the AutoBillItem
$item->setProduct($product);
// must be an existing BillingPlan
$billingplanID = $argv[3];
print "billingplanID is {$billingplanID} \n";
$billingplan = new BillingPlan();
$billingplan->setMerchantBillingPlanId($billingplanID);
// Create a random ID for our testing - This should be much more unique in a production env.
$autobillID = 'ab-random' . rand(1000, 9999999);
print "autobillID is {$autobillID} \n";
$autobill = new AutoBill();
$autobill->setItems(array($item));
$autobill->setAccount($account);
$autobill->setBillingPlan($billingplan);
$autobill->setMerchantAutoBillId($autobillID);
// You can apply a Campaign Code to the Billing Plan here:
//$autobill->setBillingPlanCampaignCode('1MonthBonusPromo');
// IP is used along with address info for fraud scoring
$autobill->setSourceIp('123.123.123.123');
// Choices for a faiure of the initial auth.  Uncomment only one at a time:
$immediateAuthFailurePolicy = 'doNotSaveAutoBill';
function createAutoBill($account, $merchantPaymentMethodId, $merchantAutoBillId, $merchantBillingPlanId, $merchantProductId, $currency)
{
    $autobill = new AutoBill();
    $autobill->setAccount($account);
    # same Account
    # AutoBills can have multiple products each in an AutoBillItem as an array:
    $item = new AutoBillItem();
    $item->setIndex(0);
    # set product to an existing product
    $product = new Product();
    $product->setMerchantProductId($merchantProductId);
    $item->setProduct($product);
    # set the Product in the AutoBillItem
    # WSDL AutoBill.items data member is set using PHP method AutoBill.setItems()
    $response = $autobill->setItems(array($item));
    # print_r ($response);
    $autobill->setMerchantAutoBillId($merchantAutoBillId);
    $autobill->setCustomerAutoBillName($merchantAutoBillId);
    # use same PaymentMethod that just validated successfully
    $pm = new PaymentMethod();
    $pm->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $autobill->setPaymentMethod($pm);
    $autobill->setCurrency($currency);
    # set billing plan to existing billing plan
    $billingplan = new BillingPlan();
    $billingplan->setMerchantBillingPlanId($merchantBillingPlanId);
    $autobill->setBillingPlan($billingplan);
    # AutoBill.update() method parameters:
    $validate = false;
    // through 8.0
    $fraudScore = 100;
    // Use this to accept cards involved in chargeback (i.e. Fraud Score=100)
    $minChargebackProbability = $fraudScore;
    $ignoreAvsPolicy = true;
    $ignoreCvnPolicy = true;
    $campaignCode = "";
    $dryrun = false;
    # 9.0 parameters
    $immediateAuthFailurePolicy = 'doNotSaveAutoBill';
    $validateForFuturePayment = $validate;
    print "\nmerchantAccountId=" . $account->getMerchantAccountId() . "\n";
    print "\tmerchantAutoBillId={$merchantAutoBillId}\n";
    print "\t\tmerchantProductId={$product->merchantProductId},";
    print "\tmerchantBillingPlanId={$merchantBillingPlanId}\n";
    print "\tminChargeBackProbability={$minChargebackProbability}\n\n";
    $response = $autobill->update('SucceedIgnore', $validate, $minChargebackProbability, $ignoreAvsPolicy, $ignoreCvnPolicy, $campaignCode, $dryrun);
    // 5.0+
    # $response = $autobill->update($immediateAuthFailurePolicy, $validateForFuturePayment,
    #					$minChargebackProbability,
    # 					$ignoreAvsPolicy, $ignoreCvnPolicy,
    #					$campaignCode, $dryrun);	// 9.0
    echo "\n";
    # print_r ($response);
    $createAutoBill_soapId = $response['data']->return->soapId;
    print "createAutoBill(): soapId = " . $createAutoBill_soapId;
}
Example #10
0
 function defaultRender(BillingPlan $plan = null, $short = false)
 {
     return sprintf('<span class="am-product-title">%s</span> <span class="am-product-terms">%s</span> <span class="am-product-desc">%s</span>', $this->getTitle(false), $plan ? ___($plan->getTerms()) : "", $this->getDescription(false));
 }
<?php

require_once 'Vindicia/Soap/Vindicia.php';
require_once 'Vindicia/Soap/Const.php';
$abID = $argv[1];
$remID = $argv[2];
$addID = $argv[3];
$effectiveDate = $argv[4];
$prorate = $argv[5];
$dryrun = $argv[6];
$newBillingPlanId = $argv[7];
print "Replacing product {$remID} with product {$addID} on autobill {$abID} \n";
print "dryrun is {$dryrun} \n";
if (!empty($newBillingPlanId)) {
    print "Changing billing plan to {$newBillingPlanId} \n";
    $changeBillingPlanTo = new BillingPlan();
    $changeBillingPlanTo->setMerchantBillingPlanId($newBillingPlanId);
}
$autobill = new AutoBill();
$return = $autobill->fetchByMerchantAutoBillId('', $abID);
$autobillVID = $return['data']->autobill->VID;
print "VID is {$autobillVID} \n";
$modAutoBill = new AutoBill();
$modAutoBill->setVID($autobillVID);
$remProduct = new Product();
$remProduct->setMerchantProductId($remID);
$remItem = new AutoBillItem();
$remItem->setProduct($remProduct);
$addProduct = new Product();
$addProduct->setMerchantProductId($addID);
$addItem = new AutoBillItem();
$abill->setPaymentMethod($pm);
//Create AutoBillItem to represent the purchased product
$item = new AutoBillItem();
// This is subscription product customer has selected to subscribe to
// Make sure a Product with this ID is already defined via the CashBox portal
$prod = new Product();
$prod->setMerchantProductId('QuickRenewalTestOnly');
$item->setProduct($prod);
$item->setQuantity(1);
// Campaign Code can be specified for each individual line item:
//$item->setCampaignCode('promo2');
$items = array($item);
$abill->setItems($items);
// If we are not going to use the default billing plan associated with the Product
// we must explicitly tell the AutoBill which billing plan it should use
$plan = new BillingPlan();
$plan->setMerchantBillingPlanId('FastRenewalTestPlan');
$abill->setBillingPlan($plan);
$immediateAuthFailurePolicy = 'doNotSaveAutoBill';
// if validation tx fails, do not save AutoBill
$validateForFuturePayment = true;
// if no payment is due at subscription start, we still want the payment method validated with a 1 RM transaction
$minChargebackProbability = 100;
// not using fraud screening
$ignoreAvsPolicy = true;
// Does not apply to MOLPay payment method
$ignoreCvnPolicy = true;
// Does not apply to MOLPay payment method
$sparseReturnDescriptor = '';
// we want the whole Transaction object back
// Campaign Code can also be passed in to the call as a param to apply to all eligible items