Exemplo n.º 1
0
$I->seeLastOrder(['customer_id' => '1', 'payment_id' => 'クレジットカード決済', 'status' => '入金待ち']);
$I->seeLink($chargeId);
$I->see('2,782円の仮売上');
$I->seeLink('実売上化する');
$I->fillField('deliv_fee', '1200');
$I->executeJS('window.confirm = function (text) { return text == "この内容で登録しても宜しいでしょうか"; }');
$I->click('この内容で登録する');
$I->executeJS('window.confirm = function (text) { return text == "現在の金額で実売上化をおこないます。受注内容を変更中の場合はさきに保存してください。"; }');
$I->click('実売上化する');
$I->see('仮売上金額(2,782円)以上で実売上化することはできません。合計金額を仮売上金額以下にするか、金額を増額する場合は購入者に連絡し、再度購入処理を行ってください。');
$I->fillField('deliv_fee', '120');
$I->executeJS('window.confirm = function (text) { return text == "この内容で登録しても宜しいでしょうか"; }');
$I->click('この内容で登録する');
// dummy error to test error presentation
$I->pushMockResponse(400, json_encode(['error' => ['message' => '課金 ch_auth_charge は仮売上済状態でありません', 'caused_by' => 'insufficient', 'type' => 'invalid_request_error']]));
$I->executeJS('window.confirm = function (text) { return text == "現在の金額で実売上化をおこないます。受注内容を変更中の場合はさきに保存してください。"; }');
$I->click('実売上化する');
$I->see('不正なリクエストがおこなわれました。WebPayのダッシュボードを確認してください。課金 ch_auth_charge は仮売上済状態でありません');
$I->see('2,782円の仮売上');
$I->loadRequest();
$I->seeInLogs(['/https:\\/\\/api\\.webpay\\.jp charge\\.capture: a:2:{s:2:"id";s:13:"ch_authcharge";s:6:"amount";i:1902;} from 127.0.0.1/']);
$I->executeJS('window.confirm = function (text) { return text == "現在の金額で実売上化をおこないます。受注内容を変更中の場合はさきに保存してください。"; }');
$I->pushMockChargeResponse(['id' => $chargeId, 'amount_refunded' => 880, 'captured' => true]);
$I->click('実売上化する');
$I->see('1,902円の実売上');
$I->dontSee('実売上化する');
$I->seeStatus('入金済み');
$I->loadRequest();
$I->seeRequestTo('POST', '/charges/' . $chargeId . '/capture');
$I->seeInData('amount', 1902);
$I->seeInLogs(['/https:\\/\\/api\\.webpay\\.jp charge\\.capture: a:2:{s:2:"id";s:13:"ch_authcharge";s:6:"amount";i:1902;} from 127.0.0.1/']);
$I->am('a new customer');
$I->wantTo('register my card to purchase again');
$admin = $I->haveFriend('admin');
$admin->does(function (AcceptanceTester $I) {
    $steps = new AcceptanceTester\AdminSteps($I);
    $steps->registerWebPayModule();
});
$I->login();
$I->registerCardByPurchase($customer_attrs);
$I->expectTo('buy another item with the previously registered card');
$I->amOnPage('/products/list.php');
$I->click('おなべ');
$I->pushMockCustomerResponse($customer_attrs);
$I->proceedToPay();
$I->loadRequest();
$I->seeRequestTo('GET', '/customers/' . $customer_id);
$I->see('次のカードが登録されています。');
$I->see('Visa');
$I->see('****-****-****-4242');
$I->see('TEST TEST');
$I->see('12/2019');
$I->see('登録してあるカードで支払う');
$I->see('登録したカードを削除する');
$I->see('別のカードで支払う');
$I->pushMockChargeResponse(['captured' => true]);
$I->click('登録してあるカードで支払う');
$I->waitForText('Test shopの商品をご購入いただき、ありがとうございました', 5);
$I->loadRequest();
$I->seeInData('amount', 2782);
$I->seeInData('customer', $customer_id);
$I->seeInData('currency', 'jpy');
$customer_id = 'cus_registered';
$customer_attrs = ['id' => $customer_id, 'description' => '1'];
$I = new AcceptanceTester\CustomerSteps($scenario);
$I->am('a new customer');
$I->wantTo('remove the registered card');
$admin = $I->haveFriend('admin');
$admin->does(function (AcceptanceTester $I) {
    $steps = new AcceptanceTester\AdminSteps($I);
    $steps->registerWebPayModule();
});
$I->login();
$I->registerCardByPurchase($customer_attrs);
$I->expectTo('buy another item with the new card');
$I->amOnPage('/products/list.php');
$I->click('おなべ');
$I->pushMockCustomerResponse($customer_attrs);
$I->proceedToPay();
$I->loadRequest();
$I->seeRequestTo('GET', '/customers/' . $customer_id);
$I->see('次のカードが登録されています。');
$I->see('Visa');
$I->see('****-****-****-4242');
$I->see('TEST TEST');
$I->see('12/2019');
$I->pushMockCustomerResponse(array_merge($customer_attrs, ['card' => null]));
$I->click('登録したカードを削除する');
$I->dontSee('次のカードが登録されています。');
$I->waitForElement('#WP_checkoutBox', 5);
$I->seeInLogs(['/https:\\/\\/api\\.webpay\\.jp customer\\.retrieve: s:14:"cus_registered"/', '/https:\\/\\/api\\.webpay\\.jp customer\\.delete_active_card: s:14:"cus_registered"/']);
$I->loadRequest();
$I->seeRequestTo('DELETE', '/customers/' . $customer_id . '/active_card');
$I->am('a new customer');
$I->wantTo('update my card');
$admin = $I->haveFriend('admin');
$admin->does(function (AcceptanceTester $I) {
    $steps = new AcceptanceTester\AdminSteps($I);
    $steps->registerWebPayModule();
});
$I->login();
$I->registerCardByPurchase($customer_attrs);
$I->expectTo('buy another item with the new card');
$I->amOnPage('/products/list.php');
$I->click('おなべ');
$I->pushMockCustomerResponse($customer_attrs);
$I->proceedToPay();
$I->loadRequest();
$I->seeRequestTo('GET', '/customers/' . $customer_id);
$I->see('次のカードが登録されています。');
$I->see('Visa');
$I->see('****-****-****-4242');
$I->see('TEST TEST');
$I->see('12/2019');
$I->click('別のカードで支払う');
$I->pushMockCustomerResponse($customer_attrs);
$I->pushMockChargeResponse(['captured' => true]);
$I->payWithNewCard();
$I->waitForText('Test shopの商品をご購入いただき、ありがとうございました', 5);
$I->loadRequest();
$I->seeRequestTo('POST', '/customers/' . $customer_id);
$I->seeInData('card');
$I->seeInLogs(['/https:\\/\\/api\\.webpay\\.jp customer\\.retrieve: s:14:"cus_registered"/', '/https:\\/\\/api\\.webpay\\.jp customer\\.update: a:3:{s:2:"id";s:14:"cus_registered";s:4:"card";s:19:"tok_[^"]*";s:11:"description";s:1:"1";}/', '/https:\\/\\/api\\.webpay\\.jp charge\\.create: a:4:{s:6:"amount";i:2782;s:8:"currency";s:3:"jpy";s:11:"description";s:1:"2";s:8:"customer";s:14:"cus_registered";}/']);
$I->loadRequest();