Esempio n. 1
0
def initiate_new_plan():
    """Set a new installment plan for the returning shopper"""
    # TODO: Fill-in the data
    resp = api_client.InstallmentPlanApi.installment_plan_initiate(
        splitit.InitiateInstallmentPlanRequest(
            plan_data=splitit.PlanData(
                auto_capture=True,
                amount=splitit.MoneyWithCurrencyCode(300, "USD"),
                number_of_installments=3,
                ref_order_number="abc123",
            ),
            payment_wizard_data=splitit.PaymentWizardData(
                requested_number_of_installments="2,3,4,5,6", ),
            billing_address=splitit.AddressData2(
                address_line="260 Madison Avenue.",
                city="New York",
                state="NY",
                country="USA",
                zip="10016",
            ),
            consumer_data=splitit.ConsumerData(
                full_name="John Smith",
                email="*****@*****.**",
                phone_number="1-415-775-4848",
                culture_name="en-us",
            ),
        ))
    return resp
Esempio n. 2
0
def create_installment_plan():
    resp = api_client.InstallmentPlanApi.installment_plan_create(
        splitit.CreateInstallmentPlanRequest(
            plan_data=splitit.PlanData(
                auto_capture=True,
                amount=splitit.MoneyWithCurrencyCode(600, "USD"),
                number_of_installments=3,
                ref_order_number="abc123",
            ),
            billing_address=splitit.AddressData2(
                address_line="260 Madison Avenue.",
                city="New York",
                state="NY",
                country="USA",
                zip="10016",
            ),
            consumer_data=splitit.ConsumerData(
                full_name="John Smith",
                email="*****@*****.**",
                phone_number="1-415-775-4848",
                culture_name="en-us",
            ),
            credit_card_details=splitit.CardData(
                card_holder_full_name="John Smith",
                card_number="4111111111111111",
                card_exp_year="2022",
                card_exp_month="8",
                card_cvv="123",
            ),
            plan_approval_evidence=splitit.PlanApprovalEvidence(
                are_terms_and_conditions_approved=True, ),
        ))
    return resp
Esempio n. 3
0
def refund_installment_plan(ipn):
    resp = api_client.InstallmentPlanApi.installment_plan_refund(
        splitit.RefundPlanRequest(
            installment_plan_number=ipn,
            amount=splitit.MoneyWithCurrencyCode(200, "USD"),
            refund_strategy=splitit.RefundStrategy.FUTUREINSTALLMENTSFIRST,
        ))
    return resp
def initiate_installment_plan(transactionValue):
    """Use as a handler for Checkout request"""
    # TODO: Customize the data
    resp = api_client.InstallmentPlanApi.installment_plan_initiate(
        splitit.InitiateInstallmentPlanRequest(
            plan_data=splitit.PlanData(
                auto_capture=True,
                amount=splitit.MoneyWithCurrencyCode(transactionValue, "USD"),
                number_of_installments=3,
                ref_order_number="abc123",
                # Request 50% of the transaction as a first installment
                first_installment_amount=splitit.MoneyWithCurrencyCode(
                    0.5 * transactionValue, "USD"),
                # Delay first charge for a week
                first_charge_date=datetime.now() + timedelta(days=7)),
            payment_wizard_data=splitit.PaymentWizardData(
                requested_number_of_installments="2,3,4,5,6", ),
            # Optional data to pre-fill the form
            billing_address=splitit.AddressData2(
                address_line="260 Madison Avenue.",
                city="New York",
                state="NY",
                country="USA",
                zip="10016",
            ),
            # Optional data to pre-fill the form
            consumer_data=splitit.ConsumerData(
                full_name="John Smith",
                email="*****@*****.**",
                phone_number="1-415-775-4848",
                culture_name="en-us",
            ),
            # After user successfully interacts with splitit.com they would be
            # redirected to provided Succeeded URL with InstallmentPlanNumber as
            # a parameter in GET request. It is required to continue the flow.
            redirect_urls=splitit.RedirectUrls(
                succeeded="http://localhost/Succeeded",
                canceled="http://localhost/Canceled",
                failed="http://localhost/Failed",
            ),
        ))

    # TODO: Redirect customer to initPaymentResp.CheckoutUrl
    print("Go to {}\n".format(resp.checkout_url))
    return resp
Esempio n. 5
0
def pay_with_token(new_plan_number, cc_token):
    """Create the installment plan using Credit Card Token"""
    # TODO: Customize the data
    resp = api_client.InstallmentPlanApi.installment_plan_create(
        splitit.CreateInstallmentPlanRequest(
            installment_plan_number=new_plan_number,
            plan_data=splitit.PlanData(amount=splitit.MoneyWithCurrencyCode(
                300, "USD"), ),
            payment_token=splitit.PaymentToken(
                token=cc_token,
                type="SplititStoredCard",
            )))
    print("Successfully payed for the plan")
    return resp