Add coupon code in a payment plugin

Discussion in 'Payments processing' started by netserv3, Feb 16, 2017.

  1. netserv3

    netserv3 aMember Pro Customer

    Joined:
    Aug 29, 2006
    Messages:
    21
    Hi,
    I want to add coupon code in the following function of a payment plugin to be sent to the payment processor:

    public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
    {
    $a = new Am_Paysystem_Action_Form((($this->getConfig('testing') == self::MODE_SANDBOX) ? self::TESTING_URL : self::URL));
    $a->contractId = $invoice->getItem(0)->getBillingPlanData("bluesnap_contract_id");
    $a->custom1 = $invoice->public_id;
    $a->member_id = $invoice->user_id;
    $a->currency = strtoupper($invoice->currency);
    $a->firstName = $invoice->getFirstName();
    $a->lastName = $invoice->getLastName();
    $a->email = $invoice->getEmail();
    $a->overridePrice = sprintf("%.2f", $invoice->first_total);
    $a->overrideRecurringPrice = sprintf("%.2f", $invoice->second_total);
    if ($this->getConfig('testing') == self::MODE_TEST) {
    $a->testMode = Y;
    }
    $a->filterEmpty();
    $result->setAction($a);
    }

    It does not accept
    $a->couponcode = $invoice->getCouponCode();

    Thank you for any help.
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Hello,

    Are you sure bluesnap expect parameter couponcode? Did you get any error with your code?
  3. netserv3

    netserv3 aMember Pro Customer

    Joined:
    Aug 29, 2006
    Messages:
    21
    Yes, bluesnap accepts the parameter "couponcode".

    I wish amember developers could improve the Bluesnap plugin so that you do not need to add products with fixed prices to bluesnap catalog but use it as a payment processing system only. This allows full control of pricing/discounts with aMember. I am quoting from their documentation:

    "The Hosted Payment Page is designed for businesses that manage their product catalogs in a system outside of BlueSnap and just need a checkout page where payments will be processed by BlueSnap."

    https://support.bluesnap.com/docs/intro-to-buynow-hosted-payments-page
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Yes, it is good idea and we will implement it.

    Best Regards
  5. netserv3

    netserv3 aMember Pro Customer

    Joined:
    Aug 29, 2006
    Messages:
    21
    Glad to know that! Please let me know when you complete implementation. I will definitely upgrade.
  6. netserv3

    netserv3 aMember Pro Customer

    Joined:
    Aug 29, 2006
    Messages:
    21
    Any update on this improvement?

Share This Page