Exemple #1
0
 protected function doUnserialize(array $json)
 {
     // consult parent for further unserialization
     parent::doUnserialize($json);
     $this->unserializeArrayEntities('roles', Bf_Role::getClassName(), $json);
     $this->unserializeArrayEntities('paymentMethods', Bf_PaymentMethod::getClassName(), $json);
     $this->unserializeEntity('profile', Bf_Profile::getClassName(), $json);
     $this->unserializeEntity('metadata', Bf_MetadataJson::getClassName(), $json);
 }
Exemple #2
0
 /**
  * Remove the given payment method from the specified subscription
  * @param union[string | Bf_PaymentMethod] $paymentMethod The Bf_PaymentMethod which should be removed. <string>: ID of the Bf_PaymentMethod. <Bf_Subscription>: The Bf_Subscription.
  * @param union[string | Bf_Subscription] $subscription The Bf_Subscription from which the Bf_PaymentMethod should be removed. <string>: ID of the Bf_Subscription. <Bf_Subscription>: The Bf_Subscription.
  * @return Bf_PaymentMethod The removed payment method.
  */
 public static function removePaymentMethodFromSubscription($paymentMethod, $subscription, $queryParams = array())
 {
     $subscriptionID = Bf_Subscription::getIdentifier($subscription);
     $paymentMethodID = Bf_PaymentMethod::getIdentifier($paymentMethod);
     $endpoint = sprintf("%s/payment-methods/%s", rawurlencode($subscriptionID), rawurlencode($paymentMethodID));
     $responseEntity = Bf_PaymentMethod::getClassName();
     return static::retireAndGrabFirst($endpoint, NULL, $customClient, $responseEntity, $queryParams);
 }
Exemple #3
0
$createdAcc = Bf_Account::create($account);
$createdAccID = $createdAcc->id;
//-- make payment method, and associate it with account
//-- make Authorize.net token to associate payment method to
// FILL IN WITH YOUR AUTHORIZE.NET CUSTOMER PROFILE ID
$customerProfileID = 00;
// FILL IN WITH YOUR AUTHORIZE.NET CUSTOMER PAYMENT PROFILE ID
$customerPaymentProfileID = 00;
// FILL IN WITH YOUR AUTHORIZE.NET CUSTOMER'S CARD LAST 4 DIGITS
// this 'last 4 digits of credit card number' field (currently optional) is required for refunds
$cardLast4Digits = 00;
$authorizeNetToken = new Bf_AuthorizeNetToken(array('accountID' => $createdAccID, 'customerProfileID' => $customerProfileID, 'customerPaymentProfileID' => $customerPaymentProfileID, 'lastFourDigits' => $cardLast4Digits));
$createdAuthorizeNetToken = Bf_AuthorizeNetToken::create($authorizeNetToken);
$createdAuthorizeNetTokenID = $createdAuthorizeNetToken->id;
$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;
Exemple #4
0
 public static function initStatics()
 {
     self::$_resourcePath = new Bf_ResourcePath('payment-methods', 'paymentMethod');
 }
Exemple #5
0
 /**
  * @depends testUpdateCascade
  */
 public function testAddAnotherDefaultPaymentMethod()
 {
     $account = self::$createdAccount;
     $customerProfileID = TestBase::getSituation('customerProfileID');
     $customerPaymentProfileID = TestBase::getSituation('customerPaymentProfileID');
     // err, didn't check what the actual card last 4 digits are. but this only matters at refund-time.
     $cardLast4Digits = TestBase::getSituation('cardLast4Digits') + 1;
     $authorizeNetToken = new Bf_AuthorizeNetToken(array('accountID' => $account->id, 'customerProfileID' => $customerProfileID, 'customerPaymentProfileID' => $customerPaymentProfileID, 'lastFourDigits' => $cardLast4Digits));
     $createdAuthorizeNetToken = Bf_AuthorizeNetToken::create($authorizeNetToken);
     $createdAuthorizeNetTokenID = $createdAuthorizeNetToken->id;
     $isDefault = true;
     $paymentMethodModel = new Bf_PaymentMethod(array('linkID' => $createdAuthorizeNetToken->id, 'accountID' => $account->id, 'name' => 'Authorize.Net', 'description' => $cardLast4Digits, 'gateway' => 'authorizeNet', 'userEditable' => 0, 'priority' => 100, 'reusable' => 1, 'defaultPaymentMethod' => $isDefault));
     $createdPaymentMethod = Bf_PaymentMethod::create($paymentMethodModel);
     $expected = $isDefault;
     $actual = $createdPaymentMethod->defaultPaymentMethod;
     $this->assertEquals($expected, $actual, "Payment method begins as default.");
 }