def test_get_plan_list_info(): # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Generate plans # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # prepare payments ids = {do_create_plan(recurrings) for _ in range(0, 3)} # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Fetch plans # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # perform operation response = recurrings.get_plans(request_id=str(uuid.uuid4()), max_count=20, sort_order='desc') # explore response result assert response is not None data = {p.id for p in response.data} for p in response.data: logger.info("%s %f %s" % (p.id, p.amount, p.currency)) assert ids.issubset(data)
def test_change_plan_status(): # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 1: prepare a new plan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plan_id = do_create_plan(recurrings) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 2: change plan status # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # prepare request request = PlanUpdateRequest( request=ApiClient.uuid_request(), operation=PlanUpdateRequest.Operation.CHANGE_STATUS, plan_data=PlanUpdateRequestPlanData( status_to=PlanUpdateRequestPlanData.StatusTo.INACTIVE)) # perform operation response = recurrings.update_plan(plan_id, request) # explore response result assert response is not None data = response.plan_data assert data is not None assert data.is_executed assert data.StatusTo.INACTIVE == data.status_to
def test_rename_plan(): # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 1: prepare a new plan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plan_id = do_create_plan(recurrings) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 2: rename plan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # prepare request request = PlanUpdateRequest( request=ApiClient.uuid_request(), operation=PlanUpdateRequest.Operation.RENAME, plan_data=PlanUpdateRequestPlanData(name_to=randomString(20))) # perform operation response = recurrings.update_plan(plan_id, request) # explore response result assert response is not None data = response.plan_data assert data is not None assert data.is_executed
def test_get_subscriptions_list_information(): global ids # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Generate subscriptions # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ids = { do_create_subscription(recurrings, plan_id=do_create_plan(recurrings)) for _ in range(0, 3) } # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Fetch subscriptions # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ response = recurrings.get_subscriptions(request_id=str(uuid.uuid4()), max_count=50, sort_order="desc") print("\ncount: %s" % len(response.data)) for s in response.data: print("%s %s: %s %s" % (s.created, s.id, s.currency, s.status)) if s.status != s.Status.CANCELLED: do_cancel_subscription(recurrings, s.id) assert ids.issubset({s.id for s in response.data})
def test_delete_plan(): # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 1: prepare a new plan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plan_id = do_create_plan(recurrings) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 2: delete plan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ response = recurrings.delete_plan(plan_id) assert response is None
def test_get_plan_info(): # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 1: prepare a new plan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plan_id = do_create_plan(recurrings) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 2: get plan info # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # perform operation response = recurrings.get_plan(plan_id) # explore response result assert response is not None data = response.plan_data assert data is not None
def test_get_subscription_info(): global subscription_id # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Create subscriptions # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ subscription_id = do_create_subscription(recurrings, plan_id=do_create_plan(recurrings)) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Fetch subscription information # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ response = recurrings.get_subscription(subscription_id) # explore response result assert response is not None assert response.id == subscription_id logger.info(response)
def test_resume_subscription(): global subscription_id # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 1: prepare a new plan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plan_id = do_create_plan(recurrings) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 2: create scheduled subscription # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ recurring_request = create_recurring_request(plan_id=plan_id) # perform create scheduled subscription creation_response = recurrings.create_recurring(recurring_request) logger.info(creation_response) # get redirect url redirect_url = creation_response.redirect_url assert redirect_url is not None # Emulate customer behaviour performing GET request to redirect url do_get(redirect_url) recurring_response = fetch_recurring(recurrings, recurring_request.merchant_order.id) assert recurring_response is not None subscription_id = recurring_response.recurring_data.subscription.id # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 3: Change status of Scheduled subscription to INACTIVE # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ time.sleep(1) # prepare subscription update request data inactive_request = SubscriptionUpdateRequest( request=ApiClient.uuid_request(), operation=SubscriptionUpdateRequest.Operation.CHANGE_STATUS, subscription_data=SubscriptionUpdateRequestSubscriptionData( status_to=SubscriptionUpdateRequestSubscriptionData.StatusTo. INACTIVE)) inactive_response = recurrings.update_subscription(subscription_id, inactive_request) assert inactive_response is not None # explore response result data = inactive_response.subscription_data assert data.is_executed assert data.StatusTo.INACTIVE == data.status_to # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 4: Change status of Scheduled subscription to ACTIVE # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # prepare subscription update request data active_request = SubscriptionUpdateRequest( request=ApiClient.uuid_request(), operation=SubscriptionUpdateRequest.Operation.CHANGE_STATUS, subscription_data=SubscriptionUpdateRequestSubscriptionData( status_to=SubscriptionUpdateRequestSubscriptionData.StatusTo.ACTIVE )) active_response = recurrings.update_subscription(subscription_id, active_request) assert active_response is not None # explore response result data = active_response.subscription_data assert data.is_executed assert data.StatusTo.ACTIVE == data.status_to
def test_link_a_card_to_an_existing_subscription(): global subscription_id # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 1: prepare a new plan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plan_id = do_create_plan(recurrings) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 2: create scheduled subscription # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ subscription_id = do_create_subscription(recurrings, plan_id=plan_id) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Filling Data # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # merchant order data merchantOrderId = randomString(20) merchantDescription = fake.sentence() initiator = "cit" # card data cardPan = CARD_NON3DS_CONFIRMED cardHolder = fake.name().upper() cardExpiration = formatExpirationDate(generateCardExpiration()) securityCode = "100" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Phase 3: link a card to an existing subscription # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # prepare filing request data request = FilingRequest( request=ApiClient.uuid_request(), merchant_order=PaymentRequestMerchantOrder( id=merchantOrderId, description=merchantDescription), payment_method=PAYMENT_METHOD_BANKCARD, card_account=PaymentRequestCardAccount( card=PaymentRequestCard(pan=cardPan, holder=cardHolder, expiration=cardExpiration, security_code=securityCode)), subscription_data=FilingRequestSubscriptionData(id=subscription_id), recurring_data=FilingRecurringData(initiator=initiator), return_urls=ReturnUrls(success_url=SUCCESS_URL, decline_url=DECLINE_URL, cancel_url=CANCEL_URL, inprocess_url=INPROCESS_URL)) logger.info(request) response = recurrings.create_filing(filing_request=request) assert response is not None # get redirect url redirect_url = response.redirect_url assert redirect_url is not None # Emulate customer behaviour performing GET request to redirect url do_get(response.redirect_url)