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

相关内容

热门资讯

记者揭秘!智星菠萝辅助(透视辅... 记者揭秘!智星菠萝辅助(透视辅助)拱趴大菠萝辅助神器,扑克教程(有挂细节);模式供您选择,了解更新找...
一分钟揭秘!约局吧能能开挂(透... 一分钟揭秘!约局吧能能开挂(透视辅助)hhpoker辅助靠谱,2024新版教程(有挂教学);约局吧能...
透视辅助!wepoker模拟器... 透视辅助!wepoker模拟器哪个好用(脚本)hhpoker辅助挂是真的,科技教程(有挂技巧);囊括...
透视代打!hhpkoer辅助器... 透视代打!hhpkoer辅助器视频(辅助挂)pokemmo脚本辅助,2024新版教程(有挂教程);风...
透视了解!约局吧德州真的有透视... 透视了解!约局吧德州真的有透视挂(透视脚本)德州局HHpoker透视脚本,必胜教程(有挂分析);亲,...
六分钟了解!wepoker挂底... 六分钟了解!wepoker挂底牌(透视)德普之星开辅助,详细教程(有挂解密);德普之星开辅助是一种具...
9分钟了解!wpk私人辅助(透... 9分钟了解!wpk私人辅助(透视)hhpoker德州透视,插件教程(有挂教学);风靡全球的特色经典游...
推荐一款!wepoker究竟有... 推荐一款!wepoker究竟有透视(脚本)哈糖大菠萝开挂,介绍教程(有挂技术);囊括全国各种wepo...
每日必备!wepoker有人用... 每日必备!wepoker有人用过(脚本)wpk有那种辅助,线上教程(有挂规律);wepoker有人用...
玩家必备教程!wejoker私... 玩家必备教程!wejoker私人辅助软件(脚本)哈糖大菠萝可以开挂,可靠技巧(有挂神器)申哈糖大菠萝...