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; }
$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'; // pre-9.0 behavior for an initial auth failure //$immediateAuthFailurePolicy = 'putAutoBillInRetryCycle'; // Creates AutoBill and retriesthe authorizaton. //$immediateAuthFailurePolicy = 'putAutoBillInRetryCycleIfPaymentMethodIsValid'; // recommended in the API guide $validateForFuturePayment = 1; // need to validate to get the above choices $fraudScore = 100; // minChargebackProbability of 100 skips fraud scoring completely $ignoreAVS = 0; $ignoreCVN = 0; $dryrun = 1; $dryrun = $argv[4]; print "dryrun is {$dryrun} \n"; $coupon = NULL; $coupon = $argv[5]; print "coupon is {$coupon} \n"; $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; print "Created MerchantAutoBillId: {$return_id} \n";
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; }
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 prepayNonRecurringWithNonRecurringPrice($merchantAutobillId) { // Fetch the current active non-recurring autobill by fetching all autobills by merchantAccountId. // Pick the current active non-recurring autobill for which they are pre-paying. $currentActiveNonRecurringAutobill = get_current_active_nonrecurring_autobill($merchantAutobillId); // Pre-pay capturing a transaction for price of product on current active non-recurring autobill. $merchantTransactionId = prepay($currentActiveNonRecurringAutobill); $startTimestamp = $currentActiveNonRecurringAutobill->endTimestamp; $merchantAutoBillId = $currentActiveNonRecurringAutobill->merchantAutoBillId . '+'; $merchantAccountId = $currentActiveNonRecurringAutobill->account->merchantAccountId; // Only use sparse object, so all data members are not over-written. $sparseAccount = new Account(); $sparseAccount->merchantAccountId = $currentActiveNonRecurringAutobill->account->merchantAccountId; // Assume same billing plan as on current autobill. $billingPlan = $currentActiveNonRecurringAutobill->billingPlan; // Assume same product as on current autobill. $product = $currentActiveNonRecurringAutobill->items[0]->product; $itemNonRecurring = new AutoBillItem(); $itemNonRecurring->setIndex(1); // Override price of product to 0 USD, since payment is taken up front as one-time transaction. $itemNonRecurring->setAmount(0); $itemNonRecurring->setProduct($product); $autobill = new AutoBill(); $autobill->setMerchantAutoBillId($merchantAutoBillId); $autobill->setAccount($sparseAccount); $autobill->setItems(array($itemNonRecurring)); $autobill->setBillingPlan($billingPlan); // Future dated autobill will start when the current active autobill ends. // Price is overrided as 0 USD, so no transaction will occur and the user will be entitled for the next non-recurring cycle. $autobill->setStartTimestamp($startTimestamp); $autobill->setWarnOnExpiration(true); $autobill->setCurrency('USD'); // Add a name value pair to signify a linkage to the previous Autobill. // Add a name value pair to signify a linkage to the Transaction used to collect payment. // This will help out with revenue recognition. $nameVals[0] = new NameValuePair(); $nameVals[0]->setName("PreviousNonRecurringAutobillId"); $nameVals[0]->setValue($currentActiveNonRecurringAutobill->merchantAutoBillId); $nameVals[1] = new NameValuePair(); $nameVals[1]->setName("PaidForByMerchantTransactionId"); $nameVals[1]->setValue($merchantTransactionId); $autobill->setNameValues($nameVals); $immediateAuthFailurePolicy = 'doNotSaveAutoBill'; $validateForFuturePayment = false; $minChargebackProbability = 100; $ignoreAvsPolicy = true; $ignoreCvnPolicy = true; $campaignCode = null; $dryrun = false; $response = $autobill->update($immediateAuthFailurePolicy, $validateForFuturePayment, $minChargebackProbability, $ignoreAvsPolicy, $ignoreCvnPolicy, $campaignCode, $dryrun); logCall($response, 'Autobill::Update', $merchantAccountId); }
// 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 $campaignCode = null; // we will populate campaign code on individual items if necessary $dryRun = false; $response = $abill->update($sparseReturnDescriptor, $immediateAuthFailurePolicy, $validateForFuturePayment, $minChargebackProbability, $ignoreAvsPolicy, $ignoreCvnPolicy, $campaignCode, $dryRun); if ($response['returnCode'] == 200) { $returned_tx = $response['data']->initialTransaction; if ($returned_tx->statusLog[0]->status == 'AuthorizationPending') { print "Visit the following URL to complete payment \n"; print $returned_tx->statusLog[0]->hostedPageStatus->redirectUrl . "\n\n"; } else { if ($returned_tx->statusLog[0]->status == 'Cancelled') { print "Payment did not complete. Please start purchase again \n"; print " soap id: " . $response['data']->return->soapId . "\n"; } else { print "Error: Unexpected initial transaction status\n"; print "Vindicia soap id: " . $response['data']->return->soapId . "\n"; } } } else {