如何在不要求在ios中登录用户的情况下集成Citrus支付网关?

时间:2016-06-02 06:02:09

标签: ios iphone citrus-pay

希望你做得很好。

我正在尝试将CitrusPay SDK集成到我的iPhone应用程序中。如何在不要求用户登录柑橘支付的情况下整合CitrusPay直接付款。

我想为用户提供选项:

  1. 使用Citrus钱包付款
  2. 使用信用卡/借记卡付款
  3. 使用网上银行付款
  4. 如果用户想要使用Citrus钱包付款,那么我会要求用户使用他们的凭据登录柑橘。如果他们使用信用卡/借记卡或网上银行支付第二或第三选项,那么他们就不需要登录。

    我想使用CitrusPay SDK在我的应用中实现此功能。你能指出我的代码吗?

    我已经有了Citrus付费的演示,我已经检查了它。

    https://github.com/citruspay/citruspay-ios-sdk

    我从上面的链接下载了演示。

    请帮帮我。

1 个答案:

答案 0 :(得分:0)

    [CitrusPaymentSDK enableDEBUGLogs];

    CTSKeyStore *keyStore = [[CTSKeyStore alloc] init];
    keyStore.signinId = SignInId;
    keyStore.signinSecret = SignInSecretKey;
    keyStore.signUpId = SubscriptionId;
    keyStore.signUpSecret = SubscriptionSecretKey;
    keyStore.vanity = VanityUrl;

    [CitrusPaymentSDK initializeWithKeyStore:keyStore environment:CTSEnvSandbox];

    [CitrusPaymentSDK enableDEBUGLogs];

    //CC, DC payments
    CTSElectronicCardUpdate *creditCard = [[CTSElectronicCardUpdate alloc] initCreditCard]; //for debit card use > initDebitCard
    creditCard.number = @"";
    creditCard.expiryDate = @"XX/XX"; //only mm/yyyy format
    creditCard.scheme = [CTSUtility fetchCardSchemeForCardNumber:creditCard.number]; //fetch card scheme
    creditCard.ownerName = @"XXXXXXXX"; // no special characters here
    creditCard.cvv = @"XXX";


    CTSPaymentLayer *paymentLayer = [CitrusPaymentSDK fetchSharedPaymentLayer];

    CTSPaymentDetailUpdate *paymentInfo = [[CTSPaymentDetailUpdate alloc] init];
    [paymentInfo addCard:creditCard];

    CTSContactUpdate* contactInfo;
    CTSUserAddress* addressInfo;

    contactInfo = [[CTSContactUpdate alloc] init];
    contactInfo.firstName = @"";
    contactInfo.lastName = @"";
    contactInfo.email = @"";
    contactInfo.mobile = @"";

    addressInfo = [[CTSUserAddress alloc] init];
    addressInfo.city = TEST_CITY;
    addressInfo.country = TEST_COUNTRY;
    addressInfo.state = TEST_STATE;
    addressInfo.street1 = TEST_STREET1;
    addressInfo.street2 = TEST_STREET2;
    addressInfo.zip = TEST_ZIP;


    [CTSUtility requestBillAmount:@"X" billURL:BillUrl callback: ^(CTSBill *bill , NSError *error){

        if(error){
            dispatch_async(dispatch_get_main_queue(), ^{
            });
            [UIUtility toastMessageOnScreen:error.localizedDescription];
        }
        else {
            [paymentLayer requestDirectChargePayment:paymentInfo withContact:contactInfo withAddress:addressInfo bill:bill returnViewController:self withCompletionHandler:^(CTSCitrusCashRes *citrusCashResponse, NSError *error){

                dispatch_async(dispatch_get_main_queue(), ^{
                    //                                    [self.indicatorView stopAnimating];
                    //                                    self.indicatorView.hidden = TRUE;
                });
                if(error){
                    [UIUtility toastMessageOnScreen:error.localizedDescription];
                }
                else {
                    [UIUtility toastMessageOnScreen:[NSString stringWithFormat:@"Payment Status %@",[citrusCashResponse.responseDict valueForKey:@"TxStatus"] ]];
                    //                                    [self resetUI];
                }
            }];
        }
    }];