Пример #1
0
 public function testCreate()
 {
     $product = Models::MonthlyNonRecurringProduct();
     self::$productDescription = $product->description;
     $uniqueString = time();
     $name = "TEST_{$uniqueString}";
     $product->name = $name;
     self::$createdProduct = Bf_Product::create($product);
     $expected = self::$productDescription;
     $actual = self::$createdProduct->description;
     $this->assertEquals($expected, $actual, "Entity has expected field with known value.");
     $expected = Bf_Product::getResourcePath()->getEntityName();
     $actual = self::$createdProduct['@type'];
     $this->assertEquals($expected, $actual, "Type of any returned entity matches known value.");
 }
Пример #2
0
$paymentMethod = new Bf_PaymentMethod(array('linkID' => $createdAuthorizeNetTokenID, 'accountID' => $createdAccID, 'name' => 'Authorize.Net', 'description' => 'Pay via Authorize.Net', 'gateway' => 'authorizeNet', 'userEditable' => 0, 'priority' => 100, 'reusable' => 1));
$createdPaymentMethod = Bf_PaymentMethod::create($paymentMethod);
$createdPaymentMethodID = $createdPaymentMethod->id;
$paymentMethods = array($createdPaymentMethod);
// add these payment methods to our model of the created account
$createdAcc->paymentMethods = $paymentMethods;
// save changes to real account
$createdAcc = $createdAcc->save();
var_export($createdAcc);
//-- Make unit of measure
$uom = new Bf_UnitOfMeasure(array('name' => 'Devices', 'displayedAs' => 'Devices', 'roundingScheme' => 'UP'));
$createdUom = Bf_UnitOfMeasure::create($uom);
$createdUomID = $createdUom->id;
//-- Make product
$product = new Bf_Product(array('productType' => 'non-recurring', 'state' => 'prod', 'name' => 'Month of Paracetamoxyfrusebendroneomycin', 'description' => 'It can cure the common cold, and being struck by lightning', 'durationPeriod' => 'days', 'duration' => 28));
$createdProduct = Bf_Product::create($product);
$createdProductID = $createdProduct->id;
//-- Make product rate plan
//-- Make pricing components for product rate plan
//-- Make tiers for pricing component
$tier = new Bf_PricingComponentTier(array('lowerThreshold' => 1, 'upperThreshold' => 1, 'pricingType' => 'unit', 'price' => 1));
$tiers = array($tier);
$pricingComponentsArray = array(new Bf_PricingComponent(array('@type' => 'flatPricingComponent', 'chargeModel' => 'flat', 'name' => 'Devices used', 'description' => 'How many devices you use, I guess', 'unitOfMeasureID' => $createdUomID, 'chargeType' => 'subscription', 'upgradeMode' => 'immediate', 'downgradeMode' => 'immediate', 'defaultQuantity' => 10, 'tiers' => $tiers)));
$prp = new Bf_ProductRatePlan(array('currency' => 'USD', 'name' => getUsualPrpName(), 'pricingComponents' => $pricingComponentsArray, 'productID' => $createdProductID));
$createdPrp = Bf_ProductRatePlan::create($prp);
$createdProductRatePlanID = $createdPrp->id;
$createdPricingComponentID = $createdPrp->pricingComponents[0]->id;
//-- Make pricing component value instance of pricing component
$prc = new Bf_PricingComponentValue(array('pricingComponentID' => $createdPricingComponentID, 'value' => 2, 'crmID' => ''));
$pricingComponentValuesArray = array($prc);
//-- Make Bf_PaymentMethodSubscriptionLinks