function GoogleSubscription()
{
    echo "<h2>Google Handled Subscription Request</h2>";
    $merchant_id = "";
    // Your Merchant ID
    $merchant_key = "";
    // Your Merchant Key
    $server_type = "sandbox";
    // or production
    $currency = "USD";
    $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
    $item = new GoogleItem("fee", "sign up fee", 1, 12.0);
    $subscription_item = new GoogleSubscription("google", "DAILY", 30.0);
    $recurrent_item = new GoogleItem("fee", "recurring fee", 1, 30.0);
    $subscription_item->SetItem($recurrent_item);
    $item->SetSubscription($subscription_item);
    $cart->AddItem($item);
    echo $cart->CheckoutButtonCode("MEDIUM");
}
Example #2
0
 /**
  * @param array $params
  * @param $component
  */
 public function doRecurCheckout(&$params, $component)
 {
     $intervalUnit = CRM_Utils_Array::value('frequency_unit', $params);
     if ($intervalUnit == 'week') {
         $intervalUnit = 'WEEKLY';
     } elseif ($intervalUnit == 'year') {
         $intervalUnit = 'YEARLY';
     } elseif ($intervalUnit == 'day') {
         $intervalUnit = 'DAILY';
     } elseif ($intervalUnit == 'month') {
         $intervalUnit = 'MONTHLY';
     }
     // Merchant ID
     $merchant_id = $this->_paymentProcessor['user_name'];
     // Merchant Key
     $merchant_key = $this->_paymentProcessor['password'];
     $server_type = $this->_mode == 'test' ? 'sandbox' : '';
     $itemName = CRM_Utils_Array::value('item_name', $params);
     $description = CRM_Utils_Array::value('description', $params);
     $amount = CRM_Utils_Array::value('amount', $params);
     $installments = CRM_Utils_Array::value('installments', $params);
     $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $params['currencyID']);
     $item = new GoogleItem($itemName, $description, 1, $amount);
     $subscription_item = new GoogleSubscription("merchant", $intervalUnit, $amount, $installments);
     $item->SetSubscription($subscription_item);
     $cart->AddItem($item);
     $this->submitPostParams($params, $component, $cart);
 }