Code Duplication    Length = 43-44 lines in 2 locations

code/EcommercePayment_Stripe_AuthorizeRecordedCustomer.php 1 location

@@ 37-80 (lines=44) @@
34
     *
35
     * @return EcommercePaymentResult
36
     */
37
    public function processPayment($data, $form)
38
    {
39
        //get variables
40
        $responseData = null;
41
        //get variables
42
        $this->retrieveVariables();
43
        $this->instantiateAPI();
44
        //less than fifty cents then it is fine ...
45
        if ($this->_processing_amount < 50) {
46
            $this->Status = "Success";
47
            $returnObject = EcommercePayment_Success::create();
48
        } elseif ($this->_processing_member && $this->_processing_member->CreditCardHasBeenRecorded()) {
49
            //if currency has been pre-set use this
50
            $requestData = array(
51
                'customer' => $this->_processing_member->StripeCustomerID,
52
                'amount' => $this->_processing_amount,
53
                'currency' => $this->_processing_currency,
54
                'capture' => false,
55
                'statement_descriptor' => $this->_processing_statement_description,
56
                'metadata' => $this->_processing_metadata
57
            );
58
            $responseData = \Stripe\Charge::create($requestData, $this->_processing_idempotency_key);
59
            $this->removeCardDetails();
60
61
            //save basic info
62
            $this->recordTransaction($requestData, $responseData);
63
64
            //no idea why we need this!!!
65
            $this->Amount->Amount = $this->_processing_amount / 100;
66
        }
67
        if (
68
            $responseData &&
69
            $responseData->status == "succeeded"
70
        ) {
71
            $this->ChargeID = $responseData->id;
72
            $this->Status = "Pending";
73
            $returnObject = EcommercePayment_Success::create();
74
        } else {
75
            $this->Status = "Failure";
76
            $returnObject = EcommercePayment_Failure::create();
77
        }
78
        $this->write();
79
        return $returnObject;
80
    }
81
}
82

code/EcommercePayment_Stripe_ChargeRecordedCustomer.php 1 location

@@ 30-72 (lines=43) @@
27
     *
28
     * @return EcommercePaymentResult
29
     */
30
    public function processPayment($data, $form)
31
    {
32
        //get variables
33
        $responseData = null;
34
        //get variables
35
        $this->retrieveVariables();
36
        $this->instantiateAPI();
37
        //less than fifty cents then it is fine ...
38
        if ($this->_processing_amount < 50) {
39
            $this->Status = "Success";
40
            $returnObject = EcommercePayment_Success::create();
41
        } elseif ($this->_processing_member && $this->_processing_member->CreditCardHasBeenRecorded()) {
42
            //if currency has been pre-set use this
43
            $requestData = array(
44
                'customer' => $this->_processing_member->StripeCustomerID,
45
                'amount' => $this->_processing_amount,
46
                'currency' => $this->_processing_currency,
47
                'capture' => true,
48
                'statement_descriptor' => $this->_processing_statement_description,
49
                'metadata' => $this->_processing_metadata
50
            );
51
            $responseData = \Stripe\Charge::create($requestData, $this->_processing_idempotency_key);
52
            $this->removeCardDetails();
53
54
            //save basic info
55
            $this->recordTransaction($requestData, $responseData);
56
57
            //no idea why we need this!!!
58
            $this->Amount->Amount = $this->_processing_amount / 100;
59
        }
60
        if (
61
            $responseData &&
62
            $responseData->status == "succeeded"
63
        ) {
64
            $this->Status = "Success";
65
            $returnObject = EcommercePayment_Success::create();
66
        } else {
67
            $this->Status = "Failure";
68
            $returnObject = EcommercePayment_Failure::create();
69
        }
70
        $this->write();
71
        return $returnObject;
72
    }
73
}
74