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; }
require_once 'Vindicia/Soap/Vindicia.php'; require_once 'Vindicia/Soap/Const.php'; $ab = $argv[1]; $pmId = $argv[2]; print "autobill is {$ab}\n"; $paypal = new PayPal(); $paypal->setReturnUrl('http://localhost:8888/success.php'); $paypal->setCancelUrl('http://localhost:8888/cancellation.php'); $paypal->setRequestReferenceId(1); $pm = new PaymentMethod(); $pm->setMerchantPaymentMethodId($pmId); $pm->setType('PayPal'); $pm->setPayPal($paypal); $autobill = new AutoBill(); $autobill->setMerchantAutoBillId($ab); $autobill->setPaymentMethod($pm); $immediateAuthFailurePolicy = 'doNotSaveAutoBill'; $validateForFuturePayment = 0; $fraudScore = 100; $ignoreAVS = 1; $ignoreCVN = 1; $dryrun = 1; $dryrun = $argv[3]; $coupon = NULL; $response = $autobill->update('', $immediateAuthFailurePolicy, $validateForFuturePayment, $fraudScore, $ignoreAVS, $ignoreCVN, $coupon, $dryrun, ''); print_r($response); $return_code = $response['returnCode']; $return_string = $response['returnString']; print "Return code is {$return_code} \n"; print "Return string is {$return_string} \n"; $return_id = $response['data']->autobill->merchantAutoBillId;
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; }
$hostedPageInfo->setLanguage('en'); $hostedPageInfo->setReturnUrl('http://www.vindicia.com/'); // specify a page on your site customer will be redirected to after completing the MOLPay payment $hostedPageInfo->setProcessorPaymentMethodId('credit'); // If the billing plan is recurring, customer can pay with credit card only $provider = new PaymentProvider(); $provider->setName('MOLPay'); $hostedPageInfo->setPaymentProvider($provider); $pm->setHostedPage($hostedPageInfo); $abill = new AutoBill(); $abill->setCurrency('MYR'); // AutoBill will be billed in this currency. Make sure the Product and BillingPlan has prices in MYR $abill->setMerchantAutoBillId('VINTEST-AB-' . rand(10000, 99999)); // Unique subscription ID $abill->setAccount($account); $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();