developermypos/myPOS-Checkout-SDK-PHP

Test Checkout Redirect Issue

HumayunE opened this issue · 6 comments

Hello!

I am integrating MyPOS Checkout and when I enter all details in the checkout it processes and become unsuccessful and always returns on cancel url.

Here is the response on cancel url:
Array ( [IPCmethod] => IPCPurchaseCancel [SID] => 000000000000010 [Amount] => 200 [Currency] => EUR [OrderID] => 1572538178 [Signature] => vlGMyXQU80JkI/Xqwr5lblNS9GWos8AicgS57OXsiPwcN0xHD2qnJ+Rd0YW4AeoiVzDBcar7q3ofreorvq/mIgnx8eR0pL74ZWpLHPZ2ET0bkQBxQuKh7EwN/CssqOml1lzWTgMlE9FLbLh5TjnQDKj4jPiYo2U69SU7sVHB0Q4= )

Here are the screenshots:
Screenshot 2019-10-31 at 9 24 40 PM
Screenshot 2019-10-31 at 9 24 45 PM
Screenshot 2019-10-31 at 9 24 50 PM

Please help!!

Thanks
Humayun

Hello @aristech

Can you please help me..?

I have the same issue. In test environment, with test cards there's always redirection to cancel url.

I have solved this issue. It requires only 'OK' from our side. Anything else will send it to cancelling.
Whether that is any error or anything.

Upon HTTP request, the Merchant should respond with header HTTP 200 OK with the following body content: “OK”. Every other response will be treated as communication error, call error, server error or system malfunctions.

Checkout doc for more info: https://developers.mypos.eu/en/doc/online_payments/v1_4/226-test-data

Can you elaborate on how you solved this issue? I'm testing with the test data and cards but it always shows the same Payment Unsuccessful message and then goes to Cancel url. PrivateKey and APIPublicKey I also copied from the documentation: https://developers.mypos.eu/en/doc/online_payments/v1_4/226-test-data
Am I not sending the correct data?

    $cnf = new \Mypos\IPC\Config();
    $cnf->setIpcURL('https://www.mypos.eu/vmp/checkout-test');
    $cnf->setLang('en');
    $cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
    $cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
    $cnf->setKeyIndex('1');
    $cnf->setSid('000000000000010');
    $cnf->setVersion('1.4');
    $cnf->setWallet('61938166610');

    $customer = new \Mypos\IPC\Customer();
    $customer->setFirstName('John');
    $customer->setLastName('Smith');
    $customer->setEmail('demo@demo.demo');
    $customer->setPhone('+359888111222');
    $customer->setCountry('BGN');
    $customer->setAddress('Business Park Varna');
    $customer->setCity('Varna');
    $customer->setZip('9000');

    $cart = new \Mypos\IPC\Cart;
    $cart->add('Some Book', 1, 9.99); //name, quantity, price
    $cart->add('Some other book', 1, 4.56);
    $cart->add('Discount', 1, -2.05);

    $purchase = new \Mypos\IPC\Purchase($cnf);
    $purchase->setUrlCancel('https://mysite.com/ipc_cancel'); //User comes here after purchase cancellation
    $purchase->setUrlOk('https://mysite.com/ipc_ok'); //User comes here after purchase success
    $purchase->setUrlNotify('https://mysite.com/ipc_notify'); //IPC sends POST request to this address with purchase status
    $purchase->setOrderID(uniqid()); //Some unique ID
    $purchase->setCurrency('BGN');
    $purchase->setNote('Some note'); //Not required
    $purchase->setCustomer($customer);
    $purchase->setCart($cart);

    $purchase->setCardTokenRequest(\Mypos\IPC\Purchase::CARD_TOKEN_REQUEST_PAY_AND_STORE);
    $purchase->setPaymentParametersRequired(\Mypos\IPC\Purchase::PURCHASE_TYPE_FULL);
    $purchase->setPaymentMethod(\Mypos\IPC\Purchase::PAYMENT_METHOD_BOTH);
     
      try{
        $purchase->process();
    } catch(\Mypos\IPC\IPC_Exception $ex){
        echo $ex->getMessage();
    }

`

Can you elaborate on how you solved this issue? I'm testing with the test data and cards but it always shows the same Payment Unsuccessful message and then goes to Cancel url. PrivateKey and APIPublicKey I also copied from the documentation: https://developers.mypos.eu/en/doc/online_payments/v1_4/226-test-data
Am I not sending the correct data?

    $cnf = new \Mypos\IPC\Config();
    $cnf->setIpcURL('https://www.mypos.eu/vmp/checkout-test');
    $cnf->setLang('en');
    $cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
    $cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
    $cnf->setKeyIndex('1');
    $cnf->setSid('000000000000010');
    $cnf->setVersion('1.4');
    $cnf->setWallet('61938166610');

    $customer = new \Mypos\IPC\Customer();
    $customer->setFirstName('John');
    $customer->setLastName('Smith');
    $customer->setEmail('demo@demo.demo');
    $customer->setPhone('+359888111222');
    $customer->setCountry('BGN');
    $customer->setAddress('Business Park Varna');
    $customer->setCity('Varna');
    $customer->setZip('9000');

    $cart = new \Mypos\IPC\Cart;
    $cart->add('Some Book', 1, 9.99); //name, quantity, price
    $cart->add('Some other book', 1, 4.56);
    $cart->add('Discount', 1, -2.05);

    $purchase = new \Mypos\IPC\Purchase($cnf);
    $purchase->setUrlCancel('https://mysite.com/ipc_cancel'); //User comes here after purchase cancellation
    $purchase->setUrlOk('https://mysite.com/ipc_ok'); //User comes here after purchase success
    $purchase->setUrlNotify('https://mysite.com/ipc_notify'); //IPC sends POST request to this address with purchase status
    $purchase->setOrderID(uniqid()); //Some unique ID
    $purchase->setCurrency('BGN');
    $purchase->setNote('Some note'); //Not required
    $purchase->setCustomer($customer);
    $purchase->setCart($cart);

    $purchase->setCardTokenRequest(\Mypos\IPC\Purchase::CARD_TOKEN_REQUEST_PAY_AND_STORE);
    $purchase->setPaymentParametersRequired(\Mypos\IPC\Purchase::PURCHASE_TYPE_FULL);
    $purchase->setPaymentMethod(\Mypos\IPC\Purchase::PAYMENT_METHOD_BOTH);
     
      try{
        $purchase->process();
    } catch(\Mypos\IPC\IPC_Exception $ex){
        echo $ex->getMessage();
    }

`

Hi,
As you can see here:

$purchase->setUrlNotify('https://mysite.com/ipc_notify'); //IPC sends POST request to this address with purchase status

it sends POST request to you back before completing or cancelling transaction, here you need to print OK and nothing else. Otherwise it will be cancelled everytime.

This will be your website link "https://mysite.com/ipc_notify" where you will print OK

Can you elaborate on how you solved this issue? I'm testing with the test data and cards but it always shows the same Payment Unsuccessful message and then goes to Cancel url. PrivateKey and APIPublicKey I also copied from the documentation: https://developers.mypos.eu/en/doc/online_payments/v1_4/226-test-data
Am I not sending the correct data?

    $cnf = new \Mypos\IPC\Config();
    $cnf->setIpcURL('https://www.mypos.eu/vmp/checkout-test');
    $cnf->setLang('en');
    $cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
    $cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
    $cnf->setKeyIndex('1');
    $cnf->setSid('000000000000010');
    $cnf->setVersion('1.4');
    $cnf->setWallet('61938166610');

    $customer = new \Mypos\IPC\Customer();
    $customer->setFirstName('John');
    $customer->setLastName('Smith');
    $customer->setEmail('demo@demo.demo');
    $customer->setPhone('+359888111222');
    $customer->setCountry('BGN');
    $customer->setAddress('Business Park Varna');
    $customer->setCity('Varna');
    $customer->setZip('9000');

    $cart = new \Mypos\IPC\Cart;
    $cart->add('Some Book', 1, 9.99); //name, quantity, price
    $cart->add('Some other book', 1, 4.56);
    $cart->add('Discount', 1, -2.05);

    $purchase = new \Mypos\IPC\Purchase($cnf);
    $purchase->setUrlCancel('https://mysite.com/ipc_cancel'); //User comes here after purchase cancellation
    $purchase->setUrlOk('https://mysite.com/ipc_ok'); //User comes here after purchase success
    $purchase->setUrlNotify('https://mysite.com/ipc_notify'); //IPC sends POST request to this address with purchase status
    $purchase->setOrderID(uniqid()); //Some unique ID
    $purchase->setCurrency('BGN');
    $purchase->setNote('Some note'); //Not required
    $purchase->setCustomer($customer);
    $purchase->setCart($cart);

    $purchase->setCardTokenRequest(\Mypos\IPC\Purchase::CARD_TOKEN_REQUEST_PAY_AND_STORE);
    $purchase->setPaymentParametersRequired(\Mypos\IPC\Purchase::PURCHASE_TYPE_FULL);
    $purchase->setPaymentMethod(\Mypos\IPC\Purchase::PAYMENT_METHOD_BOTH);
     
      try{
        $purchase->process();
    } catch(\Mypos\IPC\IPC_Exception $ex){
        echo $ex->getMessage();
    }

`

Hi, As you can see here:

$purchase->setUrlNotify('https://mysite.com/ipc_notify'); //IPC sends POST request to this address with purchase status

it sends POST request to you back before completing or cancelling transaction, here you need to print OK and nothing else. Otherwise it will be cancelled everytime.

This will be your website link "https://mysite.com/ipc_notify" where you will print OK

Where I can find this code?
And how give OK? Just replace ‘mysite’ with OK or what?

THANKS