Authorize.net、CIM和ApplePay - 不能多次收取一个令牌的费用。
创始人
2024-09-22 16:01:07
0

以下是一个解决方法的代码示例,使得在使用Authorize.net、CIM和ApplePay时不能多次收取一个令牌的费用。

import net.authorize.Environment;
import net.authorize.api.contract.v1.*;
import net.authorize.api.controller.CreateCustomerProfileController;
import net.authorize.api.controller.CreateCustomerProfileFromTransactionController;
import net.authorize.api.controller.DeleteCustomerProfileController;
import net.authorize.api.controller.GetCustomerProfileController;

public class PaymentProcessor {
    private static final String API_LOGIN_ID = "YOUR_API_LOGIN_ID";
    private static final String TRANSACTION_KEY = "YOUR_TRANSACTION_KEY";

    private static final String AUTHORIZE_NET_API_URL = "https://apitest.authorize.net/xml/v1/request.api";
    private static final String APPLE_PAY_API_URL = "https://api.apple-pay-gateway.apple.com/paymentservices/startSession";

    public static void main(String[] args) {
        // Authorize.net - Create a customer profile
        CustomerProfileType customerProfile = createCustomerProfile("John Doe", "johndoe@example.com");

        // Authorize.net - Create a customer profile from a transaction
        String transactionId = "123456";
        CustomerProfileExType customerProfileFromTransaction = createCustomerProfileFromTransaction(transactionId);

        // Authorize.net - Get customer profile details
        String customerProfileId = "7890";
        CustomerProfileExType customerProfileDetails = getCustomerProfile(customerProfileId);

        // Authorize.net - Delete a customer profile
        deleteCustomerProfile(customerProfileId);

        // Apple Pay - Start a payment session
        String paymentSession = startPaymentSession();

        // Apple Pay - Process payment
        String paymentToken = "abcdef";
        processPayment(paymentSession, paymentToken);
    }

    private static CustomerProfileType createCustomerProfile(String name, String email) {
        MerchantAuthenticationType merchantAuthentication = new MerchantAuthenticationType();
        merchantAuthentication.setName(API_LOGIN_ID);
        merchantAuthentication.setTransactionKey(TRANSACTION_KEY);

        CreateCustomerProfileRequest apiRequest = new CreateCustomerProfileRequest();
        apiRequest.setMerchantAuthentication(merchantAuthentication);

        CustomerProfileType customerProfile = new CustomerProfileType();
        customerProfile.setDescription("Customer profile for " + name);
        customerProfile.setEmail(email);

        apiRequest.setProfile(customerProfile);

        CreateCustomerProfileController controller = new CreateCustomerProfileController(apiRequest);
        controller.setEnvironment(Environment.SANDBOX);
        controller.execute();

        CreateCustomerProfileResponse apiResponse = controller.getApiResponse();
        if (apiResponse != null && apiResponse.getMessages().getResultCode() == MessageTypeEnum.OK) {
            return apiResponse.getCustomerProfileId();
        } else {
            System.out.println("Failed to create customer profile: " + apiResponse.getMessages().getMessage().get(0).getText());
            return null;
        }
    }

    private static CustomerProfileExType createCustomerProfileFromTransaction(String transactionId) {
        MerchantAuthenticationType merchantAuthentication = new MerchantAuthenticationType();
        merchantAuthentication.setName(API_LOGIN_ID);
        merchantAuthentication.setTransactionKey(TRANSACTION_KEY);

        CreateCustomerProfileFromTransactionRequest apiRequest = new CreateCustomerProfileFromTransactionRequest();
        apiRequest.setMerchantAuthentication(merchantAuthentication);

        apiRequest.setTransId(transactionId);

        CreateCustomerProfileFromTransactionController controller = new CreateCustomerProfileFromTransactionController(apiRequest);
        controller.setEnvironment(Environment.SANDBOX);
        controller.execute();

        CreateCustomerProfileResponse apiResponse = controller.getApiResponse();
        if (apiResponse != null && apiResponse.getMessages().getResultCode() == MessageTypeEnum.OK) {
            return apiResponse.getCustomerProfileId();
        } else {
            System.out.println("Failed to create customer profile from transaction: " + apiResponse.getMessages().getMessage().get(0).getText());
            return null;
        }
    }

    private static CustomerProfileExType getCustomerProfile(String customerProfileId) {
        MerchantAuthenticationType merchantAuthentication = new MerchantAuthenticationType();
        merchantAuthentication.setName(API_LOGIN_ID);
        merchantAuthentication.setTransactionKey(TRANSACTION_KEY);

        GetCustomerProfileRequest apiRequest = new GetCustomerProfileRequest();
        apiRequest.setMerchantAuthentication(merchantAuthentication);

        apiRequest.setCustomerProfileId(customerProfileId);

        GetCustomerProfileController controller = new GetCustomerProfileController(apiRequest);
        controller.setEnvironment(Environment.SANDBOX);
        controller.execute();

        GetCustomerProfileResponse apiResponse = controller.getApiResponse();
        if (apiResponse != null && apiResponse.getMessages().getResultCode() == MessageTypeEnum.OK) {
            return apiResponse.getProfile();
        } else {
            System.out.println("Failed to get customer profile details: " + apiResponse.getMessages().getMessage().get(0).getText());
            return null;
        }
    }

    private static void deleteCustomerProfile(String customerProfileId) {
        MerchantAuthentication

相关内容

热门资讯

玩家必备攻略“约局吧德州有挂吗... 玩家必备攻略“约局吧德州有挂吗”开挂(透视)辅助平台(AI教程有挂实锤)《详细加薇136704302...
开挂辅助!微玩盒子网页游戏辅助... 开挂辅助!微玩盒子网页游戏辅助,wepoker底牌透视脚本(透视)开挂辅助脚本(有挂详细)相信很多朋...
透视真的“hhpoker真的有... 透视真的“hhpoker真的有透视吗”开挂(透视)辅助软件(黑科技教程存在有挂)>>您好:软件加13...
辅助开挂!威信茶馆app插件,... 辅助开挂!威信茶馆app插件,hhpoker辅助码怎么用(透视)开挂辅助下载(有挂神器);威信茶馆a...
终于知道“wepoker辅助分... 终于知道“wepoker辅助分析器”开挂(透视)辅助平台(高科技教程有挂秘诀);亲,wepoker辅...
开挂辅助!八张透视辅助,wep... 开挂辅助!八张透视辅助,wepoker辅助工具(透视)开挂辅助平台(新版有挂);AI辅助机器人普及解...
辅助开挂!卡五星辅助器逍遥,w... 辅助开挂!卡五星辅助器逍遥,wepoker插件辅助(透视)开挂辅助神器(有挂教程);1、点击下载安装...
记者揭秘“wepoker有没有... 记者揭秘“wepoker有没有挂”开挂(透视)辅助脚本(德州教程有挂技巧);无需打开直接搜索加(薇:...
开挂辅助!情怀宜春挂,hhpo... 开挂辅助!情怀宜春挂,hhpoker有后台操控吗(透视)开挂辅助工具(有挂助手);一、情怀宜春挂有挂...
分享实测“wepoker透视脚... 分享实测“wepoker透视脚本网页”开挂(透视)辅助插件(微扑克教程竟然有挂);无需打开直接搜索微...