It's a question related to nicepay

Asked 2 years ago, Updated 2 years ago, 48 views

I want to remove the payment request parameter, encryption method, and logic in the payment request jsp in PG's sample, but even if I try to put it in the controller, there is an abstract method-related error and even if I try to use the Util class, there is an error. Originally, the sample has a common payment request page, so I can send the value by url, but I don't know what to do because the payment pop-up should appear when I press the button on each payment page jsp.
I don't know if I can ask this because it's my first question. Help me

payment-gateway java spring

2022-09-20 20:54

1 Answers

I only have experience of floating KCP and Inicis modules on PHP sources, but I also made a common class and solved it, so if I can only post something with that experience...

1. In the end, PG service is a service that does just two things.

And it's just that security, front and rear work that the shopping mall has to do, and cancellation processing in case of a problem, etc. are tied up. Re-open the demo source and manual calmly with such a big picture. You'll see what to save and what to take out.

2. A PG case There is a communication protocol set for each PG company, and whether payment is approved or canceled, all of which are handled by changing the variable values of the protocol. Even if you pay on different pages, since the store is the same and the PG company you use is the same anyway, you will work on the communication protocol by changing the value of the variable. Why don't you approach the work of abstraction development from that perspective.

For example, in the case of KCP, something is very different depending on whether the user pays with mobile or PC. The JavaScript file to be used is different, the calling function is different, and even the form used at that time is different. So in my case, I have declared the public $isMobile; class variable in class KCP and used it.

To be more specific...

/**
 * Just look at it conceptually.
 */
class KCP
{
    // These are necessary to use KCP modules anyway.
    protected $isMobile;
    protected $amount;
    protected $method;

    // Then let's get it at the initialization point and use it.
    public function __construct(bool $isMobile, int $amount, string $method)
    {
        $this->isMobile = $isMobile;
        $this->amount = $amount;
        $this->method = $method;
    }

    // And based only on the values received, the front element is formed or...
    public function getKCPConfigInputs()
    {
        return
        '<input type="hidden" name="__isMobile" value="'.((int) $this->isMobile).'" />
        <input type="hidden" name="__amount" value="'.$this->amount.'" />
        <input type="hidden" name="__method" value="'.$this->method.'" />';
    }

    // ... Let's implement back-end logic.
    public function authorizeTransaction($txid)
    {
        return exec_shell(KCP_BINARY.' --txid='.$txid.' --money='.$this->amount.' --method='.$this->method);
    }
}

// Then, if you create a proper instance after that...
$kcpBefore = new KCP(true, 12900, 'BANK');
echo $kcpBefore->getKCPConfigInputs();

// there is no need to worry about...
$kcpAfter = new KCP((bool) $_POST['__isMobile'], (int) $_POST['__amount'], (string) $_POST['__method']);
echo $kcpAfter->authorizeTransaction($_POST['txid']);

PG payment seems to be a crisis that a working-level web developer must overcome at least once. Be successful when the opportunity comes. You can do it.


2022-09-20 20:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.