<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python: refundTransaction isn't working in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56968#M31713</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.developer.cybersource.com/t5/user/viewprofilepage/user-id/21261"&gt;@superseed&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on your description, you're attempting a refund before it settles which is not permitted. &amp;nbsp;Instead, you must Void an unsettled transaction which cancels the entire request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get more details in our response code lookup too:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://developer.authorize.net/api/reference/responseCodes.html?code=54" target="_blank"&gt;https://developer.authorize.net/api/reference/responseCodes.html?code=54&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Richard&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2017 23:02:28 GMT</pubDate>
    <dc:creator>RichardH</dc:creator>
    <dc:date>2017-02-17T23:02:28Z</dc:date>
    <item>
      <title>Python: refundTransaction isn't working</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56967#M31712</link>
      <description>&lt;P&gt;The code below&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Creates a customer profile&lt;/LI&gt;&lt;LI&gt;Creates a payment profile&lt;/LI&gt;&lt;LI&gt;Charges the payment profile&lt;/LI&gt;&lt;LI&gt;Partially refunds the transaction&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Everything works great, except the refund step, which errors with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Error Code: 54&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Error message: The referenced transaction does not meet the criteria for issuing a credit.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Any idea what's wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;from authorizenet import apicontractsv1
from authorizenet.constants import constants
from authorizenet.apicontrollers import *
from decimal import *
import random

# create customer profile
merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = &amp;lt;name&amp;gt;
merchantAuth.transactionKey = &amp;lt;key&amp;gt;

createCustomerProfile = apicontractsv1.createCustomerProfileRequest()
createCustomerProfile.merchantAuthentication = merchantAuth
createCustomerProfile.profile = apicontractsv1.customerProfileType('jdoe' + str(random.randint(0, 10000)), 'John2 Doe', 'jdoe@mail.com')

controller = createCustomerProfileController(createCustomerProfile)
controller.execute()

response = controller.getresponse()

if (response.messages.resultCode=="Ok"):
    print("Successfully created a customer profile with id: %s" % response.customerProfileId)
    customerProfileId = response.customerProfileId
    
    creditCard = apicontractsv1.creditCardType()
    creditCard.cardNumber = "4111111111111111"
    creditCard.expirationDate = "2020-12"

    payment = apicontractsv1.paymentType()
    payment.creditCard = creditCard

    billTo = apicontractsv1.customerAddressType()
    billTo.firstName = "John"
    billTo.lastName = "Snow"

    profile = apicontractsv1.customerPaymentProfileType()
    profile.payment = payment
    profile.billTo = billTo

    createCustomerPaymentProfile = apicontractsv1.createCustomerPaymentProfileRequest()
    createCustomerPaymentProfile.merchantAuthentication = merchantAuth
    createCustomerPaymentProfile.paymentProfile = profile
    print("customerProfileId in create_customer_payment_profile. customerProfileId = %s" %customerProfileId)
    createCustomerPaymentProfile.customerProfileId = str(customerProfileId)

    controller = createCustomerPaymentProfileController(createCustomerPaymentProfile)
    controller.execute()

    response = controller.getresponse()

    if (response.messages.resultCode=="Ok"):
        print("Successfully created a customer payment profile with id: %s" % response.customerPaymentProfileId)
        customerPaymentProfileId = response.customerPaymentProfileId
        
        profileToCharge = apicontractsv1.customerProfilePaymentType()
        profileToCharge.customerProfileId = str(customerProfileId)
        profileToCharge.paymentProfile = apicontractsv1.paymentProfile()
        profileToCharge.paymentProfile.paymentProfileId = str(customerPaymentProfileId)

        transactionrequest = apicontractsv1.transactionRequestType()
        transactionrequest.transactionType = "authCaptureTransaction"
        transactionrequest.amount = Decimal ('35.00')
        transactionrequest.profile = profileToCharge


        createtransactionrequest = apicontractsv1.createTransactionRequest()
        createtransactionrequest.merchantAuthentication = merchantAuth
        createtransactionrequest.refId = "MerchantID-0001"

        createtransactionrequest.transactionRequest = transactionrequest
        createtransactioncontroller = createTransactionController(createtransactionrequest)
        createtransactioncontroller.execute()

        response = createtransactioncontroller.getresponse()

        if response is not None:
            if response.messages.resultCode == "Ok":
                if hasattr(response.transactionResponse, 'messages') == True:
                    print ('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId);
                    print ('Transaction Response Code: %s' % response.transactionResponse.responseCode);
                    print ('Message Code: %s' % response.transactionResponse.messages.message[0].code);
                    print ('Description: %s' % response.transactionResponse.messages.message[0].description);
                    transId = response.transactionResponse.transId
                    
                    
                    creditCard = apicontractsv1.creditCardType()
                    creditCard.cardNumber = "1111"
                    creditCard.expirationDate = "XXXX"

                    payment = apicontractsv1.paymentType()
                    payment.creditCard = creditCard

                    transactionrequest = apicontractsv1.transactionRequestType()
                    transactionrequest.transactionType = "refundTransaction"
                    transactionrequest.amount = Decimal ('15.00')
                    transactionrequest.refTransId = str(transId)
                    transactionrequest.payment = payment


                    createtransactionrequest = apicontractsv1.createTransactionRequest()
                    createtransactionrequest.merchantAuthentication = merchantAuth
                    createtransactionrequest.refId = "MerchantID-0001"

                    createtransactionrequest.transactionRequest = transactionrequest
                    createtransactioncontroller = createTransactionController(createtransactionrequest)
                    createtransactioncontroller.execute()

                    response = createtransactioncontroller.getresponse()

                    if response is not None:
                        if response.messages.resultCode == "Ok":
                            if hasattr(response.transactionResponse, 'messages') == True:
                                print ('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId);
                                print ('Transaction Response Code: %s' % response.transactionResponse.responseCode);
                                print ('Message Code: %s' % response.transactionResponse.messages.message[0].code);
                                print ('Description: %s' % response.transactionResponse.messages.message[0].description);
                            else:
                                print ('Failed Transaction.');
                                if hasattr(response.transactionResponse, 'errors') == True:
                                    print ('Error Code:  %s' % str(response.transactionResponse.errors.error[0].errorCode));
                                    print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText);
                        else:
                            print ('Failed Transaction 2.');
                            if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True:
                                print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode));
                                print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText);
                            else:
                                print ('Error Code 2: %s' % response.messages.message[0]['code'].text);
                                print ('Error message 2: %s' % response.messages.message[0]['text'].text);
                    else:
                        print ('Null Response.');
                    
                    
                    
                    
                    
                else:
                    print ('Failed Transaction.');
                    if hasattr(response.transactionResponse, 'errors') == True:
                        print ('Error Code:  %s' % str(response.transactionResponse.errors.error[0].errorCode));
                        print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText);
            else:
                print ('Failed Transaction 2.');
                if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True:
                    print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode));
                    print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText);
                else:
                    print ('Error Code: %s' % response.messages.message[0]['code'].text);
                    print ('Error message: %s' % response.messages.message[0]['text'].text);
        else:
            print ('Null Response.');

        
    else:
        print("Failed to create customer payment profile %s" % response.messages.message[0]['text'].text)    
    
else:
    print("Failed to create customer payment profile %s" % response.messages.message[0]['text'].text)&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Feb 2017 22:46:18 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56967#M31712</guid>
      <dc:creator>superseed</dc:creator>
      <dc:date>2017-02-17T22:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python: refundTransaction isn't working</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56968#M31713</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.developer.cybersource.com/t5/user/viewprofilepage/user-id/21261"&gt;@superseed&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on your description, you're attempting a refund before it settles which is not permitted. &amp;nbsp;Instead, you must Void an unsettled transaction which cancels the entire request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get more details in our response code lookup too:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://developer.authorize.net/api/reference/responseCodes.html?code=54" target="_blank"&gt;https://developer.authorize.net/api/reference/responseCodes.html?code=54&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Richard&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 23:02:28 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56968#M31713</guid>
      <dc:creator>RichardH</dc:creator>
      <dc:date>2017-02-17T23:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python: refundTransaction isn't working</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56969#M31714</link>
      <description>&lt;P&gt;Is this a timing issue, in that I need to wait until the transaction settles?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If so, how long does that typically take?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 23:08:53 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56969#M31714</guid>
      <dc:creator>superseed</dc:creator>
      <dc:date>2017-02-17T23:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python: refundTransaction isn't working</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56970#M31715</link>
      <description>&lt;P&gt;I should have included that in my response. &amp;nbsp;In both the sandbox and production, transactions settle once a day after the transaction cut-off time specified in the merchant interface.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And, there isn't a way to speed that up in the sandbox.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Richard&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 23:11:58 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Python-refundTransaction-isn-t-working/m-p/56970#M31715</guid>
      <dc:creator>RichardH</dc:creator>
      <dc:date>2017-02-17T23:11:58Z</dc:date>
    </item>
  </channel>
</rss>

